Skip to content

Commit

Permalink
Merge pull request #662 from Flutterando/fix_test
Browse files Browse the repository at this point in the history
Fix test
  • Loading branch information
jacobaraujo7 authored Feb 21, 2022
2 parents 02e146f + d029e6e commit 269ed03
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 16 deletions.
8 changes: 5 additions & 3 deletions flutter_modular/example/lib/app/app_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ class AppWidget extends StatelessWidget {

@override
Widget build(BuildContext context) {
return MaterialApp(
navigatorKey: alice.getNavigatorKey(),
Modular.routerDelegate.setNavigatorKey(alice.getNavigatorKey());
return MaterialApp.router(
title: 'Flutter Slidy',
theme: ThemeData(
primarySwatch: Colors.blue,
),
).modular();
routerDelegate: Modular.routerDelegate,
routeInformationParser: Modular.routeInformationParser,
);
}
}
5 changes: 2 additions & 3 deletions flutter_modular/lib/flutter_modular.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import 'src/domain/usecases/get_arguments.dart';
import 'src/presenter/models/modular_navigator.dart';
import 'src/presenter/modular_base.dart';
import 'src/presenter/navigation/modular_page.dart';
import 'src/presenter/navigation/modular_route_information_parser.dart';
import 'src/presenter/navigation/modular_router_delegate.dart';
import 'src/presenter/navigation/router_outlet_delegate.dart';

Expand Down Expand Up @@ -65,7 +64,7 @@ extension ModularExtensionMaterial on MaterialApp {
///...
///);
///```
@deprecated
@Deprecated('Use **MaterialApp.router** instead')
MaterialApp modular() {
injector
.get<IModularNavigator>()
Expand Down Expand Up @@ -120,7 +119,7 @@ extension ModularExtensionCupertino on CupertinoApp {
///...
///);
///```
@deprecated
@Deprecated('Use CupertinoApp.router instead')
CupertinoApp modular() {
injector
.get<IModularNavigator>()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'dart:async';

import 'package:flutter/material.dart';

import 'package:modular_core/modular_core.dart';

import '../../../flutter_modular.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ void main() {
when(() => key.currentState).thenReturn(navigatorState);
parser = ModularRouteInformationParserMock();
delegate = ModularRouterDelegate(
parser: parser, navigatorKey: key, reportPop: reportPopMock);
parser: parser,
navigatorKey: key,
reportPop: reportPopMock,
);
});

test('setObserver', () {
Expand Down
12 changes: 8 additions & 4 deletions modular_codegen/lib/src/custom_annotation_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@ import 'package:analyzer/dart/element/element.dart';
import 'package:build/build.dart';
import 'package:source_gen/source_gen.dart';

abstract class CustomGeneratorForAnnotatedField<AnnotationType> extends Generator {
abstract class CustomGeneratorForAnnotatedField<AnnotationType>
extends Generator {
/// Returns the annotation of type [AnnotationType] of the given [element],
/// or [null] if it doesn't have any.
DartObject? getAnnotation(Element element) {
final annotations = TypeChecker.fromRuntime(AnnotationType).annotationsOf(element);
final annotations =
TypeChecker.fromRuntime(AnnotationType).annotationsOf(element);
if (annotations.isEmpty) {
return null;
}
if (annotations.length > 1) {
throw Exception("You tried to add multiple @$AnnotationType() annotations to the "
throw Exception(
"You tried to add multiple @$AnnotationType() annotations to the "
"same element (${element.name}), but that's not possible.");
}
return annotations.single;
Expand All @@ -39,5 +42,6 @@ abstract class CustomGeneratorForAnnotatedField<AnnotationType> extends Generato
return values.join('/n/n');
}

String generateForAnnotatedField(FieldElement field, ConstantReader annotation);
String generateForAnnotatedField(
FieldElement field, ConstantReader annotation);
}
2 changes: 1 addition & 1 deletion modular_codegen/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: modular_codegen
description: Code Generate for flutter_modular. Inject Automation. Annotation @Inject, @Param and @Data.
version: 3.0.3
version: 3.0.4
homepage: https://github.com/Flutterando/modular

environment:
Expand Down
2 changes: 2 additions & 0 deletions modular_core/lib/src/route/tracker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ class TrackerImpl implements Tracker {
params[name] = result.namedGroup(name)!;
}
return params;
} else {
return null;
}
}

Expand Down
3 changes: 2 additions & 1 deletion modular_interfaces/lib/src/di/bind.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ abstract class BindContract<T extends Object> {
this.export = false,
this.isScoped = false,
this.alwaysSerialized = false,
}) : assert((isSingleton || isLazy), r"'singleton' can't be false if 'lazy' is also false");
}) : assert((isSingleton || isLazy),
r"'singleton' can't be false if 'lazy' is also false");
}

/// For empty instance binds.
Expand Down
6 changes: 4 additions & 2 deletions modular_test/lib/modular_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ library modular_test;

import 'package:modular_core/modular_core.dart';

void initModule(BindContext module, {List<BindContract> replaceBinds = const []}) {
void initModule(BindContext module,
{List<BindContract> replaceBinds = const []}) {
// ignore: invalid_use_of_visible_for_testing_member
final bindModules = module.getProcessBinds();

Expand All @@ -18,7 +19,8 @@ void initModule(BindContext module, {List<BindContract> replaceBinds = const []}
ModularTracker.injector.addBindContext(module);
}

void initModules(List<BindContext> modules, {List<BindContract> replaceBinds = const []}) {
void initModules(List<BindContext> modules,
{List<BindContract> replaceBinds = const []}) {
for (var module in modules) {
initModule(module, replaceBinds: replaceBinds);
}
Expand Down
2 changes: 2 additions & 0 deletions shelf_modular/lib/src/presenter/utils/handlers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,7 @@ FutureOr<Response>? applyHandler(Function fn,
return fn(injector, arguments, request);
} else if (fn is HandlerThreeParams5) {
return fn(injector, request, arguments);
} else {
return null;
}
}

0 comments on commit 269ed03

Please sign in to comment.