From 9f4e82e8397928e0d30683e1b87ade825cfddc7c Mon Sep 17 00:00:00 2001 From: Parker Lougheed Date: Thu, 13 Feb 2025 10:08:47 -0600 Subject: [PATCH] Update to Dart 3.7 and reformat with tall style (#228) * Update to Dart 3.7 and reformat with tall style * Remove require_trailing_commas lint --- command_line/bin/github_activity.dart | 11 ++- command_line/lib/github_activity.dart | 8 +- command_line/lib/src/options.dart | 18 ++-- command_line/lib/src/options.g.dart | 88 +++++++++---------- command_line/lib/src/util.dart | 24 ++--- command_line/pubspec.yaml | 2 +- command_line/test/github_stats_test.dart | 10 ++- enhanced_enums/lib/comparable_mixin.dart | 6 +- enhanced_enums/pubspec.yaml | 2 +- extension_methods/example/fluid_api.dart | 4 +- extension_methods/example/json_helpers.dart | 5 +- extension_methods/pubspec.yaml | 2 +- ffi/hello_world/hello.dart | 27 ++++-- ffi/hello_world/pubspec.yaml | 2 +- ffi/hello_world/test/hello_world_test.dart | 12 ++- ffi/primitives/primitives.dart | 31 +++++-- ffi/primitives/pubspec.yaml | 2 +- ffi/primitives/test/primitives_test.dart | 23 +++-- ffi/structs/pubspec.yaml | 2 +- ffi/structs/structs.dart | 62 ++++++++----- ffi/structs/test/structs_test.dart | 15 ++-- ffi/system_command/pubspec.yaml | 2 +- ffi/system_command/win32ui.dart | 39 ++++---- ffi/system_command/windows.dart | 45 ++++++---- ffi/test_utils/pubspec.yaml | 2 +- isolates/bin/long_running_isolate.dart | 6 +- isolates/pubspec.yaml | 2 +- native_app/pubspec.yaml | 2 +- null_safety/calculate_lix/bin/main.dart | 14 +-- null_safety/calculate_lix/lib/lix.dart | 6 +- null_safety/calculate_lix/pubspec.yaml | 2 +- .../example/example.dart | 11 +-- .../example/scheduler_example.dart | 15 ++-- .../lib/constraint_solver.dart | 6 +- package_constraint_solver/pubspec.yaml | 2 +- .../test/constraint_solver_test.dart | 34 ++----- parameters/lib/super_initalizer.dart | 22 +---- parameters/pubspec.yaml | 2 +- parameters/test/named_parameters_test.dart | 10 +-- server/google_apis/bin/server.dart | 32 ++++--- server/google_apis/pubspec.yaml | 2 +- server/simple/analysis_options.yaml | 1 - server/simple/bin/server.dart | 52 +++++------ server/simple/pubspec.yaml | 2 +- server/simple/test/docker_test.dart | 10 +-- server/simple/test/server_test.dart | 12 +-- 46 files changed, 348 insertions(+), 341 deletions(-) diff --git a/command_line/bin/github_activity.dart b/command_line/bin/github_activity.dart index f6b3556..84696c8 100644 --- a/command_line/bin/github_activity.dart +++ b/command_line/bin/github_activity.dart @@ -20,13 +20,16 @@ void main(List args) { } var fetcher = ActivityService( - options.user!, options.verbose!, options.interval, - formatter: _getFormatter(options)); + options.user!, + options.verbose!, + options.interval, + formatter: _getFormatter(options), + ); // Stream the github activity to the console fetcher.getActivityStrings().listen((s) { - print(s); - }) + print(s); + }) ..onDone(() => exit(0)) ..onError((e) => print('Unable to fetch stats:\n$e')); } diff --git a/command_line/lib/github_activity.dart b/command_line/lib/github_activity.dart index 6f61435..8fd3a4b 100644 --- a/command_line/lib/github_activity.dart +++ b/command_line/lib/github_activity.dart @@ -32,8 +32,12 @@ class ActivityService { final EventFormatter formatter; static const _supportedEventTypes = ['PullRequestEvent', 'IssuesEvent']; - ActivityService(this.username, this.verbose, this.interval, - {this.formatter = const DefaultEventFormatter()}); + ActivityService( + this.username, + this.verbose, + this.interval, { + this.formatter = const DefaultEventFormatter(), + }); /// Returns a stream of formatted lines for printing to the console. Stream getActivityStrings() async* { diff --git a/command_line/lib/src/options.dart b/command_line/lib/src/options.dart index 74a807f..0025fcb 100644 --- a/command_line/lib/src/options.dart +++ b/command_line/lib/src/options.dart @@ -28,10 +28,12 @@ class Options { final bool? verbose; @CliOption( - abbr: 'f', - help: 'The format to display. Defaults to ' - '"Friday, October 18 at 13:55 PM: opened "', - allowed: ['default', 'markdown']) + abbr: 'f', + help: + 'The format to display. Defaults to ' + '"Friday, October 18 at 13:55 PM: opened "', + allowed: ['default', 'markdown'], + ) final String? format; @CliOption(abbr: 'h', negatable: false, help: 'Prints usage information.') @@ -47,8 +49,8 @@ enum Interval { month; Duration get duration => switch (this) { - Interval.day => const Duration(days: 1), - Interval.week => const Duration(days: 7), - Interval.month => const Duration(days: 30), - }; + Interval.day => const Duration(days: 1), + Interval.week => const Duration(days: 7), + Interval.month => const Duration(days: 30), + }; } diff --git a/command_line/lib/src/options.g.dart b/command_line/lib/src/options.g.dart index c68fd03..601f5b5 100644 --- a/command_line/lib/src/options.g.dart +++ b/command_line/lib/src/options.g.dart @@ -10,62 +10,58 @@ T _$enumValueHelper(Map enumValues, String source) => enumValues.entries .singleWhere( (e) => e.value == source, - orElse: () => throw ArgumentError( - '`$source` is not one of the supported values: ' - '${enumValues.values.join(', ')}', - ), + orElse: + () => + throw ArgumentError( + '`$source` is not one of the supported values: ' + '${enumValues.values.join(', ')}', + ), ) .key; Options _$parseOptionsResult(ArgResults result) => Options( - result['user'] as String?, - _$enumValueHelper( - _$IntervalEnumMapBuildCli, - result['interval'] as String, - ), - result['verbose'] as bool?, - result['format'] as String?, - result['help'] as bool, - ); + result['user'] as String?, + _$enumValueHelper(_$IntervalEnumMapBuildCli, result['interval'] as String), + result['verbose'] as bool?, + result['format'] as String?, + result['help'] as bool, +); const _$IntervalEnumMapBuildCli = { Interval.day: 'day', Interval.week: 'week', - Interval.month: 'month' + Interval.month: 'month', }; -ArgParser _$populateOptionsParser(ArgParser parser) => parser - ..addOption( - 'user', - abbr: 'u', - help: 'Required. The GitHub user', - ) - ..addOption( - 'interval', - abbr: 'i', - help: 'The time interval to filter events.', - defaultsTo: 'week', - allowed: ['day', 'week', 'month'], - ) - ..addFlag( - 'verbose', - abbr: 'v', - help: 'Print additional event types', - defaultsTo: false, - ) - ..addOption( - 'format', - abbr: 'f', - help: - 'The format to display. Defaults to "Friday, October 18 at 13:55 PM: opened "', - allowed: ['default', 'markdown'], - ) - ..addFlag( - 'help', - abbr: 'h', - help: 'Prints usage information.', - negatable: false, - ); +ArgParser _$populateOptionsParser(ArgParser parser) => + parser + ..addOption('user', abbr: 'u', help: 'Required. The GitHub user') + ..addOption( + 'interval', + abbr: 'i', + help: 'The time interval to filter events.', + defaultsTo: 'week', + allowed: ['day', 'week', 'month'], + ) + ..addFlag( + 'verbose', + abbr: 'v', + help: 'Print additional event types', + defaultsTo: false, + ) + ..addOption( + 'format', + abbr: 'f', + help: + 'The format to display. Defaults to "Friday, October 18 at 13:55 PM: opened "', + allowed: ['default', 'markdown'], + ) + ..addFlag( + 'help', + abbr: 'h', + help: 'Prints usage information.', + negatable: false, + ); final _$parserForOptions = _$populateOptionsParser(ArgParser()); diff --git a/command_line/lib/src/util.dart b/command_line/lib/src/util.dart index ac5e2d9..b66ca50 100644 --- a/command_line/lib/src/util.dart +++ b/command_line/lib/src/util.dart @@ -9,22 +9,22 @@ import 'options.dart'; String? extractAction(Event event) => event.payload!['action']; String? extractUrl(Event event) => switch (event.type) { - 'PullRequestEvent' => event.payload!['pull_request']['html_url'], - 'IssuesEvent' => event.payload!['issue']['html_url'], - _ => null, - }; + 'PullRequestEvent' => event.payload!['pull_request']['html_url'], + 'IssuesEvent' => event.payload!['issue']['html_url'], + _ => null, +}; String? extractTitle(Event event) => switch (event.type) { - 'PullRequestEvent' => event.payload!['pull_request']['title'], - 'IssuesEvent' => event.payload!['issue']['title'], - _ => null, - }; + 'PullRequestEvent' => event.payload!['pull_request']['title'], + 'IssuesEvent' => event.payload!['issue']['title'], + _ => null, +}; int? extractIssueNumber(Event event) => switch (event.type) { - 'PullRequestEvent' => event.payload!['pull_request']['number'], - 'IssuesEvent' => event.payload!['issue']['number'], - _ => null, - }; + 'PullRequestEvent' => event.payload!['pull_request']['number'], + 'IssuesEvent' => event.payload!['issue']['number'], + _ => null, +}; bool isTooOld(DateTime? date, Interval interval) => date?.isBefore(DateTime.now().subtract(interval.duration)) ?? true; diff --git a/command_line/pubspec.yaml b/command_line/pubspec.yaml index 7c9c020..d734a66 100644 --- a/command_line/pubspec.yaml +++ b/command_line/pubspec.yaml @@ -7,7 +7,7 @@ description: >- publish_to: none environment: - sdk: ^3.5.0 + sdk: ^3.7.0 dependencies: args: ^2.5.0 diff --git a/command_line/test/github_stats_test.dart b/command_line/test/github_stats_test.dart index 8e85236..5021aa5 100644 --- a/command_line/test/github_stats_test.dart +++ b/command_line/test/github_stats_test.dart @@ -21,7 +21,7 @@ void main() { payload: { 'action': 'closed', 'pull_request': { - 'html_url': 'https://github.com/peermaps/random-slicing/issues/2' + 'html_url': 'https://github.com/peermaps/random-slicing/issues/2', }, }, org: org, @@ -32,8 +32,10 @@ void main() { // Don't check exact date since it is formatted as local time. expect(output, contains('Tuesday, October 1 at ')); expect( - output, - contains( - 'substack closed https://github.com/peermaps/random-slicing/issues/2')); + output, + contains( + 'substack closed https://github.com/peermaps/random-slicing/issues/2', + ), + ); }); } diff --git a/enhanced_enums/lib/comparable_mixin.dart b/enhanced_enums/lib/comparable_mixin.dart index e9d50e2..39b512c 100644 --- a/enhanced_enums/lib/comparable_mixin.dart +++ b/enhanced_enums/lib/comparable_mixin.dart @@ -3,11 +3,7 @@ // BSD-style license that can be found in the LICENSE file. /// Enum that implements a Comparable using a mixin -enum Ordering with EnumIndexOrdering { - zero, - few, - many; -} +enum Ordering with EnumIndexOrdering { zero, few, many } /// Mixin that uses the enum index to create a comparable mixin EnumIndexOrdering on Enum implements Comparable { diff --git a/enhanced_enums/pubspec.yaml b/enhanced_enums/pubspec.yaml index 1fec478..a473b92 100644 --- a/enhanced_enums/pubspec.yaml +++ b/enhanced_enums/pubspec.yaml @@ -5,7 +5,7 @@ description: Samples that demonstrates the enhanced enums syntax publish_to: none environment: - sdk: ^3.5.0 + sdk: ^3.7.0 dev_dependencies: lints: ^5.0.0 diff --git a/extension_methods/example/fluid_api.dart b/extension_methods/example/fluid_api.dart index a1a8276..63075dc 100644 --- a/extension_methods/example/fluid_api.dart +++ b/extension_methods/example/fluid_api.dart @@ -18,8 +18,8 @@ void main() { extension on Group { void removeYoungest() { - var sorted = people.toList() - ..sort((a, b) => a.dayOfBirth.compareTo(b.dayOfBirth)); + var sorted = + people.toList()..sort((a, b) => a.dayOfBirth.compareTo(b.dayOfBirth)); var youngest = sorted.last; people.remove(youngest); } diff --git a/extension_methods/example/json_helpers.dart b/extension_methods/example/json_helpers.dart index d536789..b63339d 100644 --- a/extension_methods/example/json_helpers.dart +++ b/extension_methods/example/json_helpers.dart @@ -7,10 +7,7 @@ /// /// This might create a false sense of (type) security, so use with caution. void main() { - var json = { - 'id': 100, - 'name': 'Dash', - }; + var json = {'id': 100, 'name': 'Dash'}; print("${json.name}'s ID is ${json.id}."); // Dash's ID is 100. } diff --git a/extension_methods/pubspec.yaml b/extension_methods/pubspec.yaml index 4ad72b1..f706a85 100644 --- a/extension_methods/pubspec.yaml +++ b/extension_methods/pubspec.yaml @@ -6,7 +6,7 @@ description: >- publish_to: none environment: - sdk: ^3.5.0 + sdk: ^3.7.0 dev_dependencies: lints: ^5.0.0 diff --git a/ffi/hello_world/hello.dart b/ffi/hello_world/hello.dart index 47323ef..35e47c2 100644 --- a/ffi/hello_world/hello.dart +++ b/ffi/hello_world/hello.dart @@ -14,25 +14,36 @@ typedef HelloWorld = void Function(); void main() { // Open the dynamic library - var libraryPath = - path.join(Directory.current.path, 'hello_library', 'libhello.so'); + var libraryPath = path.join( + Directory.current.path, + 'hello_library', + 'libhello.so', + ); if (Platform.isMacOS) { - libraryPath = - path.join(Directory.current.path, 'hello_library', 'libhello.dylib'); + libraryPath = path.join( + Directory.current.path, + 'hello_library', + 'libhello.dylib', + ); } if (Platform.isWindows) { libraryPath = path.join( - Directory.current.path, 'hello_library', 'Debug', 'hello.dll'); + Directory.current.path, + 'hello_library', + 'Debug', + 'hello.dll', + ); } final dylib = ffi.DynamicLibrary.open(libraryPath); // Look up the C function 'hello_world' - final HelloWorld hello = dylib - .lookup>('hello_world') - .asFunction(); + final HelloWorld hello = + dylib + .lookup>('hello_world') + .asFunction(); // Call the function hello(); } diff --git a/ffi/hello_world/pubspec.yaml b/ffi/hello_world/pubspec.yaml index 293dfb4..633c791 100644 --- a/ffi/hello_world/pubspec.yaml +++ b/ffi/hello_world/pubspec.yaml @@ -7,7 +7,7 @@ description: >- publish_to: none environment: - sdk: ^3.5.0 + sdk: ^3.7.0 dependencies: path: ^1.9.0 diff --git a/ffi/hello_world/test/hello_world_test.dart b/ffi/hello_world/test/hello_world_test.dart index a46b844..6a9740d 100644 --- a/ffi/hello_world/test/hello_world_test.dart +++ b/ffi/hello_world/test/hello_world_test.dart @@ -7,13 +7,17 @@ void main() async { group('hello_world', () { test('make dylib + execute', () async { // run 'cmake .' - var cmake = - await Process.run('cmake', ['.'], workingDirectory: 'hello_library'); + var cmake = await Process.run('cmake', [ + '.', + ], workingDirectory: 'hello_library'); expect(cmake.exitCode, 0); // run 'make' - var make = - await Process.run('make', [], workingDirectory: 'hello_library'); + var make = await Process.run( + 'make', + [], + workingDirectory: 'hello_library', + ); expect(make.exitCode, 0); var filePath = getLibraryFilePath('hello_library', 'hello'); diff --git a/ffi/primitives/primitives.dart b/ffi/primitives/primitives.dart index f002685..e7de48c 100644 --- a/ffi/primitives/primitives.dart +++ b/ffi/primitives/primitives.dart @@ -36,14 +36,24 @@ typedef FreePointer = void Function(Pointer a); void main() { // Open the dynamic library var libraryPath = path.join( - Directory.current.path, 'primitives_library', 'libprimitives.so'); + Directory.current.path, + 'primitives_library', + 'libprimitives.so', + ); if (Platform.isMacOS) { libraryPath = path.join( - Directory.current.path, 'primitives_library', 'libprimitives.dylib'); + Directory.current.path, + 'primitives_library', + 'libprimitives.dylib', + ); } if (Platform.isWindows) { libraryPath = path.join( - Directory.current.path, 'primitives_library', 'Debug', 'primtives.dll'); + Directory.current.path, + 'primitives_library', + 'Debug', + 'primtives.dll', + ); } final dylib = DynamicLibrary.open(libraryPath); @@ -59,8 +69,9 @@ void main() { // Place a value into the address p.value = 3; - final subtractPointer = - dylib.lookup>('subtract'); + final subtractPointer = dylib.lookup>( + 'subtract', + ); final subtract = subtractPointer.asFunction(); print('3 - 5 = ${subtract(p, 5)}'); @@ -68,8 +79,9 @@ void main() { calloc.free(p); // calls int *multiply(int a, int b); - final multiplyPointer = - dylib.lookup>('multiply'); + final multiplyPointer = dylib.lookup>( + 'multiply', + ); final multiply = multiplyPointer.asFunction(); final resultPointer = multiply(3, 5); // Fetch the result at the address pointed to @@ -77,8 +89,9 @@ void main() { print('3 * 5 = $result'); // Free up allocated memory. This time in C, because it was allocated in C. - final freePointerPointer = - dylib.lookup>('free_pointer'); + final freePointerPointer = dylib.lookup>( + 'free_pointer', + ); final freePointer = freePointerPointer.asFunction(); freePointer(resultPointer); } diff --git a/ffi/primitives/pubspec.yaml b/ffi/primitives/pubspec.yaml index b812ce6..1271824 100644 --- a/ffi/primitives/pubspec.yaml +++ b/ffi/primitives/pubspec.yaml @@ -5,7 +5,7 @@ description: A super simple example of calling C code from Dart with FFI publish_to: none environment: - sdk: ^3.5.0 + sdk: ^3.7.0 dependencies: ffi: ^2.1.3 diff --git a/ffi/primitives/test/primitives_test.dart b/ffi/primitives/test/primitives_test.dart index 07e1611..43300f4 100644 --- a/ffi/primitives/test/primitives_test.dart +++ b/ffi/primitives/test/primitives_test.dart @@ -7,13 +7,17 @@ void main() async { group('primitives', () { test('make dylib + execute', () async { // run 'cmake .' - var cmake = await Process.run('cmake', ['.'], - workingDirectory: 'primitives_library'); + var cmake = await Process.run('cmake', [ + '.', + ], workingDirectory: 'primitives_library'); expect(cmake.exitCode, 0); // run 'make' - var make = - await Process.run('make', [], workingDirectory: 'primitives_library'); + var make = await Process.run( + 'make', + [], + workingDirectory: 'primitives_library', + ); expect(make.exitCode, 0); // Verify dynamic library was created @@ -28,10 +32,13 @@ void main() async { // Verify program output expect(dartProcess.stderr, isEmpty); expect( - dartProcess.stdout, - equals('3 + 5 = 8\n' - '3 - 5 = -2\n' - '3 * 5 = 15\n')); + dartProcess.stdout, + equals( + '3 + 5 = 8\n' + '3 - 5 = -2\n' + '3 * 5 = 15\n', + ), + ); }); }); } diff --git a/ffi/structs/pubspec.yaml b/ffi/structs/pubspec.yaml index 0f09148..c135a5f 100644 --- a/ffi/structs/pubspec.yaml +++ b/ffi/structs/pubspec.yaml @@ -7,7 +7,7 @@ description: >- publish_to: none environment: - sdk: ^3.5.0 + sdk: ^3.7.0 dependencies: ffi: ^2.1.3 diff --git a/ffi/structs/structs.dart b/ffi/structs/structs.dart index 0a7c620..6375d78 100644 --- a/ffi/structs/structs.dart +++ b/ffi/structs/structs.dart @@ -38,36 +38,47 @@ typedef FreeStringNative = Void Function(Pointer str); typedef FreeString = void Function(Pointer str); // C function: struct Coordinate create_coordinate(double latitude, double longitude) -typedef CreateCoordinateNative = Coordinate Function( - Double latitude, Double longitude); -typedef CreateCoordinate = Coordinate Function( - double latitude, double longitude); +typedef CreateCoordinateNative = + Coordinate Function(Double latitude, Double longitude); +typedef CreateCoordinate = + Coordinate Function(double latitude, double longitude); // C function: struct Place create_place(char *name, double latitude, double longitude) -typedef CreatePlaceNative = Place Function( - Pointer name, Double latitude, Double longitude); -typedef CreatePlace = Place Function( - Pointer name, double latitude, double longitude); +typedef CreatePlaceNative = + Place Function(Pointer name, Double latitude, Double longitude); +typedef CreatePlace = + Place Function(Pointer name, double latitude, double longitude); typedef DistanceNative = Double Function(Coordinate p1, Coordinate p2); typedef Distance = double Function(Coordinate p1, Coordinate p2); void main() { // Open the dynamic library - var libraryPath = - path.join(Directory.current.path, 'structs_library', 'libstructs.so'); + var libraryPath = path.join( + Directory.current.path, + 'structs_library', + 'libstructs.so', + ); if (Platform.isMacOS) { libraryPath = path.join( - Directory.current.path, 'structs_library', 'libstructs.dylib'); + Directory.current.path, + 'structs_library', + 'libstructs.dylib', + ); } if (Platform.isWindows) { libraryPath = path.join( - Directory.current.path, 'structs_library', 'Debug', 'structs.dll'); + Directory.current.path, + 'structs_library', + 'Debug', + 'structs.dll', + ); } final dylib = DynamicLibrary.open(libraryPath); - final helloWorld = - dylib.lookupFunction('hello_world'); + final helloWorld = dylib.lookupFunction( + 'hello_world', + ); final message = helloWorld().toDartString(); print(message); @@ -79,26 +90,31 @@ void main() { calloc.free(backwardsUtf8); print('$backwards reversed is $reversedMessage'); - final freeString = - dylib.lookupFunction('free_string'); + final freeString = dylib.lookupFunction( + 'free_string', + ); freeString(reversedMessageUtf8); - final createCoordinate = - dylib.lookupFunction( - 'create_coordinate'); + final createCoordinate = dylib + .lookupFunction( + 'create_coordinate', + ); final coordinate = createCoordinate(3.5, 4.6); print( - 'Coordinate is lat ${coordinate.latitude}, long ${coordinate.longitude}'); + 'Coordinate is lat ${coordinate.latitude}, long ${coordinate.longitude}', + ); final myHomeUtf8 = 'My Home'.toNativeUtf8(); - final createPlace = - dylib.lookupFunction('create_place'); + final createPlace = dylib.lookupFunction( + 'create_place', + ); final place = createPlace(myHomeUtf8, 42.0, 24.0); final name = place.name.toDartString(); calloc.free(myHomeUtf8); final coord = place.coordinate; print( - 'The name of my place is $name at ${coord.latitude}, ${coord.longitude}'); + 'The name of my place is $name at ${coord.latitude}, ${coord.longitude}', + ); final distance = dylib.lookupFunction('distance'); final dist = distance(createCoordinate(2.0, 2.0), createCoordinate(5.0, 6.0)); print("distance between (2,2) and (5,6) = $dist"); diff --git a/ffi/structs/test/structs_test.dart b/ffi/structs/test/structs_test.dart index f95932f..0dd4461 100644 --- a/ffi/structs/test/structs_test.dart +++ b/ffi/structs/test/structs_test.dart @@ -7,13 +7,17 @@ void main() async { group('structs', () { test('make dylib + execute', () async { // run 'cmake .' - var cmake = await Process.run('cmake', ['.'], - workingDirectory: 'structs_library'); + var cmake = await Process.run('cmake', [ + '.', + ], workingDirectory: 'structs_library'); expect(cmake.exitCode, 0); // run 'make' - var make = - await Process.run('make', [], workingDirectory: 'structs_library'); + var make = await Process.run( + 'make', + [], + workingDirectory: 'structs_library', + ); expect(make.exitCode, 0); // Verify dynamic library was created @@ -32,7 +36,8 @@ void main() async { }); } -const _expected = 'Hello World\n' +const _expected = + 'Hello World\n' 'backwards reversed is sdrawkcab\n' 'Coordinate is lat 3.5, long 4.6\n' 'The name of my place is My Home at 42.0, 24.0\n' diff --git a/ffi/system_command/pubspec.yaml b/ffi/system_command/pubspec.yaml index 06c8d27..44835c7 100644 --- a/ffi/system_command/pubspec.yaml +++ b/ffi/system_command/pubspec.yaml @@ -5,7 +5,7 @@ description: A FFI application that invokes system commands. publish_to: none environment: - sdk: ^3.5.0 + sdk: ^3.7.0 dependencies: ffi: ^2.1.3 diff --git a/ffi/system_command/win32ui.dart b/ffi/system_command/win32ui.dart index 028cd3a..56f9fb1 100644 --- a/ffi/system_command/win32ui.dart +++ b/ffi/system_command/win32ui.dart @@ -18,18 +18,20 @@ int MessageBoxW( UINT uType ); */ -typedef MessageBoxC = Int32 Function( - Pointer hwnd, - Pointer lpText, - Pointer lpCaption, - Uint32 uType, -); -typedef MessageBoxDart = int Function( - Pointer parentWindow, - Pointer message, - Pointer caption, - int type, -); +typedef MessageBoxC = + Int32 Function( + Pointer hwnd, + Pointer lpText, + Pointer lpCaption, + Uint32 uType, + ); +typedef MessageBoxDart = + int Function( + Pointer parentWindow, + Pointer message, + Pointer caption, + int type, + ); const MB_ABORTRETRYIGNORE = 0x00000002; const MB_CANCELTRYCONTINUE = 0x00000006; @@ -54,16 +56,21 @@ int messageBox(String message, String caption) { final user32 = DynamicLibrary.open('user32.dll'); // Look up the `MessageBoxW` function. - final messageBoxP = - user32.lookupFunction('MessageBoxW'); + final messageBoxP = user32.lookupFunction( + 'MessageBoxW', + ); // Allocate pointers to Utf16 arrays containing the command arguments. final messageP = message.toNativeUtf16(); final captionP = caption.toNativeUtf16(); // Invoke the command, and free the pointers. - final result = - messageBoxP(nullptr, messageP, captionP, MB_OK | MB_ICONINFORMATION); + final result = messageBoxP( + nullptr, + messageP, + captionP, + MB_OK | MB_ICONINFORMATION, + ); calloc.free(messageP); calloc.free(captionP); diff --git a/ffi/system_command/windows.dart b/ffi/system_command/windows.dart index 3e3acae..404a342 100644 --- a/ffi/system_command/windows.dart +++ b/ffi/system_command/windows.dart @@ -22,28 +22,33 @@ HINSTANCE ShellExecuteW( https://docs.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shellexecutew */ -typedef ShellExecuteC = ffi.Int32 Function( - ffi.Pointer hwnd, - ffi.Pointer lpOperation, - ffi.Pointer lpFile, - ffi.Pointer lpParameters, - ffi.Pointer lpDirectory, - ffi.Uint32 nShowCmd); -typedef ShellExecuteDart = int Function( - ffi.Pointer parentWindow, - ffi.Pointer operation, - ffi.Pointer file, - ffi.Pointer parameters, - ffi.Pointer directory, - int showCmd); +typedef ShellExecuteC = + ffi.Int32 Function( + ffi.Pointer hwnd, + ffi.Pointer lpOperation, + ffi.Pointer lpFile, + ffi.Pointer lpParameters, + ffi.Pointer lpDirectory, + ffi.Uint32 nShowCmd, + ); +typedef ShellExecuteDart = + int Function( + ffi.Pointer parentWindow, + ffi.Pointer operation, + ffi.Pointer file, + ffi.Pointer parameters, + ffi.Pointer directory, + int showCmd, + ); int shellExecute(String operation, String file) { // Load shell32. final dylib = ffi.DynamicLibrary.open('shell32.dll'); // Look up the `ShellExecuteW` function. - final shellExecuteP = - dylib.lookupFunction('ShellExecuteW'); + final shellExecuteP = dylib.lookupFunction( + 'ShellExecuteW', + ); // Allocate pointers to Utf8 arrays containing the command arguments. final operationP = operation.toNativeUtf16(); @@ -52,7 +57,13 @@ int shellExecute(String operation, String file) { // Invoke the command, and free the pointers. var result = shellExecuteP( - ffi.nullptr, operationP, fileP, ffi.nullptr, ffi.nullptr, SW_SHOWNORMAL); + ffi.nullptr, + operationP, + fileP, + ffi.nullptr, + ffi.nullptr, + SW_SHOWNORMAL, + ); calloc.free(operationP); calloc.free(fileP); diff --git a/ffi/test_utils/pubspec.yaml b/ffi/test_utils/pubspec.yaml index 47835e8..7295afe 100644 --- a/ffi/test_utils/pubspec.yaml +++ b/ffi/test_utils/pubspec.yaml @@ -4,7 +4,7 @@ name: test_utils publish_to: none environment: - sdk: ^3.5.0 + sdk: ^3.7.0 dependencies: path: ^1.9.0 diff --git a/isolates/bin/long_running_isolate.dart b/isolates/bin/long_running_isolate.dart index c33f0c1..529399c 100644 --- a/isolates/bin/long_running_isolate.dart +++ b/isolates/bin/long_running_isolate.dart @@ -11,11 +11,7 @@ import 'dart:isolate'; import 'package:async/async.dart'; -const filenames = [ - 'json_01.json', - 'json_02.json', - 'json_03.json', -]; +const filenames = ['json_01.json', 'json_02.json', 'json_03.json']; void main() async { await for (final jsonData in _sendAndReceive(filenames)) { diff --git a/isolates/pubspec.yaml b/isolates/pubspec.yaml index 882d88e..4240771 100644 --- a/isolates/pubspec.yaml +++ b/isolates/pubspec.yaml @@ -3,7 +3,7 @@ description: A sample command-line application. publish_to: none environment: - sdk: ^3.5.0 + sdk: ^3.7.0 dependencies: async: ^2.11.0 diff --git a/native_app/pubspec.yaml b/native_app/pubspec.yaml index 3c6b1a1..904fc7a 100644 --- a/native_app/pubspec.yaml +++ b/native_app/pubspec.yaml @@ -7,7 +7,7 @@ description: >- publish_to: none environment: - sdk: ^3.5.0 + sdk: ^3.7.0 dev_dependencies: lints: ^5.0.0 diff --git a/null_safety/calculate_lix/bin/main.dart b/null_safety/calculate_lix/bin/main.dart index b172242..eb333d4 100644 --- a/null_safety/calculate_lix/bin/main.dart +++ b/null_safety/calculate_lix/bin/main.dart @@ -24,12 +24,16 @@ void main(List arguments) { // Calculate lix. try { final l = Lix.fromString(File(fileName).readAsStringSync()); - print('Lix is: ${l.readability}, ${l.describe()} to read ' - '(words: ${l.words}, long words: ${l.longWords}, ' - 'periods: ${l.periods}).'); + print( + 'Lix is: ${l.readability}, ${l.describe()} to read ' + '(words: ${l.words}, long words: ${l.longWords}, ' + 'periods: ${l.periods}).', + ); } catch (error) { - print('Invalid input, could not calculate lix!\n' - 'The input text must contain at least one full sentence.'); + print( + 'Invalid input, could not calculate lix!\n' + 'The input text must contain at least one full sentence.', + ); } } } diff --git a/null_safety/calculate_lix/lib/lix.dart b/null_safety/calculate_lix/lib/lix.dart index 3907e46..e6e1a6b 100644 --- a/null_safety/calculate_lix/lib/lix.dart +++ b/null_safety/calculate_lix/lib/lix.dart @@ -26,11 +26,7 @@ class Lix { /// the fields 'required', meaning that a value must be passed to the /// constructor. 'required' is a new keyword introduced as part of null safety /// which replaces the previous '@required' annotation. - Lix({ - required this.words, - required this.longWords, - required this.periods, - }) { + Lix({required this.words, required this.longWords, required this.periods}) { readability = _calculate(); } diff --git a/null_safety/calculate_lix/pubspec.yaml b/null_safety/calculate_lix/pubspec.yaml index c8b906f..65967dc 100644 --- a/null_safety/calculate_lix/pubspec.yaml +++ b/null_safety/calculate_lix/pubspec.yaml @@ -6,7 +6,7 @@ version: 1.3.0 publish_to: none environment: - sdk: ^3.5.0 + sdk: ^3.7.0 dependencies: collection: ^1.19.0 diff --git a/package_constraint_solver/example/example.dart b/package_constraint_solver/example/example.dart index cedaae6..5593e2d 100644 --- a/package_constraint_solver/example/example.dart +++ b/package_constraint_solver/example/example.dart @@ -12,11 +12,7 @@ void main() { var meals = ['artichoke', 'bananas', 'broccoli']; - var domains = { - doug: meals, - patrick: meals, - susan: meals, - }; + var domains = {doug: meals, patrick: meals, susan: meals}; var csp = CSP(variables, domains); @@ -30,10 +26,7 @@ class Guest { final String name; final List dislikes; - Guest( - this.name, { - this.dislikes = const [], - }); + Guest(this.name, {this.dislikes = const []}); @override String toString() { diff --git a/package_constraint_solver/example/scheduler_example.dart b/package_constraint_solver/example/scheduler_example.dart index bb1b297..851ccf9 100644 --- a/package_constraint_solver/example/scheduler_example.dart +++ b/package_constraint_solver/example/scheduler_example.dart @@ -17,14 +17,8 @@ void main() { ]; final timeSlots = [ - TimeSlot( - DateTime(2023, 2, 14, 8), - DateTime(2023, 2, 14, 9), - ), - TimeSlot( - DateTime(2023, 2, 14, 11), - DateTime(2023, 2, 14, 12), - ), + TimeSlot(DateTime(2023, 2, 14, 8), DateTime(2023, 2, 14, 9)), + TimeSlot(DateTime(2023, 2, 14, 11), DateTime(2023, 2, 14, 12)), ]; final scheduledTasks = scheduleTasks(tasks, timeSlots); @@ -115,8 +109,9 @@ class TaskConstraint extends Constraint { // Create a map containing the remaining time for each time slot Map remainingTime = {}; for (var timeSlot in assignment.values) { - remainingTime[timeSlot] = - Duration(milliseconds: timeSlot.duration.inMilliseconds); + remainingTime[timeSlot] = Duration( + milliseconds: timeSlot.duration.inMilliseconds, + ); } // Check that each task fits in the available time slot. diff --git a/package_constraint_solver/lib/constraint_solver.dart b/package_constraint_solver/lib/constraint_solver.dart index 3d33f9d..706faba 100644 --- a/package_constraint_solver/lib/constraint_solver.dart +++ b/package_constraint_solver/lib/constraint_solver.dart @@ -55,7 +55,8 @@ class CSP { // Check that each variable is present in the domains map if (!domains.containsKey(variable)) { throw ArgumentError( - 'Each variable should have a domain associated with it.'); + 'Each variable should have a domain associated with it.', + ); } } } @@ -66,7 +67,8 @@ class CSP { // Check that this constraint's variable is present in this CSP if (!variables.contains(variable)) { throw ArgumentError( - "The constraint's variable is not present in this CSP"); + "The constraint's variable is not present in this CSP", + ); } // Add the constraint to the `constraints` map. As long as the previous diff --git a/package_constraint_solver/pubspec.yaml b/package_constraint_solver/pubspec.yaml index 0b5a432..64198a1 100644 --- a/package_constraint_solver/pubspec.yaml +++ b/package_constraint_solver/pubspec.yaml @@ -4,7 +4,7 @@ repository: https://github.com/dart-lang/samples/tree/main/package_constraint_so publish_to: none environment: - sdk: ^3.5.0 + sdk: ^3.7.0 dependencies: path: ^1.9.0 diff --git a/package_constraint_solver/test/constraint_solver_test.dart b/package_constraint_solver/test/constraint_solver_test.dart index bab0033..7a5c4f2 100644 --- a/package_constraint_solver/test/constraint_solver_test.dart +++ b/package_constraint_solver/test/constraint_solver_test.dart @@ -10,10 +10,7 @@ class Guest { final String name; final List dislikes; - Guest( - this.name, { - this.dislikes = const [], - }); + Guest(this.name, {this.dislikes = const []}); @override String toString() { @@ -48,32 +45,15 @@ class AvoidDislikes extends Constraint { void main() { group('constraint satisfaction framework', () { test('Satisfies constraints', () { - var doug = Guest( - 'Doug', - dislikes: ['artichoke'], - ); - var patrick = Guest( - 'Patrick', - dislikes: ['bananas'], - ); - var susan = Guest( - 'Susan', - dislikes: ['broccoli'], - ); + var doug = Guest('Doug', dislikes: ['artichoke']); + var patrick = Guest('Patrick', dislikes: ['bananas']); + var susan = Guest('Susan', dislikes: ['broccoli']); var variables = [doug, patrick, susan]; - var meals = [ - 'artichoke', - 'bananas', - 'broccoli', - ]; - - var domains = { - doug: meals, - patrick: meals, - susan: meals, - }; + var meals = ['artichoke', 'bananas', 'broccoli']; + + var domains = {doug: meals, patrick: meals, susan: meals}; var csp = CSP(variables, domains); csp.addConstraint(AvoidDislikes(variables)); diff --git a/parameters/lib/super_initalizer.dart b/parameters/lib/super_initalizer.dart index 2bf45ce..e8d3416 100644 --- a/parameters/lib/super_initalizer.dart +++ b/parameters/lib/super_initalizer.dart @@ -27,11 +27,7 @@ class Synth { /// In the class constructor [model] is a positional parameter, /// while [polyphony] and [oscillators] are named parameters. - Synth( - this.model, { - required this.polyphony, - this.oscillators = 1, - }); + Synth(this.model, {required this.polyphony, this.oscillators = 1}); @override String toString() { @@ -73,14 +69,8 @@ class MultiOscillatorSynth extends Synth { /// [model] is forwarded to the super constructor. /// [polyphony] and [oscillators] positional parameters are then passed to the /// named parameters in the super constructor. - MultiOscillatorSynth( - super.model, - int polyphony, - int oscillators, - ) : super( - polyphony: polyphony, - oscillators: oscillators, - ); + MultiOscillatorSynth(super.model, int polyphony, int oscillators) + : super(polyphony: polyphony, oscillators: oscillators); } /// This class represents a synth with a fixed amount @@ -90,9 +80,5 @@ class MultiOscillatorSynth extends Synth { class FixedOscillatorSynth extends Synth { /// [model] is forwarded to the super constructor. /// [polyphony] and [oscillators] are hardcoded. - FixedOscillatorSynth(super.model) - : super( - polyphony: 1, - oscillators: 3, - ); + FixedOscillatorSynth(super.model) : super(polyphony: 1, oscillators: 3); } diff --git a/parameters/pubspec.yaml b/parameters/pubspec.yaml index db1dd7c..1a1e3ed 100644 --- a/parameters/pubspec.yaml +++ b/parameters/pubspec.yaml @@ -5,7 +5,7 @@ version: 1.0.0 publish_to: none environment: - sdk: ^3.5.0 + sdk: ^3.7.0 dev_dependencies: lints: ^5.0.0 diff --git a/parameters/test/named_parameters_test.dart b/parameters/test/named_parameters_test.dart index 1716ce1..3a3cab5 100644 --- a/parameters/test/named_parameters_test.dart +++ b/parameters/test/named_parameters_test.dart @@ -42,13 +42,9 @@ void main() { // positional argument `predicate` appears between // named arguments `items` and `skip` - final total = countWhere( - items: list, - (item) { - return item % 2 == 0; - }, - skip: 1, - ); + final total = countWhere(items: list, (item) { + return item % 2 == 0; + }, skip: 1); expect(total, 2); }); diff --git a/server/google_apis/bin/server.dart b/server/google_apis/bin/server.dart index fb1e776..15a7cc0 100644 --- a/server/google_apis/bin/server.dart +++ b/server/google_apis/bin/server.dart @@ -29,9 +29,7 @@ Future main() async { return Response.ok( JsonUtf8Encoder(' ').convert(result), - headers: { - 'content-type': 'application/json', - }, + headers: {'content-type': 'application/json'}, ); } @@ -44,18 +42,18 @@ Future main() async { } CommitRequest _incrementRequest(String projectId) => CommitRequest( - writes: [ - Write( - transform: DocumentTransform( - document: - 'projects/$projectId/databases/(default)/documents/settings/count', - fieldTransforms: [ - FieldTransform( - fieldPath: 'count', - increment: Value(integerValue: '1'), - ) - ], + writes: [ + Write( + transform: DocumentTransform( + document: + 'projects/$projectId/databases/(default)/documents/settings/count', + fieldTransforms: [ + FieldTransform( + fieldPath: 'count', + increment: Value(integerValue: '1'), ), - ), - ], - ); + ], + ), + ), + ], +); diff --git a/server/google_apis/pubspec.yaml b/server/google_apis/pubspec.yaml index 363508e..a244220 100644 --- a/server/google_apis/pubspec.yaml +++ b/server/google_apis/pubspec.yaml @@ -2,7 +2,7 @@ name: cloud_run_google_apis publish_to: none # not intended for publication to pub.dev environment: - sdk: ^3.5.0 + sdk: ^3.7.0 dependencies: google_cloud: ^0.2.0 diff --git a/server/simple/analysis_options.yaml b/server/simple/analysis_options.yaml index a478cad..a4f5a52 100644 --- a/server/simple/analysis_options.yaml +++ b/server/simple/analysis_options.yaml @@ -4,4 +4,3 @@ linter: rules: - prefer_const_constructors - prefer_expression_function_bodies - - require_trailing_commas diff --git a/server/simple/bin/server.dart b/server/simple/bin/server.dart index cf1b9f0..8faaca4 100644 --- a/server/simple/bin/server.dart +++ b/server/simple/bin/server.dart @@ -26,8 +26,8 @@ Future main() async { final server = await shelf_io.serve( // See https://pub.dev/documentation/shelf/latest/shelf/logRequests.html logRequests() - // See https://pub.dev/documentation/shelf/latest/shelf/MiddlewareExtensions/addHandler.html - .addHandler(cascade.handler), + // See https://pub.dev/documentation/shelf/latest/shelf/MiddlewareExtensions/addHandler.html + .addHandler(cascade.handler), InternetAddress.anyIPv4, // Allows external connections port, ); @@ -39,27 +39,28 @@ Future main() async { } // Serve files from the file system. -final _staticHandler = - shelf_static.createStaticHandler('public', defaultDocument: 'index.html'); +final _staticHandler = shelf_static.createStaticHandler( + 'public', + defaultDocument: 'index.html', +); // Router instance to handler requests. -final _router = shelf_router.Router() - ..get('/helloworld', _helloWorldHandler) - ..get( - '/time', - (request) => Response.ok(DateTime.now().toUtc().toIso8601String()), - ) - ..get('/info.json', _infoHandler) - ..get('/sum//', _sumHandler); +final _router = + shelf_router.Router() + ..get('/helloworld', _helloWorldHandler) + ..get( + '/time', + (request) => Response.ok(DateTime.now().toUtc().toIso8601String()), + ) + ..get('/info.json', _infoHandler) + ..get('/sum//', _sumHandler); Response _helloWorldHandler(Request request) => Response.ok('Hello, World!'); String _jsonEncode(Object? data) => const JsonEncoder.withIndent(' ').convert(data); -const _jsonHeaders = { - 'content-type': 'application/json', -}; +const _jsonHeaders = {'content-type': 'application/json'}; Response _sumHandler(Request request, String a, String b) { final aNum = int.parse(a); @@ -83,16 +84,11 @@ final _dartVersion = () { }(); Response _infoHandler(Request request) => Response( - 200, - headers: { - ..._jsonHeaders, - 'Cache-Control': 'no-store', - }, - body: _jsonEncode( - { - 'Dart version': _dartVersion, - 'uptime': _watch.elapsed.toString(), - 'requestCount': ++_requestCount, - }, - ), - ); + 200, + headers: {..._jsonHeaders, 'Cache-Control': 'no-store'}, + body: _jsonEncode({ + 'Dart version': _dartVersion, + 'uptime': _watch.elapsed.toString(), + 'requestCount': ++_requestCount, + }), +); diff --git a/server/simple/pubspec.yaml b/server/simple/pubspec.yaml index 3b62bb6..a19af0e 100644 --- a/server/simple/pubspec.yaml +++ b/server/simple/pubspec.yaml @@ -2,7 +2,7 @@ name: container_server_example publish_to: none # not intended for publication to pub.dev environment: - sdk: ^3.5.0 + sdk: ^3.7.0 dependencies: shelf: ^1.4.2 diff --git a/server/simple/test/docker_test.dart b/server/simple/test/docker_test.dart index ec7e295..cd4aec8 100644 --- a/server/simple/test/docker_test.dart +++ b/server/simple/test/docker_test.dart @@ -11,13 +11,9 @@ import 'test_definitions.dart'; void main() { void testServer(String name, Future Function(String host) func) { - test( - name, - () async { - await func('http://localhost:8080'); - }, - timeout: _defaultTimeout, - ); + test(name, () async { + await func('http://localhost:8080'); + }, timeout: _defaultTimeout); } runTests(testServer); diff --git a/server/simple/test/server_test.dart b/server/simple/test/server_test.dart index f6dbe60..3208aff 100644 --- a/server/simple/test/server_test.dart +++ b/server/simple/test/server_test.dart @@ -24,14 +24,10 @@ void main() { }); void testServer(String name, Future Function(String host) func) { - test( - name, - () async { - await func('http://localhost:$port'); - await proc.kill(); - }, - timeout: _defaultTimeout, - ); + test(name, () async { + await func('http://localhost:$port'); + await proc.kill(); + }, timeout: _defaultTimeout); } runTests(testServer);