Skip to content

Commit

Permalink
refactor: migrate to Dart 3 and Flutter 3.10 (#981)
Browse files Browse the repository at this point in the history
  • Loading branch information
ookami-kb authored May 27, 2023
1 parent a6e713e commit 5a19763
Show file tree
Hide file tree
Showing 397 changed files with 1,395 additions and 1,291 deletions.
4 changes: 4 additions & 0 deletions .fvm/fvm_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"flutterSdkVersion": "3.10.2",
"flavors": {}
}
7 changes: 3 additions & 4 deletions .github/workflows/check_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ concurrency:
cancel-in-progress: true

env:
FLUTTER_VERSION: "3.7.8"
DART_VERSION: "2.19.5"
FLUTTER_VERSION: "3.10.2"
DART_VERSION: "3.0.2"

jobs:
formatting:
Expand Down Expand Up @@ -67,7 +67,6 @@ jobs:
with:
sdk: ${{ env.DART_VERSION }}


- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
Expand Down Expand Up @@ -156,7 +155,7 @@ jobs:

- uses: subosito/flutter-action@v2
with:
flutter-version: "3.7.2"
flutter-version: ${{ env.FLUTTER_VERSION }}

- name: Activate utils
run: make activate_utils
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/e2e_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ concurrency:
cancel-in-progress: true

env:
FLUTTER_VERSION: '3.7.8'
FLUTTER_VERSION: "3.10.2"

jobs:
e2e:
Expand All @@ -26,7 +26,7 @@ jobs:
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: 'stable'
channel: "stable"
cache: true

- id: "auth"
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,5 @@ test-ledger
.packages~master

**/pubspec_overrides.yaml

.fvm/flutter_sdk
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ dart_get:

dart_analyze:
dart analyze --fatal-infos .
dart pub run mews_pedantic:metrics analyze --fatal-style --fatal-performance --fatal-warnings lib
dart pub run dart_code_metrics:metrics analyze --fatal-style --fatal-performance --fatal-warnings lib

dart_test:
dart test
Expand All @@ -46,11 +46,11 @@ flutter_generate_test_schemas:

flutter_analyze:
flutter analyze --fatal-infos
flutter pub run mews_pedantic:metrics analyze --fatal-style --fatal-performance --fatal-warnings lib
flutter pub run dart_code_metrics:metrics analyze --fatal-style --fatal-performance --fatal-warnings lib

flutter_check_unused_code:
flutter pub run mews_pedantic:metrics check-unused-code lib --fatal-unused --exclude=$(excludeUnused)
flutter pub run mews_pedantic:metrics check-unused-files lib --fatal-unused --exclude=$(excludeUnused)
flutter pub run dart_code_metrics:metrics check-unused-code lib --fatal-unused --exclude=$(excludeUnused)
flutter pub run dart_code_metrics:metrics check-unused-files lib --fatal-unused --exclude=$(excludeUnused)

flutter_test:
flutter test
Expand Down
2 changes: 1 addition & 1 deletion codemagic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ workflows:
groups:
- common
- google_credentials
flutter: 3.7.8
flutter: 3.10.2
xcode: 14.2
android_signing:
- app
Expand Down
4 changes: 4 additions & 0 deletions packages/borsh/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
include: package:mews_pedantic/analysis_options.yaml

analyzer:
plugins:
- dart_code_metrics
1 change: 0 additions & 1 deletion packages/borsh/lib/borsh.dart

This file was deleted.

6 changes: 4 additions & 2 deletions packages/borsh/lib/src/borsh_serializable_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import 'package:source_gen/source_gen.dart';

