flutter updates

This commit is contained in:
Christien Rioux 2024-05-20 20:48:17 -04:00
parent cf837e2176
commit ed893852a2
14 changed files with 528 additions and 200 deletions

View File

@ -34,7 +34,7 @@ class ChatSingleContactListWidget extends StatelessWidget {
? const EmptyChatListWidget()
: SearchableList<proto.Chat>(
initialList: chatList.map((x) => x.value).toList(),
builder: (l, i, c) {
itemBuilder: (c) {
final contact =
contactMap[c.remoteConversationRecordKey];
if (contact == null) {

View File

@ -1,5 +1,4 @@
import 'dart:async';
import 'dart:io';
import 'dart:typed_data';
import 'package:awesome_extensions/awesome_extensions.dart';
@ -16,65 +15,64 @@ import '../../theme/theme.dart';
import '../../tools/tools.dart';
import 'invitation_dialog.dart';
class BarcodeOverlay extends CustomPainter {
BarcodeOverlay({
required this.barcode,
required this.arguments,
required this.boxFit,
required this.capture,
});
// class BarcodeOverlay extends CustomPainter {
// BarcodeOverlay({
// required this.barcode,
// required this.boxFit,
// required this.capture,
// required this.size,
// });
final BarcodeCapture capture;
final Barcode barcode;
final MobileScannerArguments arguments;
final BoxFit boxFit;
// final BarcodeCapture capture;
// final Barcode barcode;
// final BoxFit boxFit;
// final Size size;
@override
void paint(Canvas canvas, Size size) {
final adjustedSize = applyBoxFit(boxFit, arguments.size, size);
// @override
// void paint(Canvas canvas, Size size) {
// final adjustedSize = applyBoxFit(boxFit, size, size);
var verticalPadding = size.height - adjustedSize.destination.height;
var horizontalPadding = size.width - adjustedSize.destination.width;
if (verticalPadding > 0) {
verticalPadding = verticalPadding / 2;
} else {
verticalPadding = 0;
}
// var verticalPadding = size.height - adjustedSize.destination.height;
// var horizontalPadding = size.width - adjustedSize.destination.width;
// if (verticalPadding > 0) {
// verticalPadding = verticalPadding / 2;
// } else {
// verticalPadding = 0;
// }
if (horizontalPadding > 0) {
horizontalPadding = horizontalPadding / 2;
} else {
horizontalPadding = 0;
}
// if (horizontalPadding > 0) {
// horizontalPadding = horizontalPadding / 2;
// } else {
// horizontalPadding = 0;
// }
final ratioWidth = (Platform.isIOS ? capture.width : arguments.size.width) /
adjustedSize.destination.width;
final ratioHeight =
(Platform.isIOS ? capture.height : arguments.size.height) /
adjustedSize.destination.height;
// final ratioWidth = (Platform.isIOS ? capture.size.width : size.width) /
// adjustedSize.destination.width;
// final ratioHeight = (Platform.isIOS ? capture.size.height : size.height) /
// adjustedSize.destination.height;
final adjustedOffset = <Offset>[];
for (final offset in barcode.corners) {
adjustedOffset.add(
Offset(
offset.dx / ratioWidth + horizontalPadding,
offset.dy / ratioHeight + verticalPadding,
),
);
}
final cutoutPath = Path()..addPolygon(adjustedOffset, true);
// final adjustedOffset = <Offset>[];
// for (final offset in barcode.corners) {
// adjustedOffset.add(
// Offset(
// offset.dx / ratioWidth + horizontalPadding,
// offset.dy / ratioHeight + verticalPadding,
// ),
// );
// }
// final cutoutPath = Path()..addPolygon(adjustedOffset, true);
final backgroundPaint = Paint()
..color = Colors.red.withOpacity(0.3)
..style = PaintingStyle.fill
..blendMode = BlendMode.dstOut;
// final backgroundPaint = Paint()
// ..color = Colors.red.withOpacity(0.3)
// ..style = PaintingStyle.fill
// ..blendMode = BlendMode.dstOut;
canvas.drawPath(cutoutPath, backgroundPaint);
}
// canvas.drawPath(cutoutPath, backgroundPaint);
// }
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) => false;
}
// @override
// bool shouldRepaint(covariant CustomPainter oldDelegate) => false;
// }
class ScannerOverlay extends CustomPainter {
ScannerOverlay(this.scanWindow);
@ -202,9 +200,9 @@ class ScanInvitationDialogState extends State<ScanInvitationDialog> {
IconButton(
color: Colors.white,
icon: ValueListenableBuilder(
valueListenable: cameraController.torchState,
valueListenable: cameraController,
builder: (context, state, child) {
switch (state) {
switch (state.torchState) {
case TorchState.off:
return Icon(Icons.flash_off,
color:
@ -212,6 +210,12 @@ class ScanInvitationDialogState extends State<ScanInvitationDialog> {
case TorchState.on:
return Icon(Icons.flash_on,
color: scale.primaryScale.primary);
case TorchState.auto:
return Icon(Icons.flash_auto,
color: scale.primaryScale.primary);
case TorchState.unavailable:
return Icon(Icons.no_flash,
color: scale.primaryScale.primary);
}
},
),
@ -236,10 +240,9 @@ class ScanInvitationDialogState extends State<ScanInvitationDialog> {
IconButton(
color: Colors.white,
icon: ValueListenableBuilder(
valueListenable:
cameraController.cameraFacingState,
valueListenable: cameraController,
builder: (context, state, child) {
switch (state) {
switch (state.cameraDirection) {
case CameraFacing.front:
return const Icon(Icons.camera_front);
case CameraFacing.back:
@ -265,7 +268,7 @@ class ScanInvitationDialogState extends State<ScanInvitationDialog> {
SchedulerBinding.instance
.addPostFrameCallback((_) {
cameraController.dispose();
Navigator.pop(context, null);
Navigator.pop(context);
})
})),
],

View File

@ -38,7 +38,7 @@ class ContactListWidget extends StatelessWidget {
? const EmptyContactListWidget()
: SearchableList<proto.Contact>(
initialList: contactList.toList(),
builder: (l, i, c) =>
itemBuilder: (c) =>
ContactItemWidget(contact: c, disabled: disabled)
.paddingLTRB(0, 4, 0, 0),
filter: (value) {

View File

@ -1,8 +1,9 @@
@Timeout(Duration(seconds: 240))
//@Timeout(Duration(seconds: 240))
library veilid_support_integration_test;
//library veilid_support_integration_test;
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/foundation.dart';
import 'package:test/test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:veilid_test/veilid_test.dart';
@ -28,6 +29,10 @@ void main() {
group('Started Tests', () {
setUpAll(veilidFixture.setUp);
tearDownAll(veilidFixture.tearDown);
tearDownAll(() {
final endTime = DateTime.now();
debugPrintSynchronously('Duration: ${endTime.difference(startTime)}');
});
group('Attached Tests', () {
setUpAll(veilidFixture.attach);
@ -58,7 +63,7 @@ void main() {
test('create shortarray stride=$stride',
makeTestDHTShortArrayCreateDelete(stride: stride));
test('add shortarray stride=$stride',
makeTestDHTShortArrayAdd(stride: 256));
makeTestDHTShortArrayAdd(stride: stride));
}
});
@ -70,14 +75,11 @@ void main() {
test('create log stride=$stride',
makeTestDHTLogCreateDelete(stride: stride));
test('add/truncate log stride=$stride',
makeTestDHTLogAddTruncate(stride: 256),
makeTestDHTLogAddTruncate(stride: stride),
timeout: const Timeout(Duration(seconds: 480)));
}
});
});
});
});
final endTime = DateTime.now();
print('Duration: ${endTime.difference(startTime)}');
}

View File

@ -1,6 +1,30 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
_fe_analyzer_shared:
dependency: transitive
description:
name: _fe_analyzer_shared
sha256: "0b2f2bd91ba804e53a61d757b986f89f1f9eaed5b11e4b2f5a2468d86d6c9fc7"
url: "https://pub.dev"
source: hosted
version: "67.0.0"
analyzer:
dependency: transitive
description:
name: analyzer
sha256: "37577842a27e4338429a1cbc32679d508836510b056f1eedf0c8d20e39c1383d"
url: "https://pub.dev"
source: hosted
version: "6.4.1"
args:
dependency: transitive
description:
name: args
sha256: "7cf60b9f0cc88203c5a190b4cd62a99feea42759a7fa695010eb5de1c0b2252a"
url: "https://pub.dev"
source: hosted
version: "2.5.0"
async:
dependency: transitive
description:
@ -81,6 +105,30 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.18.0"
convert:
dependency: transitive
description:
name: convert
sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592"
url: "https://pub.dev"
source: hosted
version: "3.1.1"
coverage:
dependency: transitive
description:
name: coverage
sha256: "3945034e86ea203af7a056d98e98e42a5518fff200d6e8e6647e1886b07e936e"
url: "https://pub.dev"
source: hosted
version: "1.8.0"
crypto:
dependency: transitive
description:
name: crypto
sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab
url: "https://pub.dev"
source: hosted
version: "3.0.3"
cupertino_icons:
dependency: "direct main"
description:
@ -109,10 +157,10 @@ packages:
dependency: transitive
description:
name: fast_immutable_collections
sha256: "38fbc50df5b219dcfb83ebbc3275ec09872530ca1153858fc56fceadb310d037"
sha256: "533806a7f0c624c2e479d05d3fdce4c87109a7cd0db39b8cc3830d3a2e8dedc7"
url: "https://pub.dev"
source: hosted
version: "10.2.2"
version: "10.2.3"
ffi:
dependency: transitive
description:
@ -165,11 +213,27 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.4.1"
frontend_server_client:
dependency: transitive
description:
name: frontend_server_client
sha256: f64a0333a82f30b0cca061bc3d143813a486dc086b574bfb233b7c1372427694
url: "https://pub.dev"
source: hosted
version: "4.0.0"
fuchsia_remote_debug_protocol:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
glob:
dependency: transitive
description:
name: glob
sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63"
url: "https://pub.dev"
source: hosted
version: "2.1.2"
globbing:
dependency: transitive
description:
@ -178,11 +242,43 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.0"
http_multi_server:
dependency: transitive
description:
name: http_multi_server
sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b"
url: "https://pub.dev"
source: hosted
version: "3.2.1"
http_parser:
dependency: transitive
description:
name: http_parser
sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b"
url: "https://pub.dev"
source: hosted
version: "4.0.2"
integration_test:
dependency: "direct dev"
description: flutter
source: sdk
version: "0.0.0"
io:
dependency: transitive
description:
name: io
sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e"
url: "https://pub.dev"
source: hosted
version: "1.0.4"
js:
dependency: transitive
description:
name: js
sha256: c1b2e9b5ea78c45e1a0788d29606ba27dc5f71f019f32ca5140f61ef071838cf
url: "https://pub.dev"
source: hosted
version: "0.7.1"
json_annotation:
dependency: transitive
description:
@ -195,26 +291,26 @@ packages:
dependency: transitive
description:
name: leak_tracker
sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a"
url: "https://pub.dev"
source: hosted
version: "10.0.0"
version: "10.0.4"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8"
url: "https://pub.dev"
source: hosted
version: "2.0.1"
version: "3.0.3"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
url: "https://pub.dev"
source: hosted
version: "2.0.1"
version: "3.0.1"
lint_hard:
dependency: "direct dev"
description:
@ -223,6 +319,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.0.0"
logging:
dependency: transitive
description:
name: logging
sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
loggy:
dependency: transitive
description:
@ -251,10 +355,34 @@ packages:
dependency: transitive
description:
name: meta
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
url: "https://pub.dev"
source: hosted
version: "1.11.0"
version: "1.12.0"
mime:
dependency: transitive
description:
name: mime
sha256: "2e123074287cc9fd6c09de8336dae606d1ddb88d9ac47358826db698c176a1f2"
url: "https://pub.dev"
source: hosted
version: "1.0.5"
node_preamble:
dependency: transitive
description:
name: node_preamble
sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db"
url: "https://pub.dev"
source: hosted
version: "2.0.2"
package_config:
dependency: transitive
description:
name: package_config
sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd"
url: "https://pub.dev"
source: hosted
version: "2.1.0"
path:
dependency: transitive
description:
@ -327,6 +455,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.8"
pool:
dependency: transitive
description:
name: pool
sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a"
url: "https://pub.dev"
source: hosted
version: "1.5.1"
process:
dependency: transitive
description:
@ -343,11 +479,67 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.1.0"
pub_semver:
dependency: transitive
description:
name: pub_semver
sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c"
url: "https://pub.dev"
source: hosted
version: "2.1.4"
shelf:
dependency: transitive
description:
name: shelf
sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4
url: "https://pub.dev"
source: hosted
version: "1.4.1"
shelf_packages_handler:
dependency: transitive
description:
name: shelf_packages_handler
sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e"
url: "https://pub.dev"
source: hosted
version: "3.0.2"
shelf_static:
dependency: transitive
description:
name: shelf_static
sha256: a41d3f53c4adf0f57480578c1d61d90342cd617de7fc8077b1304643c2d85c1e
url: "https://pub.dev"
source: hosted
version: "1.1.2"
shelf_web_socket:
dependency: transitive
description:
name: shelf_web_socket
sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1"
url: "https://pub.dev"
source: hosted
version: "1.0.4"
sky_engine:
dependency: transitive
description: flutter
source: sdk
version: "0.0.99"
source_map_stack_trace:
dependency: transitive
description:
name: source_map_stack_trace
sha256: "84cf769ad83aa6bb61e0aa5a18e53aea683395f196a6f39c4c881fb90ed4f7ae"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
source_maps:
dependency: transitive
description:
name: source_maps
sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703"
url: "https://pub.dev"
source: hosted
version: "0.10.12"
source_span:
dependency: transitive
description:
@ -412,14 +604,38 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.2.1"
test:
dependency: "direct dev"
description:
name: test
sha256: "7ee446762c2c50b3bd4ea96fe13ffac69919352bd3b4b17bac3f3465edc58073"
url: "https://pub.dev"
source: hosted
version: "1.25.2"
test_api:
dependency: transitive
description:
name: test_api
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f"
url: "https://pub.dev"
source: hosted
version: "0.6.1"
version: "0.7.0"
test_core:
dependency: transitive
description:
name: test_core
sha256: "2bc4b4ecddd75309300d8096f781c0e3280ca1ef85beda558d33fcbedc2eead4"
url: "https://pub.dev"
source: hosted
version: "0.6.0"
typed_data:
dependency: transitive
description:
name: typed_data
sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c
url: "https://pub.dev"
source: hosted
version: "1.3.2"
vector_math:
dependency: transitive
description:
@ -453,10 +669,34 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec"
url: "https://pub.dev"
source: hosted
version: "13.0.0"
version: "14.2.1"
watcher:
dependency: transitive
description:
name: watcher
sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8"
url: "https://pub.dev"
source: hosted
version: "1.1.0"
web:
dependency: transitive
description:
name: web
sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27"
url: "https://pub.dev"
source: hosted
version: "0.5.1"
web_socket_channel:
dependency: transitive
description:
name: web_socket_channel
sha256: "58c6666b342a38816b2e7e50ed0f1e261959630becd4c879c4f26bfa14aa5a42"
url: "https://pub.dev"
source: hosted
version: "2.4.5"
webdriver:
dependency: transitive
description:
@ -465,14 +705,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.0.3"
webkit_inspection_protocol:
dependency: transitive
description:
name: webkit_inspection_protocol
sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572"
url: "https://pub.dev"
source: hosted
version: "1.2.1"
win32:
dependency: transitive
description:
name: win32
sha256: "0eaf06e3446824099858367950a813472af675116bf63f008a4c2a75ae13e9cb"
sha256: a79dbe579cb51ecd6d30b17e0cae4e0ea15e2c0e66f69ad4198f22a6789e94f4
url: "https://pub.dev"
source: hosted
version: "5.5.0"
version: "5.5.1"
xdg_directories:
dependency: transitive
description:
@ -481,6 +729,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.4"
yaml:
dependency: transitive
description:
name: yaml
sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5"
url: "https://pub.dev"
source: hosted
version: "3.1.2"
sdks:
dart: ">=3.3.4 <4.0.0"
dart: ">=3.4.0 <4.0.0"
flutter: ">=3.19.1"

View File

@ -20,6 +20,7 @@ dev_dependencies:
integration_test:
sdk: flutter
lint_hard: ^4.0.0
test: ^1.25.2
veilid_test:
path: ../../../../veilid/veilid-flutter/packages/veilid_test

View File

@ -36,6 +36,9 @@ class _DHTLogAppend extends _DHTLogRead implements DHTAppendTruncateRandomRead {
_spine.allocateTail(values.length);
// Look up the first position and shortarray
final dws = DelayedWaitSet<void>();
var success = true;
for (var valueIdx = 0; valueIdx < values.length;) {
final remaining = values.length - valueIdx;
@ -45,25 +48,32 @@ class _DHTLogAppend extends _DHTLogRead implements DHTAppendTruncateRandomRead {
}
final sacount = min(remaining, DHTShortArray.maxElements - lookup.pos);
final success =
await lookup.shortArray.scope((sa) => sa.operateWrite((write) async {
// If this a new segment, then clear it in
// case we have wrapped around
if (lookup.pos == 0) {
await write.clear();
} else if (lookup.pos != write.length) {
// We should always be appending at the length
throw StateError('appending should be at the end');
}
return write
.tryAddItems(values.sublist(valueIdx, valueIdx + sacount));
}));
if (!success) {
return false;
}
final sublistValues = values.sublist(valueIdx, valueIdx + sacount);
dws.add(() async {
final ok = await lookup.shortArray
.scope((sa) => sa.operateWrite((write) async {
// If this a new segment, then clear it in
// case we have wrapped around
if (lookup.pos == 0) {
await write.clear();
} else if (lookup.pos != write.length) {
// We should always be appending at the length
throw StateError('appending should be at the end');
}
return write.tryAddItems(sublistValues);
}));
if (!ok) {
success = false;
}
});
valueIdx += sacount;
}
return true;
await dws(chunkSize: maxDHTConcurrency);
return success;
}
@override

View File

@ -215,7 +215,7 @@ class _DHTShortArrayHead {
}
} on Exception catch (_) {
// On any exception close the records we have opened
await Future.wait(newRecords.entries.map((e) => e.value.close()));
await newRecords.entries.map((e) => e.value.close()).wait;
rethrow;
}
@ -259,13 +259,22 @@ class _DHTShortArrayHead {
/////////////////////////////////////////////////////////////////////////////
// Linked record management
Future<DHTRecord> _getOrCreateLinkedRecord(int recordNumber) async {
Future<DHTRecord> _getOrCreateLinkedRecord(
int recordNumber, bool allowCreate) async {
if (recordNumber == 0) {
return _headRecord;
}
final pool = DHTRecordPool.instance;
recordNumber--;
while (recordNumber >= _linkedRecords.length) {
if (recordNumber < _linkedRecords.length) {
return _linkedRecords[recordNumber];
}
if (!allowCreate) {
throw StateError("asked for non-existent record and can't create");
}
final pool = DHTRecordPool.instance;
for (var rn = _linkedRecords.length; rn <= recordNumber; rn++) {
// Linked records must use SMPL schema so writer can be specified
// Use the same writer as the head record
final smplWriter = _headRecord.writer!;
@ -287,9 +296,6 @@ class _DHTShortArrayHead {
// Add to linked records
_linkedRecords.add(dhtRecord);
}
if (!await _writeHead()) {
throw StateError('failed to add linked record');
}
return _linkedRecords[recordNumber];
}
@ -313,15 +319,16 @@ class _DHTShortArrayHead {
);
}
Future<DHTShortArrayHeadLookup> lookupPosition(int pos) async {
Future<DHTShortArrayHeadLookup> lookupPosition(
int pos, bool allowCreate) async {
final idx = _index[pos];
return lookupIndex(idx);
return lookupIndex(idx, allowCreate);
}
Future<DHTShortArrayHeadLookup> lookupIndex(int idx) async {
Future<DHTShortArrayHeadLookup> lookupIndex(int idx, bool allowCreate) async {
final seq = idx < _seqs.length ? _seqs[idx] : 0xFFFFFFFF;
final recordNumber = idx ~/ _stride;
final record = await _getOrCreateLinkedRecord(recordNumber);
final record = await _getOrCreateLinkedRecord(recordNumber, allowCreate);
final recordSubkey = (idx % _stride) + ((recordNumber == 0) ? 1 : 0);
return DHTShortArrayHeadLookup(
record: record, recordSubkey: recordSubkey, seq: seq);
@ -378,7 +385,7 @@ class _DHTShortArrayHead {
assert(
newKeys.length <=
(DHTShortArray.maxElements + (_stride - 1)) ~/ _stride,
'too many keys');
'too many keys: $newKeys.length');
assert(newKeys.length == linkedKeys.length, 'duplicated linked keys');
final newIndex = index.toSet();
assert(newIndex.length <= DHTShortArray.maxElements, 'too many indexes');

View File

@ -15,7 +15,7 @@ class _DHTShortArrayRead implements DHTRandomRead {
throw IndexError.withLength(pos, length);
}
final lookup = await _head.lookupPosition(pos);
final lookup = await _head.lookupPosition(pos, false);
final refresh = forceRefresh || _head.positionNeedsRefresh(pos);
final outSeqNum = Output<int>();

View File

@ -17,37 +17,77 @@ class _DHTShortArrayWrite extends _DHTShortArrayRead
@override
Future<bool> tryInsertItem(int pos, Uint8List value) async {
if (pos < 0 || pos > _head.length) {
throw IndexError.withLength(pos, _head.length);
}
// Allocate empty index at position
_head.allocateIndex(pos);
// Write item
final ok = await tryWriteItem(pos, value);
if (!ok) {
_head.freeIndex(pos);
var success = false;
try {
// Write item
success = await tryWriteItem(pos, value);
} finally {
if (!success) {
_head.freeIndex(pos);
}
}
return true;
}
@override
Future<bool> tryInsertItems(int pos, List<Uint8List> values) async {
// Allocate empty indices at the end of the list
if (pos < 0 || pos > _head.length) {
throw IndexError.withLength(pos, _head.length);
}
// Allocate empty indices
for (var i = 0; i < values.length; i++) {
_head.allocateIndex(pos + i);
}
// Write items
var success = true;
final dws = DelayedWaitSet<void>();
for (var i = 0; i < values.length; i++) {
dws.add(() async {
final ok = await tryWriteItem(pos + i, values[i]);
if (!ok) {
_head.freeIndex(pos + i);
success = false;
final outSeqNums = List.generate(values.length, (_) => Output<int>());
final lookups = <DHTShortArrayHeadLookup>[];
try {
// do all lookups
for (var i = 0; i < values.length; i++) {
final lookup = await _head.lookupPosition(pos + i, true);
lookups.add(lookup);
}
// Write items in parallel
final dws = DelayedWaitSet<void>();
for (var i = 0; i < values.length; i++) {
final lookup = lookups[i];
final value = values[i];
final outSeqNum = outSeqNums[i];
dws.add(() async {
final outValue = await lookup.record.tryWriteBytes(value,
subkey: lookup.recordSubkey, outSeqNum: outSeqNum);
if (outValue != null) {
success = false;
}
});
}
await dws(chunkSize: maxDHTConcurrency, onChunkDone: (_) => success);
} finally {
// Update sequence numbers
for (var i = 0; i < values.length; i++) {
if (outSeqNums[i].value != null) {
_head.updatePositionSeq(pos + i, true, outSeqNums[i].value!);
}
});
}
// Free indices if this was a failure
if (!success) {
for (var i = 0; i < values.length; i++) {
_head.freeIndex(pos);
}
}
}
await dws(chunkSize: maxDHTConcurrency, onChunkDone: (_) => success);
return success;
}
@ -68,7 +108,7 @@ class _DHTShortArrayWrite extends _DHTShortArrayRead
if (pos < 0 || pos >= _head.length) {
throw IndexError.withLength(pos, _head.length);
}
final lookup = await _head.lookupPosition(pos);
final lookup = await _head.lookupPosition(pos, true);
final outSeqNum = Output<int>();
@ -98,24 +138,22 @@ class _DHTShortArrayWrite extends _DHTShortArrayRead
if (pos < 0 || pos >= _head.length) {
throw IndexError.withLength(pos, _head.length);
}
final lookup = await _head.lookupPosition(pos);
final outSeqNum = Output<int>();
final lookup = await _head.lookupPosition(pos, true);
final outSeqNumRead = Output<int>();
final oldValue = lookup.seq == 0xFFFFFFFF
? null
: await lookup.record
.get(subkey: lookup.recordSubkey, outSeqNum: outSeqNum);
if (outSeqNum.value != null) {
_head.updatePositionSeq(pos, false, outSeqNum.value!);
.get(subkey: lookup.recordSubkey, outSeqNum: outSeqNumRead);
if (outSeqNumRead.value != null) {
_head.updatePositionSeq(pos, false, outSeqNumRead.value!);
}
final outSeqNumWrite = Output<int>();
final result = await lookup.record.tryWriteBytes(newValue,
subkey: lookup.recordSubkey, outSeqNum: outSeqNum);
if (outSeqNum.value != null) {
_head.updatePositionSeq(pos, true, outSeqNum.value!);
subkey: lookup.recordSubkey, outSeqNum: outSeqNumWrite);
if (outSeqNumWrite.value != null) {
_head.updatePositionSeq(pos, true, outSeqNumWrite.value!);
}
if (result != null) {

View File

@ -85,10 +85,10 @@ packages:
dependency: transitive
description:
name: build_daemon
sha256: "0343061a33da9c5810b2d6cee51945127d8f4c060b7fbdd9d54917f0a3feaaa1"
sha256: "79b2aef6ac2ed00046867ed354c88778c9c0f029df8a20fe10b5436826721ef9"
url: "https://pub.dev"
source: hosted
version: "4.0.1"
version: "4.0.2"
build_resolvers:
dependency: transitive
description:
@ -101,10 +101,10 @@ packages:
dependency: "direct dev"
description:
name: build_runner
sha256: "3ac61a79bfb6f6cc11f693591063a7f19a7af628dc52f141743edac5c16e8c22"
sha256: "1414d6d733a85d8ad2f1dfcb3ea7945759e35a123cb99ccfac75d0758f75edfa"
url: "https://pub.dev"
source: hosted
version: "2.4.9"
version: "2.4.10"
build_runner_core:
dependency: transitive
description:
@ -221,10 +221,10 @@ packages:
dependency: "direct main"
description:
name: fast_immutable_collections
sha256: "38fbc50df5b219dcfb83ebbc3275ec09872530ca1153858fc56fceadb310d037"
sha256: "533806a7f0c624c2e479d05d3fdce4c87109a7cd0db39b8cc3830d3a2e8dedc7"
url: "https://pub.dev"
source: hosted
version: "10.2.2"
version: "10.2.3"
ffi:
dependency: transitive
description:
@ -399,10 +399,10 @@ packages:
dependency: "direct main"
description:
name: meta
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
url: "https://pub.dev"
source: hosted
version: "1.11.0"
version: "1.12.0"
mime:
dependency: transitive
description:
@ -763,10 +763,10 @@ packages:
dependency: transitive
description:
name: win32
sha256: "0eaf06e3446824099858367950a813472af675116bf63f008a4c2a75ae13e9cb"
sha256: a79dbe579cb51ecd6d30b17e0cae4e0ea15e2c0e66f69ad4198f22a6789e94f4
url: "https://pub.dev"
source: hosted
version: "5.5.0"
version: "5.5.1"
xdg_directories:
dependency: transitive
description:
@ -784,5 +784,5 @@ packages:
source: hosted
version: "3.1.2"
sdks:
dart: ">=3.3.0 <4.0.0"
dart: ">=3.4.0 <4.0.0"
flutter: ">=3.19.1"

View File

@ -12,11 +12,11 @@ dependencies:
bloc_advanced_tools: ^0.1.1
collection: ^1.18.0
equatable: ^2.0.5
fast_immutable_collections: ^10.2.2
fast_immutable_collections: ^10.2.3
freezed_annotation: ^2.4.1
json_annotation: ^4.9.0
loggy: ^2.0.3
meta: ^1.11.0
meta: ^1.12.0
protobuf: ^3.1.0
veilid:
@ -24,7 +24,7 @@ dependencies:
path: ../../../veilid/veilid-flutter
dev_dependencies:
build_runner: ^2.4.9
build_runner: ^2.4.10
freezed: ^2.5.2
json_serializable: ^6.8.0
lint_hard: ^4.0.0

View File

@ -68,10 +68,10 @@ packages:
dependency: "direct main"
description:
name: awesome_extensions
sha256: c3bf11d07a69fe10ff5541717b920661c7a87a791ee182851f1c92a2d15b95a2
sha256: "07e52221467e651cab9219a26286245760831c3852ea2c54883a48a54f120d7c"
url: "https://pub.dev"
source: hosted
version: "2.0.14"
version: "2.0.16"
badges:
dependency: "direct main"
description:
@ -139,10 +139,10 @@ packages:
dependency: transitive
description:
name: build_daemon
sha256: "0343061a33da9c5810b2d6cee51945127d8f4c060b7fbdd9d54917f0a3feaaa1"
sha256: "79b2aef6ac2ed00046867ed354c88778c9c0f029df8a20fe10b5436826721ef9"
url: "https://pub.dev"
source: hosted
version: "4.0.1"
version: "4.0.2"
build_resolvers:
dependency: transitive
description:
@ -155,10 +155,10 @@ packages:
dependency: "direct dev"
description:
name: build_runner
sha256: "3ac61a79bfb6f6cc11f693591063a7f19a7af628dc52f141743edac5c16e8c22"
sha256: "1414d6d733a85d8ad2f1dfcb3ea7945759e35a123cb99ccfac75d0758f75edfa"
url: "https://pub.dev"
source: hosted
version: "2.4.9"
version: "2.4.10"
build_runner_core:
dependency: transitive
description:
@ -219,10 +219,10 @@ packages:
dependency: transitive
description:
name: camera_android
sha256: "7b0aba6398afa8475e2bc9115d976efb49cf8db781e922572d443795c04a4f4f"
sha256: b350ac087f111467e705b2b76cc1322f7f5bdc122aa83b4b243b0872f390d229
url: "https://pub.dev"
source: hosted
version: "0.10.9+1"
version: "0.10.9+2"
camera_avfoundation:
dependency: transitive
description:
@ -387,10 +387,10 @@ packages:
dependency: transitive
description:
name: diffutil_dart
sha256: e0297e4600b9797edff228ed60f4169a778ea357691ec98408fa3b72994c7d06
sha256: "5e74883aedf87f3b703cb85e815bdc1ed9208b33501556e4a8a5572af9845c81"
url: "https://pub.dev"
source: hosted
version: "3.0.0"
version: "4.0.1"
equatable:
dependency: "direct main"
description:
@ -403,10 +403,10 @@ packages:
dependency: "direct main"
description:
name: fast_immutable_collections
sha256: "38fbc50df5b219dcfb83ebbc3275ec09872530ca1153858fc56fceadb310d037"
sha256: "533806a7f0c624c2e479d05d3fdce4c87109a7cd0db39b8cc3830d3a2e8dedc7"
url: "https://pub.dev"
source: hosted
version: "10.2.2"
version: "10.2.3"
ffi:
dependency: transitive
description:
@ -472,10 +472,10 @@ packages:
dependency: "direct main"
description:
name: flutter_chat_ui
sha256: c8580c85e2d29359ffc84147e643d08d883eb6e757208652377f0105ef58807f
sha256: "40fb37acc328dd179eadc3d67bf8bd2d950dc0da34464aa8d48e8707e0234c09"
url: "https://pub.dev"
source: hosted
version: "1.6.12"
version: "1.6.13"
flutter_form_builder:
dependency: "direct main"
description:
@ -634,10 +634,10 @@ packages:
dependency: "direct main"
description:
name: go_router
sha256: b465e99ce64ba75e61c8c0ce3d87b66d8ac07f0b35d0a7e0263fcfc10f99e836
sha256: aa073287b8f43553678e6fa9e8bb9c83212ff76e09542129a8099bbc8db4df65
url: "https://pub.dev"
source: hosted
version: "13.2.5"
version: "14.1.2"
graphs:
dependency: transitive
description:
@ -714,10 +714,10 @@ packages:
dependency: "direct main"
description:
name: intl
sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d"
sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf
url: "https://pub.dev"
source: hosted
version: "0.18.1"
version: "0.19.0"
io:
dependency: transitive
description:
@ -802,10 +802,10 @@ packages:
dependency: "direct main"
description:
name: meta
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
url: "https://pub.dev"
source: hosted
version: "1.11.0"
version: "1.12.0"
mime:
dependency: transitive
description:
@ -818,10 +818,10 @@ packages:
dependency: "direct main"
description:
name: mobile_scanner
sha256: "827765afbd4792ff3fd105ad593821ac0f6d8a7d352689013b07ee85be336312"
sha256: b8c0e9afcfd52534f85ec666f3d52156f560b5e6c25b1e3d4fe2087763607926
url: "https://pub.dev"
source: hosted
version: "4.0.1"
version: "5.1.1"
motion_toast:
dependency: "direct main"
description:
@ -938,10 +938,10 @@ packages:
dependency: transitive
description:
name: photo_view
sha256: "8036802a00bae2a78fc197af8a158e3e2f7b500561ed23b4c458107685e645bb"
sha256: "1fc3d970a91295fbd1364296575f854c9863f225505c28c46e0a03e48960c75e"
url: "https://pub.dev"
source: hosted
version: "0.14.0"
version: "0.15.0"
pinput:
dependency: "direct main"
description:
@ -1106,26 +1106,26 @@ packages:
dependency: "direct main"
description:
name: searchable_listview
sha256: f9bc1a57dfcba49ce2d190d642567fb82309dd23849b3b0a328266e3f90054db
sha256: dfa6358f5e097f45b5b51a160cb6189e112e3abe0f728f4740349cd3b6575617
url: "https://pub.dev"
source: hosted
version: "2.12.0"
version: "2.13.0"
share_plus:
dependency: "direct main"
description:
name: share_plus
sha256: fb5319f3aab4c5dda5ebb92dca978179ba21f8c783ee4380910ef4c1c6824f51
sha256: ef3489a969683c4f3d0239010cc8b7a2a46543a8d139e111c06c558875083544
url: "https://pub.dev"
source: hosted
version: "8.0.3"
version: "9.0.0"
share_plus_platform_interface:
dependency: transitive
description:
name: share_plus_platform_interface
sha256: "251eb156a8b5fa9ce033747d73535bf53911071f8d3b6f4f0b578505ce0d4496"
sha256: "0f9e4418835d1b2c3ae78fdb918251959106cefdbc4dd43526e182f80e82f6d4"
url: "https://pub.dev"
source: hosted
version: "3.4.0"
version: "4.0.0"
shared_preferences:
dependency: "direct main"
description:
@ -1194,10 +1194,10 @@ packages:
dependency: transitive
description:
name: shelf_web_socket
sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1"
sha256: "073c147238594ecd0d193f3456a5fe91c4b0abbcc68bf5cd95b36c4e194ac611"
url: "https://pub.dev"
source: hosted
version: "1.0.4"
version: "2.0.0"
signal_strength_indicator:
dependency: "direct main"
description:
@ -1399,10 +1399,10 @@ packages:
dependency: transitive
description:
name: url_launcher_android
sha256: "360a6ed2027f18b73c8d98e159dda67a61b7f2e0f6ec26e86c3ada33b0621775"
sha256: "17cd5e205ea615e2c6ea7a77323a11712dffa0720a8a90540db57a01347f9ad9"
url: "https://pub.dev"
source: hosted
version: "6.3.1"
version: "6.3.2"
url_launcher_ios:
dependency: transitive
description:
@ -1529,30 +1529,38 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.5.1"
web_socket:
dependency: transitive
description:
name: web_socket
sha256: "217f49b5213796cb508d6a942a5dc604ce1cb6a0a6b3d8cb3f0c314f0ecea712"
url: "https://pub.dev"
source: hosted
version: "0.1.4"
web_socket_channel:
dependency: transitive
description:
name: web_socket_channel
sha256: "58c6666b342a38816b2e7e50ed0f1e261959630becd4c879c4f26bfa14aa5a42"
sha256: a2d56211ee4d35d9b344d9d4ce60f362e4f5d1aafb988302906bd732bc731276
url: "https://pub.dev"
source: hosted
version: "2.4.5"
version: "3.0.0"
win32:
dependency: transitive
description:
name: win32
sha256: "0eaf06e3446824099858367950a813472af675116bf63f008a4c2a75ae13e9cb"
sha256: a79dbe579cb51ecd6d30b17e0cae4e0ea15e2c0e66f69ad4198f22a6789e94f4
url: "https://pub.dev"
source: hosted
version: "5.5.0"
version: "5.5.1"
window_manager:
dependency: "direct main"
description:
name: window_manager
sha256: b3c895bdf936c77b83c5254bec2e6b3f066710c1f89c38b20b8acc382b525494
sha256: "8699323b30da4cdbe2aa2e7c9de567a6abd8a97d9a5c850a3c86dcd0b34bbfbf"
url: "https://pub.dev"
source: hosted
version: "0.3.8"
version: "0.3.9"
xdg_directories:
dependency: transitive
description:
@ -1610,5 +1618,5 @@ packages:
source: hosted
version: "1.1.2"
sdks:
dart: ">=3.3.0 <4.0.0"
dart: ">=3.4.0 <4.0.0"
flutter: ">=3.19.1"

View File

@ -44,14 +44,14 @@ dependencies:
flutter_translate: ^4.0.4
form_builder_validators: ^9.1.0
freezed_annotation: ^2.4.1
go_router: ^13.2.5
go_router: ^14.1.2
hydrated_bloc: ^9.1.5
image: ^4.1.7
intl: ^0.18.1
json_annotation: ^4.9.0
loggy: ^2.0.3
meta: ^1.11.0
mobile_scanner: ^4.0.1
mobile_scanner: ^5.1.1
motion_toast: ^2.9.1
pasteboard: ^0.2.0
path: ^1.9.0
@ -66,7 +66,7 @@ dependencies:
radix_colors: ^1.0.4
reorderable_grid: ^1.0.10
searchable_listview: ^2.12.0
share_plus: ^8.0.3
share_plus: ^9.0.0
shared_preferences: ^2.2.3
signal_strength_indicator: ^0.4.1
split_view: ^3.2.1
@ -88,6 +88,9 @@ dependency_overrides:
path: ../dart_async_tools
bloc_advanced_tools:
path: ../bloc_advanced_tools
# REMOVE ONCE form_builder_validators HAS A FIX UPSTREAM
intl: 0.19.0
dev_dependencies:
build_runner: ^2.4.9