From 09303b3874a4e17c579775cc93d6562ba5066b81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Gabriel=20Bracaioli?= Date: Thu, 22 Jun 2023 10:27:42 -0300 Subject: [PATCH 1/5] Upgrade pipeline config to circleci --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 194cbb1..76db488 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,14 +2,14 @@ version: 2 job_defaults: &defaults docker: - - image: cirrusci/flutter:3.0.2 + - image: ghcr.io/cirruslabs/flutter:3.10.5 jobs: format-check: <<: *defaults steps: - checkout - - run: flutter format --dry-run --set-exit-if-changed . + - run: dart format -o none --set-exit-if-changed . analyze: <<: *defaults steps: From ad70aec3fa3aa997f202e4b0d8a8b498965ad717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Gabriel=20Bracaioli?= Date: Thu, 22 Jun 2023 10:29:26 -0300 Subject: [PATCH 2/5] Improve analysis with ignores until migration package next --- analysis_options.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 48d12fe..58035e0 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -36,6 +36,12 @@ analyzer: # Stream and not importing dart:async # Please see https://github.com/flutter/flutter/pull/24528 for details. sdk_version_async_exported_from_core: ignore + # Review lints ignore after migrating all to package next + constant_identifier_names: ignore + use_build_context_synchronously: ignore + library_private_types_in_public_api: ignore + inference_failure_on_function_invocation: ignore + use_key_in_widget_constructors: ignore exclude: - monocli - lib/**/*.g.dart @@ -108,7 +114,7 @@ linter: - library_prefixes # - lines_longer_than_80_chars # not yet tested - list_remove_unrelated_type - - library_private_types_in_public_api + # - library_private_types_in_public_api # - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/sdk/issues/34181 - no_adjacent_strings_in_list - no_duplicate_case_values From 625ca067e7b66722c8e9f2e63cc89deea15b6559 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Gabriel=20Bracaioli?= Date: Thu, 22 Jun 2023 10:32:00 -0300 Subject: [PATCH 3/5] Apply simple code improvements --- example/lib/main.dart | 4 ++- .../lib/samples/modules/composer/module.dart | 2 +- .../screens/text_composer_screen.dart | 4 +-- .../screens/success_screen.dart | 4 +-- example/lib/samples/router.dart | 4 +-- example/lib/samples/screens/home_screen.dart | 25 +++++++++---------- lib/src/nu_router.dart | 4 +-- lib/src/nuvigator.dart | 8 +++--- test/deeplink_test.dart | 2 +- 9 files changed, 29 insertions(+), 28 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 2081ffa..c82db3d 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -5,7 +5,7 @@ import 'samples/bloc/samples_bloc.dart'; import 'samples/modules/friend_request/bloc/friend_request_bloc.dart'; import 'samples/router.dart'; -void main() => runApp(MyApp()); +void main() => runApp(const MyApp()); class TestObserver extends NavigatorObserver { @override @@ -30,6 +30,8 @@ class TestObserver extends NavigatorObserver { } class MyApp extends StatelessWidget { + const MyApp({super.key}); + @override Widget build(BuildContext context) { return MaterialApp( diff --git a/example/lib/samples/modules/composer/module.dart b/example/lib/samples/modules/composer/module.dart index 08e0afb..65a66cd 100644 --- a/example/lib/samples/modules/composer/module.dart +++ b/example/lib/samples/modules/composer/module.dart @@ -32,7 +32,7 @@ class _ComposerHelpRoute extends NuRoute { @override Widget build(BuildContext context, NuRouteSettings settings) { - return HelpScreen(); + return const HelpScreen(); } } diff --git a/example/lib/samples/modules/composer/screens/text_composer_screen.dart b/example/lib/samples/modules/composer/screens/text_composer_screen.dart index e672b0e..52031cc 100644 --- a/example/lib/samples/modules/composer/screens/text_composer_screen.dart +++ b/example/lib/samples/modules/composer/screens/text_composer_screen.dart @@ -9,7 +9,7 @@ class TextComposerScreen extends StatefulWidget { }); final String? initialText; - final Function(String) submitText; + final Function submitText; final VoidCallback toHelp; @override @@ -55,7 +55,7 @@ class _TextComposerScreenState extends State { minLines: 5, maxLines: null, ), - RaisedButton( + ElevatedButton( onPressed: () => widget.submitText(_controller.text), child: const Text('Publish'), ), diff --git a/example/lib/samples/modules/friend_request/screens/success_screen.dart b/example/lib/samples/modules/friend_request/screens/success_screen.dart index 9027bc4..e90d182 100644 --- a/example/lib/samples/modules/friend_request/screens/success_screen.dart +++ b/example/lib/samples/modules/friend_request/screens/success_screen.dart @@ -40,11 +40,11 @@ class SuccessScreen extends StatelessWidget { textAlign: TextAlign.center, ), const SizedBox(height: 48), - RaisedButton( + ElevatedButton( onPressed: closeFlow, child: const Text('Close flow'), ), - RaisedButton( + ElevatedButton( onPressed: toComposeText, child: const Text('Compose a message'), ), diff --git a/example/lib/samples/router.dart b/example/lib/samples/router.dart index 930923a..40f8355 100644 --- a/example/lib/samples/router.dart +++ b/example/lib/samples/router.dart @@ -97,14 +97,14 @@ class MainAppRouter extends NuRouter { bool? isFromNative, dynamic args, ]) async { - print('DeepLink not found ${uri.toString()}'); + debugPrint('DeepLink not found ${uri.toString()}'); }; @override List get registerRoutes => [ NuRouteBuilder( path: 'home', - builder: (_, __, ___) => HomeScreen(), + builder: (_, __, ___) => const HomeScreen(), screenType: ScreenTypeBuilder( (WidgetBuilder builder, RouteSettings settings) => CupertinoPageRoute( diff --git a/example/lib/samples/screens/home_screen.dart b/example/lib/samples/screens/home_screen.dart index c0f1124..d131b49 100644 --- a/example/lib/samples/screens/home_screen.dart +++ b/example/lib/samples/screens/home_screen.dart @@ -2,9 +2,11 @@ import 'package:flutter/material.dart'; import 'package:nuvigator/nuvigator.dart'; class HomeScreen extends StatelessWidget { + const HomeScreen({super.key}); + @override Widget build(BuildContext context) { - print('BUILDING HOME'); + debugPrint('BUILDING HOME'); final nuvigator = Nuvigator.of(context); final headingStle = Theme.of(context).textTheme.headline3; @@ -30,7 +32,7 @@ class HomeScreen extends StatelessWidget { textAlign: TextAlign.center, ), const SizedBox(height: 48), - RaisedButton( + ElevatedButton( onPressed: () { // final r = NuRouter.of(context); // r.toListRequests(); @@ -40,7 +42,7 @@ class HomeScreen extends StatelessWidget { }, child: const Text('Review friend requests'), ), - RaisedButton( + ElevatedButton( onPressed: () async { String? text; @@ -49,16 +51,13 @@ class HomeScreen extends StatelessWidget { screenType: cupertinoDialogScreenType, ); - if (text != null) { - // ignore: unawaited_futures - showDialog( - context: context, - builder: (context) => AlertDialog( - title: const Text('Composed message'), - content: Text(text ?? ''), - ), - ); - } + showDialog( + context: context, + builder: (context) => AlertDialog( + title: const Text('Composed message'), + content: Text(text ?? ''), + ), + ); }, child: const Text('Compose a message'), ), diff --git a/lib/src/nu_router.dart b/lib/src/nu_router.dart index 9efed27..ae832ff 100644 --- a/lib/src/nu_router.dart +++ b/lib/src/nu_router.dart @@ -240,7 +240,7 @@ abstract class NuRouter implements INuRouter { final nuRouterInitResult = init(context); if (awaitForInit) { await nuRouterInitResult; - } else if (!(nuRouterInitResult is SynchronousFuture)) { + } else if (nuRouterInitResult is! SynchronousFuture) { throw FlutterError( '$this NuRouter initialization do not support Asynchronous initializations,' ' but the return type of init() is not a SynchronousFuture. Make ' @@ -254,7 +254,7 @@ abstract class NuRouter implements INuRouter { final routeInitResult = route.init(context); if (awaitForInit) { await routeInitResult; - } else if (!(routeInitResult is SynchronousFuture)) { + } else if (routeInitResult is! SynchronousFuture) { throw FlutterError( '$this NuRouter initialization do not support Asynchronous initializations,' ' but the Route $route return type of init() is not a SynchronousFuture.' diff --git a/lib/src/nuvigator.dart b/lib/src/nuvigator.dart index edbe6ca..874dd0c 100644 --- a/lib/src/nuvigator.dart +++ b/lib/src/nuvigator.dart @@ -25,26 +25,26 @@ class NuvigatorStateTracker extends NavigatorObserver { @override void didPush(Route route, Route? previousRoute) { stack.add(route); - if (debug) print('didPush $route: $stackRouteNames'); + if (debug) debugPrint('didPush $route: $stackRouteNames'); } @override void didPop(Route route, Route? previousRoute) { stack.remove(route); - if (debug) print('didPop $route: $stackRouteNames'); + if (debug) debugPrint('didPop $route: $stackRouteNames'); } @override void didRemove(Route route, Route? previousRoute) { stack.remove(route); - if (debug) print('didRemove $route: $stackRouteNames'); + if (debug) debugPrint('didRemove $route: $stackRouteNames'); } @override void didReplace({Route? newRoute, Route? oldRoute}) { final index = stack.indexOf(oldRoute); stack[index] = newRoute; - if (debug) print('didReplace $oldRoute to $newRoute: $stackRouteNames'); + if (debug) debugPrint('didReplace $oldRoute to $newRoute: $stackRouteNames'); } } diff --git a/test/deeplink_test.dart b/test/deeplink_test.dart index ba49844..03fb5fe 100644 --- a/test/deeplink_test.dart +++ b/test/deeplink_test.dart @@ -14,7 +14,7 @@ void main() { test('on getting empty path param', () { final result = parser.getPathParams('my-route?another-one=hello'); - expect(result, {}); + expect(result, {}); }); test('on getting the query params', () { From 70742162e1e85d472c6f88dd360d820eda0f55d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Gabriel=20Bracaioli?= Date: Thu, 22 Jun 2023 10:43:06 -0300 Subject: [PATCH 4/5] Apply format --- lib/src/nuvigator.dart | 3 ++- test/deeplink_test.dart | 2 +- test/nuvigator_test.dart | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/src/nuvigator.dart b/lib/src/nuvigator.dart index 874dd0c..e034d1d 100644 --- a/lib/src/nuvigator.dart +++ b/lib/src/nuvigator.dart @@ -44,7 +44,8 @@ class NuvigatorStateTracker extends NavigatorObserver { void didReplace({Route? newRoute, Route? oldRoute}) { final index = stack.indexOf(oldRoute); stack[index] = newRoute; - if (debug) debugPrint('didReplace $oldRoute to $newRoute: $stackRouteNames'); + if (debug) + debugPrint('didReplace $oldRoute to $newRoute: $stackRouteNames'); } } diff --git a/test/deeplink_test.dart b/test/deeplink_test.dart index 03fb5fe..8d063ee 100644 --- a/test/deeplink_test.dart +++ b/test/deeplink_test.dart @@ -14,7 +14,7 @@ void main() { test('on getting empty path param', () { final result = parser.getPathParams('my-route?another-one=hello'); - expect(result, {}); + expect(result, {}); }); test('on getting the query params', () { diff --git a/test/nuvigator_test.dart b/test/nuvigator_test.dart index 5ccc809..12b0a8b 100644 --- a/test/nuvigator_test.dart +++ b/test/nuvigator_test.dart @@ -4,7 +4,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:nuvigator/next.dart'; - Widget baseNuvigator( Key key, Key nestedKey, From f7225909bc0e23e8898fe6e4e589ec26920406b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Gabriel=20Bracaioli?= Date: Thu, 22 Jun 2023 10:45:42 -0300 Subject: [PATCH 5/5] Apply fix analyze --- lib/src/nuvigator.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/src/nuvigator.dart b/lib/src/nuvigator.dart index e034d1d..ababbf1 100644 --- a/lib/src/nuvigator.dart +++ b/lib/src/nuvigator.dart @@ -44,8 +44,9 @@ class NuvigatorStateTracker extends NavigatorObserver { void didReplace({Route? newRoute, Route? oldRoute}) { final index = stack.indexOf(oldRoute); stack[index] = newRoute; - if (debug) + if (debug) { debugPrint('didReplace $oldRoute to $newRoute: $stackRouteNames'); + } } }