class BorshSerializableGenerator
extends GeneratorForAnnotation<BorshSerializable> {
const BorshSerializableGenerator();

@override
String generateForAnnotatedElement(
Element element,
Expand Down Expand Up @@ -81,13 +83,13 @@ Iterable<String> _generatePrivateClassFields(
Iterable<ParameterElement> parameters,
) sync* {
for (final p in parameters) {
yield 'final ${p.type.toString()} ${p.name};';
yield 'final ${p.type} ${p.name};';
}
}

Iterable<String> _generateFields(Iterable<ParameterElement> parameters) sync* {
for (final parameter in parameters) {
yield '${parameter.type.toString()} get ${parameter.name} => throw UnimplementedError();';
yield '${parameter.type} get ${parameter.name} => throw UnimplementedError();';
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/borsh/lib/src/builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import 'package:build/build.dart';
import 'package:source_gen/source_gen.dart';

Builder borsh(BuilderOptions _) =>
SharedPartBuilder([BorshSerializableGenerator()], 'borsh');
SharedPartBuilder([const BorshSerializableGenerator()], 'borsh');
3 changes: 2 additions & 1 deletion packages/borsh/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ dependencies:

dev_dependencies:
build_runner: ^2.0.6
mews_pedantic: ^0.13.0
dart_code_metrics: ^5.7.3
mews_pedantic: ^0.15.0-dev.0
test: ^1.17.10
10 changes: 5 additions & 5 deletions packages/borsh/test/structs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ class Test1 with _$Test1 {
@BFixedArray(3, BString()) required List<String> listOfStrings,
@BFixedArray(3, BU8()) required List<int> listOfInts,
@BFixedArray(3, BFixedArray(2, BU8()))
required List<List<int>> listOfListsOfInts,
required List<List<int>> listOfListsOfInts,
@BArray(BString()) required List<String> dynamicListOfStrings,
}) = _Test1;

Test1._();
const Test1._();

factory Test1.fromBorsh(Uint8List data) => _$Test1FromBorsh(data);
}
Expand All @@ -27,7 +27,7 @@ class SimpleStruct with _$SimpleStruct {
@BU8() required int intValue,
}) = _SimpleStruct;

SimpleStruct._();
const SimpleStruct._();

factory SimpleStruct.fromBorsh(Uint8List data) =>
_$SimpleStructFromBorsh(data);
Expand All @@ -40,7 +40,7 @@ class CompositeStruct with _$CompositeStruct {
@BSimpleStruct() required SimpleStruct simpleStruct,
}) = _CompositeStruct;

CompositeStruct._();
const CompositeStruct._();

factory CompositeStruct.fromBorsh(Uint8List data) =>
_$CompositeStructFromBorsh(data);
Expand All @@ -53,7 +53,7 @@ class StructWithOption with _$StructWithOption {
@BOption(BString()) required String? option,
}) = _StructWithOption;

StructWithOption._();
const StructWithOption._();

factory StructWithOption.fromBorsh(Uint8List data) =>
_$StructWithOptionFromBorsh(data);
Expand Down
4 changes: 4 additions & 0 deletions packages/borsh_annotation/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
include: package:mews_pedantic/analysis_options.yaml

