Skip to content

Commit

Permalink
Merge pull request #109 from nubank/fix_analysis_and_pipeline
Browse files Browse the repository at this point in the history
Fix analysis and pipeline
  • Loading branch information
obraca authored Jun 23, 2023
2 parents b182429 + f722590 commit e62e0ec
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 32 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 7 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,6 +30,8 @@ class TestObserver extends NavigatorObserver {
}

class MyApp extends StatelessWidget {
const MyApp({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
Expand Down
2 changes: 1 addition & 1 deletion example/lib/samples/modules/composer/module.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class _ComposerHelpRoute extends NuRoute {

@override
Widget build(BuildContext context, NuRouteSettings<void> settings) {
return HelpScreen();
return const HelpScreen();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class TextComposerScreen extends StatefulWidget {
});

final String? initialText;
final Function(String) submitText;
final Function submitText;
final VoidCallback toHelp;

@override
Expand Down Expand Up @@ -55,7 +55,7 @@ class _TextComposerScreenState extends State<TextComposerScreen> {
minLines: 5,
maxLines: null,
),
RaisedButton(
ElevatedButton(
onPressed: () => widget.submitText(_controller.text),
child: const Text('Publish'),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
),
Expand Down
4 changes: 2 additions & 2 deletions example/lib/samples/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<NuRoute> get registerRoutes => [
NuRouteBuilder(
path: 'home',
builder: (_, __, ___) => HomeScreen(),
builder: (_, __, ___) => const HomeScreen(),
screenType: ScreenTypeBuilder(
(WidgetBuilder builder, RouteSettings settings) =>
CupertinoPageRoute(
Expand Down
25 changes: 12 additions & 13 deletions example/lib/samples/screens/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -30,7 +32,7 @@ class HomeScreen extends StatelessWidget {
textAlign: TextAlign.center,
),
const SizedBox(height: 48),
RaisedButton(
ElevatedButton(
onPressed: () {
// final r = NuRouter.of<OldFriendRequestRouter>(context);
// r.toListRequests();
Expand All @@ -40,7 +42,7 @@ class HomeScreen extends StatelessWidget {
},
child: const Text('Review friend requests'),
),
RaisedButton(
ElevatedButton(
onPressed: () async {
String? text;

Expand All @@ -49,16 +51,13 @@ class HomeScreen extends StatelessWidget {
screenType: cupertinoDialogScreenType,
);

if (text != null) {
// ignore: unawaited_futures
showDialog<void>(
context: context,
builder: (context) => AlertDialog(
title: const Text('Composed message'),
content: Text(text ?? ''),
),
);
}
showDialog<void>(
context: context,
builder: (context) => AlertDialog(
title: const Text('Composed message'),
content: Text(text ?? ''),
),
);
},
child: const Text('Compose a message'),
),
Expand Down
4 changes: 2 additions & 2 deletions lib/src/nu_router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 '
Expand All @@ -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.'
Expand Down
10 changes: 6 additions & 4 deletions lib/src/nuvigator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,28 @@ class NuvigatorStateTracker extends NavigatorObserver {
@override
void didPush(Route<dynamic> route, Route<dynamic>? previousRoute) {
stack.add(route);
if (debug) print('didPush $route: $stackRouteNames');
if (debug) debugPrint('didPush $route: $stackRouteNames');
}

@override
void didPop(Route<dynamic> route, Route<dynamic>? previousRoute) {
stack.remove(route);
if (debug) print('didPop $route: $stackRouteNames');
if (debug) debugPrint('didPop $route: $stackRouteNames');
}

@override
void didRemove(Route<dynamic> route, Route<dynamic>? previousRoute) {
stack.remove(route);
if (debug) print('didRemove $route: $stackRouteNames');
if (debug) debugPrint('didRemove $route: $stackRouteNames');
}

@override
void didReplace({Route<dynamic>? newRoute, Route<dynamic>? 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');
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/deeplink_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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, <String, String>{});
});

test('on getting the query params', () {
Expand Down
1 change: 0 additions & 1 deletion test/nuvigator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit e62e0ec

Please sign in to comment.