analyzer:
plugins:
- dart_code_metrics
18 changes: 9 additions & 9 deletions packages/borsh_annotation/lib/src/binary_writer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ class BinaryWriter {
int length = 0;

void _maybeResize() {
if (buf.lengthInBytes < 16 + length) {
final list = Uint8List.fromList([
...buf.buffer.asUint8List(),
...Uint8List(_initialLength),
]);
buf = list.buffer.asByteData();
}
if (buf.lengthInBytes >= 16 + length) return;

final list = Uint8List.fromList([
...buf.buffer.asUint8List(),
...Uint8List(_initialLength),
]);
buf = list.buffer.asByteData();
}

void writeU8(int value) {
Expand Down Expand Up @@ -56,13 +56,13 @@ class BinaryWriter {
_writeBuffer(buffer);
}

void writeFixedArray<T>(Iterable<T> array, void Function(T) fn) {
void writeFixedArray<T>(Iterable<T> array, void Function(T item) fn) {
for (final item in array) {
fn(item);
}
}

void writeArray<T>(Iterable<T> array, void Function(T) fn) {
void writeArray<T>(Iterable<T> array, void Function(T item) fn) {
writeU32(array.length);
for (final item in array) {
fn(item);
Expand Down
3 changes: 2 additions & 1 deletion packages/borsh_annotation/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ environment:
sdk: ">=2.13.0 <3.0.0"

dev_dependencies:
mews_pedantic: ^0.13.0
dart_code_metrics: ^5.7.3
mews_pedantic: ^0.15.0-dev.0
3 changes: 3 additions & 0 deletions packages/espressocash_app/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ linter:
- prefer_relative_imports

analyzer:
plugins:
- dart_code_metrics

exclude:
- "**/*.mocks.dart"
- "**/*.gr.dart"
Expand Down
27 changes: 16 additions & 11 deletions packages/espressocash_app/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,13 @@ PODS:
- Ramp (~> 2.0.0)
- rive_common (0.0.1):
- Flutter
- Sentry/HybridSDK (7.31.5)
- Sentry/HybridSDK (8.7.2):
- SentryPrivate (= 8.7.2)
- sentry_flutter (0.0.1):
- Flutter
- FlutterMacOS
- Sentry/HybridSDK (= 7.31.5)
- Sentry/HybridSDK (= 8.7.2)
- SentryPrivate (8.7.2)
- share (0.0.1):
- Flutter
- shared_preferences_foundation (0.0.1):
Expand Down Expand Up @@ -219,20 +221,23 @@ DEPENDENCIES:
- mobile_scanner (from `.symlinks/plugins/mobile_scanner/ios`)
- package_info (from `.symlinks/plugins/package_info/ios`)
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- Ramp (from `https://github.com/RampNetwork/ramp-sdk-ios`, tag `2.0.0`)
- ramp_flutter (from `.symlinks/plugins/ramp_flutter/ios`)
- rive_common (from `.symlinks/plugins/rive_common/ios`)
- sentry_flutter (from `.symlinks/plugins/sentry_flutter/ios`)
- share (from `.symlinks/plugins/share/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- sqflite (from `.symlinks/plugins/sqflite/ios`)
- sqlite3_flutter_libs (from `.symlinks/plugins/sqlite3_flutter_libs/ios`)
- uni_links (from `.symlinks/plugins/uni_links/ios`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
- webview_flutter_wkwebview (from `.symlinks/plugins/webview_flutter_wkwebview/ios`)

SPEC REPOS:
https://github.com/CocoaPods/Specs.git:
- Sentry
- SentryPrivate
https://github.com/passbase/cocoapods-specs.git:
- Passbase
https://github.com/passbase/microblink-cocoapods-specs.git:
Expand Down Expand Up @@ -261,7 +266,6 @@ SPEC REPOS:
- nanopb
- PromisesObjC
- Protobuf
- Sentry
- sqlite3

EXTERNAL SOURCES:
Expand Down Expand Up @@ -292,7 +296,7 @@ EXTERNAL SOURCES:
package_info_plus:
:path: ".symlinks/plugins/package_info_plus/ios"
path_provider_foundation:
:path: ".symlinks/plugins/path_provider_foundation/ios"
:path: ".symlinks/plugins/path_provider_foundation/darwin"
Ramp:
:git: https://github.com/RampNetwork/ramp-sdk-ios
:tag: 2.0.0
Expand All @@ -305,7 +309,7 @@ EXTERNAL SOURCES:
share:
:path: ".symlinks/plugins/share/ios"
shared_preferences_foundation:
:path: ".symlinks/plugins/shared_preferences_foundation/ios"
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
sqflite:
:path: ".symlinks/plugins/sqflite/ios"
sqlite3_flutter_libs:
Expand Down Expand Up @@ -348,7 +352,7 @@ SPEC CHECKSUMS:
GoogleUtilitiesComponents: 679b2c881db3b615a2777504623df6122dd20afe
GTMSessionFetcher: 5595ec75acf5be50814f81e9189490412bad82ba
image_picker_ios: b786a5dcf033a8336a657191401bfdf12017dabb
integration_test: a1e7d09bd98eca2fc37aefd79d4f41ad37bdbbe5
integration_test: 13825b8a9334a850581300559b8839134b124670
Microblink: 9443ff3c708a97673e4999389626079e10a1bbc1
MLImage: 489dfec109f21da8621b28d476401aaf7a0d4ff4
MLKitBarcodeScanning: d92fe1911001ec36870162c5a0eb206f612b7169
Expand All @@ -357,16 +361,17 @@ SPEC CHECKSUMS:
mobile_scanner: 004f7ad2fe4e2b5a3e6ed0bc4b83ca9c5b5dd975
nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431
package_info: 873975fc26034f0b863a300ad47e7f1ac6c7ec62
package_info_plus: 6c92f08e1f853dc01228d6f553146438dafcd14e
package_info_plus: fd030dabf36271f146f1f3beacd48f564b0f17f7
Passbase: bce91be2e3be1b9c72ab42ee91c57a106095bd65
path_provider_foundation: 37748e03f12783f9de2cb2c4eadfaa25fe6d4852
PromisesObjC: ab77feca74fa2823e7af4249b8326368e61014cb
Protobuf: f4128517d7a42302e106cc3afe614ee3a7513e94
Ramp: c522303707480a458eef7d05c96e8c9604be4840
ramp_flutter: 2fed2262c7882b5b8285c1aaea4f36f2b93b00c1
rive_common: e35144d3b86972f8760b6c9f8b120dfd5fadfa13
Sentry: 4c9babff9034785067c896fd580b1f7de44da020
sentry_flutter: b10ae7a5ddcbc7f04648eeb2672b5747230172f1
Sentry: c43b6d1d51bf96edbaeac7772c4178aa54f4f450
sentry_flutter: 354c51276054f9f8a9b276967172aeb2e91d8a69
SentryPrivate: 760a9fd5d134c4d926c4c0afe9c4deceadbf4557
share: 0b2c3e82132f5888bccca3351c504d0003b3b410
shared_preferences_foundation: 297b3ebca31b34ec92be11acd7fb0ba932c822ca
sqflite: 6d358c025f5b867b29ed92fc697fd34924e11904
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@
files = (
);
inputPaths = (
"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
);
name = "Thin Binary";
outputPaths = (
Expand Down
8 changes: 7 additions & 1 deletion packages/espressocash_app/lib/app/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import '../routes.gr.dart';
import '../ui/theme.dart';

class CryptopleaseApp extends StatefulWidget {
const CryptopleaseApp({Key? key}) : super(key: key);
const CryptopleaseApp({super.key});

@override
State<CryptopleaseApp> createState() => _CryptopleaseAppState();
Expand All @@ -22,6 +22,12 @@ class CryptopleaseApp extends StatefulWidget {
class _CryptopleaseAppState extends State<CryptopleaseApp> {
final _router = AppRouter();

@override
void dispose() {
_router.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
final isLoading =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import '../../../../ui/app_bar.dart';
import '../../../../ui/tab_bar.dart';

class ActivitiesScreen extends StatelessWidget {
const ActivitiesScreen({Key? key}) : super(key: key);
const ActivitiesScreen({super.key});

@override
Widget build(BuildContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class HomeRouterKey {
}

class AuthenticatedFlowScreen extends StatefulWidget {
const AuthenticatedFlowScreen({Key? key}) : super(key: key);
const AuthenticatedFlowScreen({super.key});

@override
State<AuthenticatedFlowScreen> createState() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import '../../../ui/navigation_bar/navigation_bar.dart';
import '../../../ui/navigation_bar/navigation_button.dart';

class HomeScreen extends StatelessWidget {
const HomeScreen({Key? key}) : super(key: key);
const HomeScreen({super.key});

@override
Widget build(BuildContext context) => AutoTabsRouter(
Expand Down
Loading

0 comments on commit 5a19763

Please sign in to comment.