From 5bd1c0c9a0761e0da62b20add0da39f258f3cac1 Mon Sep 17 00:00:00 2001 From: Luis Roseno Date: Fri, 16 Apr 2021 06:31:51 -0300 Subject: [PATCH 1/8] Updated dependencies --- pubspec.lock | 332 ++++++++++++++++++++++++++++++--------------------- pubspec.yaml | 30 ++--- 2 files changed, 209 insertions(+), 153 deletions(-) diff --git a/pubspec.lock b/pubspec.lock index 08830a5..6295047 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,21 +7,14 @@ packages: name: _fe_analyzer_shared url: "https://pub.dartlang.org" source: hosted - version: "1.0.3" + version: "20.0.0" analyzer: dependency: transitive description: name: analyzer url: "https://pub.dartlang.org" source: hosted - version: "0.39.4" - archive: - dependency: transitive - description: - name: archive - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.11" + version: "1.4.0" args: dependency: transitive description: @@ -35,189 +28,224 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.0" + version: "2.5.0" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "2.1.0" build: dependency: transitive description: name: build url: "https://pub.dartlang.org" source: hosted - version: "1.2.2" + version: "2.0.0" build_config: dependency: transitive description: name: build_config url: "https://pub.dartlang.org" source: hosted - version: "0.4.1+1" + version: "0.4.7" build_daemon: dependency: transitive description: name: build_daemon url: "https://pub.dartlang.org" source: hosted - version: "2.1.3" + version: "2.1.10" build_resolvers: dependency: transitive description: name: build_resolvers url: "https://pub.dartlang.org" source: hosted - version: "1.3.2" + version: "2.0.0" build_runner: dependency: "direct dev" description: name: build_runner url: "https://pub.dartlang.org" source: hosted - version: "1.7.3" + version: "1.12.2" build_runner_core: dependency: transitive description: name: build_runner_core url: "https://pub.dartlang.org" source: hosted - version: "4.3.0" + version: "6.1.12" built_collection: dependency: transitive description: name: built_collection url: "https://pub.dartlang.org" source: hosted - version: "4.3.2" + version: "5.0.0" built_value: dependency: transitive description: name: built_value url: "https://pub.dartlang.org" source: hosted - version: "7.0.8" + version: "8.0.4" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" + version: "1.2.0" checked_yaml: dependency: transitive description: name: checked_yaml url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" + version: "2.0.1" + cli_util: + dependency: transitive + description: + name: cli_util + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.0" + clock: + dependency: transitive + description: + name: clock + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" code_builder: dependency: transitive description: name: code_builder url: "https://pub.dartlang.org" source: hosted - version: "3.2.1" + version: "3.7.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.11" + version: "1.15.0" convert: dependency: transitive description: name: convert url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "3.0.0" crypto: dependency: transitive description: name: crypto url: "https://pub.dartlang.org" source: hosted - version: "2.1.3" - csslib: + version: "3.0.1" + dart_style: dependency: transitive description: - name: csslib + name: dart_style url: "https://pub.dartlang.org" source: hosted - version: "0.16.1" - dart_style: + version: "2.0.0" + dartz: dependency: transitive description: - name: dart_style + name: dartz url: "https://pub.dartlang.org" source: hosted - version: "1.3.3" + version: "0.10.0-nullsafety.1" dio: dependency: "direct main" description: name: dio url: "https://pub.dartlang.org" source: hosted - version: "3.0.8" - firebase: + version: "4.0.0" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + ffi: + dependency: transitive + description: + name: ffi + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" + file: dependency: transitive description: - name: firebase + name: file url: "https://pub.dartlang.org" source: hosted - version: "7.2.1" + version: "6.1.0" firebase_auth: dependency: "direct main" description: name: firebase_auth url: "https://pub.dartlang.org" source: hosted - version: "0.15.4" + version: "1.1.0" firebase_auth_platform_interface: dependency: transitive description: name: firebase_auth_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.1.5" + version: "4.1.0" firebase_auth_web: dependency: transitive description: name: firebase_auth_web url: "https://pub.dartlang.org" source: hosted - version: "0.1.2" + version: "1.0.6" firebase_core: dependency: transitive description: name: firebase_core url: "https://pub.dartlang.org" source: hosted - version: "0.4.3+3" + version: "1.0.3" firebase_core_platform_interface: dependency: transitive description: name: firebase_core_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" + version: "4.0.0" firebase_core_web: dependency: transitive description: name: firebase_core_web url: "https://pub.dartlang.org" source: hosted - version: "0.1.1+2" + version: "1.0.2" fixnum: dependency: transitive description: name: fixnum url: "https://pub.dartlang.org" source: hosted - version: "0.10.11" + version: "1.0.0" flutter: dependency: "direct main" description: flutter @@ -229,14 +257,21 @@ packages: name: flutter_mobx url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "2.0.0" flutter_modular: dependency: "direct main" description: - path: "C:\\Users\\jacob\\FlutterProjects\\modular" - relative: false - source: path - version: "0.4.2" + name: flutter_modular + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.0" + flutter_modular_annotations: + dependency: transitive + description: + name: flutter_modular_annotations + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.2" flutter_test: dependency: "direct dev" description: flutter @@ -253,56 +288,42 @@ packages: name: glob url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "2.0.1" google_sign_in: dependency: "direct main" description: name: google_sign_in url: "https://pub.dartlang.org" source: hosted - version: "4.1.1" + version: "5.0.2" google_sign_in_platform_interface: dependency: transitive description: name: google_sign_in_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.3" + version: "2.0.1" google_sign_in_web: dependency: transitive description: name: google_sign_in_web url: "https://pub.dartlang.org" source: hosted - version: "0.8.3" + version: "0.10.0" graphs: dependency: transitive description: name: graphs url: "https://pub.dartlang.org" source: hosted - version: "0.2.0" + version: "1.0.0" hive: dependency: "direct main" description: name: hive url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" - html: - dependency: transitive - description: - name: html - url: "https://pub.dartlang.org" - source: hosted - version: "0.14.0+3" - http: - dependency: transitive - description: - name: http - url: "https://pub.dartlang.org" - source: hosted - version: "0.12.0+4" + version: "2.0.3" http_multi_server: dependency: transitive description: @@ -316,14 +337,14 @@ packages: name: http_parser url: "https://pub.dartlang.org" source: hosted - version: "3.1.3" - image: + version: "4.0.0" + intl: dependency: transitive description: - name: image + name: intl url: "https://pub.dartlang.org" source: hosted - version: "2.1.4" + version: "0.17.0" io: dependency: transitive description: @@ -337,35 +358,35 @@ packages: name: js url: "https://pub.dartlang.org" source: hosted - version: "0.6.1+1" + version: "0.6.3" json_annotation: dependency: transitive description: name: json_annotation url: "https://pub.dartlang.org" source: hosted - version: "3.0.1" + version: "4.0.1" logging: dependency: transitive description: name: logging url: "https://pub.dartlang.org" source: hosted - version: "0.11.4" + version: "1.0.1" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.6" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.8" + version: "1.3.0" mime: dependency: transitive description: @@ -379,161 +400,182 @@ packages: name: mobx url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "2.0.1" mobx_codegen: dependency: "direct dev" description: name: mobx_codegen url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "2.0.1+3" mockito: dependency: "direct dev" description: name: mockito url: "https://pub.dartlang.org" source: hosted - version: "4.1.1" - node_interop: + version: "5.0.4" + package_config: dependency: transitive description: - name: node_interop + name: package_config url: "https://pub.dartlang.org" source: hosted - version: "1.0.3" - node_io: + version: "2.0.0" + path: dependency: transitive description: - name: node_io + name: path url: "https://pub.dartlang.org" source: hosted - version: "1.0.1+2" - package_config: - dependency: transitive + version: "1.8.0" + path_provider: + dependency: "direct main" description: - name: package_config + name: path_provider url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" - package_resolver: + version: "2.0.1" + path_provider_linux: dependency: transitive description: - name: package_resolver + name: path_provider_linux url: "https://pub.dartlang.org" source: hosted - version: "1.0.10" - path: + version: "2.0.0" + path_provider_macos: dependency: transitive description: - name: path + name: path_provider_macos url: "https://pub.dartlang.org" source: hosted - version: "1.6.4" - path_provider: - dependency: "direct main" + version: "2.0.0" + path_provider_platform_interface: + dependency: transitive description: - name: path_provider + name: path_provider_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.6.0" - pedantic: + version: "2.0.1" + path_provider_windows: dependency: transitive description: - name: pedantic + name: path_provider_windows url: "https://pub.dartlang.org" source: hosted - version: "1.8.0+1" - petitparser: + version: "2.0.0" + pedantic: dependency: transitive description: - name: petitparser + name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "2.4.0" + version: "1.11.0" platform: dependency: transitive description: name: platform url: "https://pub.dartlang.org" source: hosted - version: "2.2.1" - pointycastle: + version: "3.0.0" + plugin_platform_interface: dependency: transitive description: - name: pointycastle + name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" + version: "2.0.0" pool: dependency: transitive description: name: pool url: "https://pub.dartlang.org" source: hosted - version: "1.4.0" + version: "1.5.0" + process: + dependency: transitive + description: + name: process + url: "https://pub.dartlang.org" + source: hosted + version: "4.2.1" pub_semver: dependency: transitive description: name: pub_semver url: "https://pub.dartlang.org" source: hosted - version: "1.4.2" + version: "2.0.0" pubspec_parse: dependency: transitive description: name: pubspec_parse url: "https://pub.dartlang.org" source: hosted - version: "0.1.5" + version: "1.0.0" quiver: dependency: transitive description: name: quiver url: "https://pub.dartlang.org" source: hosted - version: "2.0.5" + version: "3.0.1" shared_preferences: dependency: "direct main" description: name: shared_preferences url: "https://pub.dartlang.org" source: hosted - version: "0.5.6+1" + version: "2.0.5" + shared_preferences_linux: + dependency: transitive + description: + name: shared_preferences_linux + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" shared_preferences_macos: dependency: transitive description: name: shared_preferences_macos url: "https://pub.dartlang.org" source: hosted - version: "0.0.1+4" + version: "2.0.0" shared_preferences_platform_interface: dependency: transitive description: name: shared_preferences_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "2.0.0" shared_preferences_web: dependency: transitive description: name: shared_preferences_web url: "https://pub.dartlang.org" source: hosted - version: "0.1.2+3" + version: "2.0.0" + shared_preferences_windows: + dependency: transitive + description: + name: shared_preferences_windows + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" shelf: dependency: transitive description: name: shelf url: "https://pub.dartlang.org" source: hosted - version: "0.7.5" + version: "1.1.0" shelf_web_socket: dependency: transitive description: name: shelf_web_socket url: "https://pub.dartlang.org" source: hosted - version: "0.2.3" + version: "1.0.1" sky_engine: dependency: transitive description: flutter @@ -545,105 +587,119 @@ packages: name: source_gen url: "https://pub.dartlang.org" source: hosted - version: "0.9.4+7" + version: "1.0.0" source_span: dependency: transitive description: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.5.5" + version: "1.8.0" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" stream_transform: dependency: transitive description: name: stream_transform url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "2.0.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.11" + version: "0.2.19" timing: dependency: transitive description: name: timing url: "https://pub.dartlang.org" source: hosted - version: "0.1.1+2" + version: "1.0.0" + triple: + dependency: transitive + description: + name: triple + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.1.0" watcher: dependency: transitive description: name: watcher url: "https://pub.dartlang.org" source: hosted - version: "0.9.7+13" + version: "1.0.0" web_socket_channel: dependency: transitive description: name: web_socket_channel url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" - xml: + version: "2.0.0" + win32: dependency: transitive description: - name: xml + name: win32 url: "https://pub.dartlang.org" source: hosted - version: "3.5.0" + version: "2.0.5" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.0" yaml: dependency: transitive description: name: yaml url: "https://pub.dartlang.org" source: hosted - version: "2.2.0" + version: "3.1.0" sdks: - dart: ">=2.7.0 <3.0.0" - flutter: ">=1.12.13+hotfix.4 <2.0.0" + dart: ">=2.12.0 <3.0.0" + flutter: ">=1.20.0" diff --git a/pubspec.yaml b/pubspec.yaml index 4af9c09..6eff2e4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,22 +11,21 @@ description: A new Flutter project. # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.0.0+1 +version: 1.0.0+2 environment: sdk: ">=2.1.0 <3.0.0" dependencies: - shared_preferences: ^0.5.6+1 - google_sign_in: ^4.1.1 - path_provider: ^1.6.0 - hive: ^1.3.0 - dio: ^3.0.8 - flutter_mobx: ^1.0.1 - mobx: ^1.0.0 - firebase_auth: ^0.15.4 - flutter_modular: - path: C:\Users\jacob\FlutterProjects\modular + shared_preferences: ^2.0.5 + firebase_auth: ^1.1.0 + google_sign_in: ^5.0.2 + path_provider: ^2.0.1 + hive: ^2.0.3 + dio: ^4.0.0 + flutter_mobx: ^2.0.0 + mobx: ^2.0.1 + flutter_modular: any flutter: sdk: flutter @@ -34,9 +33,9 @@ dependencies: # Use with the CupertinoIcons class for iOS style icons. dev_dependencies: - mockito: ^4.1.1 - mobx_codegen: ^1.0.1 - build_runner: ^1.7.3 + mockito: ^5.0.2 + build_runner: ^1.12.2 + mobx_codegen: ^2.0.1+2 flutter_test: sdk: flutter @@ -83,4 +82,5 @@ flutter: # For details regarding fonts from package dependencies, # see https://flutter.dev/custom-fonts/#from-packages scripts: - mobx: flutter pub run build_runner watch --delete-conflicting-outputs \ No newline at end of file + mobb: flutter pub get & flutter pub run build_runner build --delete-conflicting-outputs + mobx: flutter pub get & flutter pub run build_runner watch --delete-conflicting-outputs \ No newline at end of file From 7cb0603eafa0a07ded7802792adea31a3ceab3b7 Mon Sep 17 00:00:00 2001 From: Luis Roseno Date: Fri, 16 Apr 2021 07:02:32 -0300 Subject: [PATCH 2/8] Migrate flutter_modular 2 to 3 --- lib/app/app_module.dart | 15 +++++---------- lib/app/app_widget.dart | 4 +--- .../modules/home/components/item/item_widget.dart | 2 +- lib/app/modules/home/home_controller.dart | 5 ++--- lib/app/modules/home/home_module.dart | 8 +++----- lib/app/modules/home/home_page.dart | 2 +- lib/app/modules/login/login_module.dart | 8 +++----- lib/main.dart | 8 +++++++- 8 files changed, 23 insertions(+), 29 deletions(-) diff --git a/lib/app/app_module.dart b/lib/app/app_module.dart index c52b7ec..c5b6cba 100644 --- a/lib/app/app_module.dart +++ b/lib/app/app_module.dart @@ -13,7 +13,7 @@ import 'modules/login/login_module.dart'; import 'shared/auth/repositories/auth_repository_interface.dart'; import 'splash/splash_page.dart'; -class AppModule extends MainModule { +class AppModule extends Module { @override List get binds => [ Bind((i) => AppController()), @@ -24,15 +24,10 @@ class AppModule extends MainModule { ]; @override - List get routers => [ - Router('/', child: (_, args) => SplashPage()), - Router('/login', + List get routers => [ + ChildRoute('/', child: (_, args) => SplashPage()), + ModuleRoute('/login', module: LoginModule(), transition: TransitionType.noTransition), - Router('/home', module: HomeModule()), + ModuleRoute('/home', module: HomeModule()), ]; - - @override - Widget get bootstrap => AppWidget(); - - static Inject get to => Inject.of(); } diff --git a/lib/app/app_widget.dart b/lib/app/app_widget.dart index db021e5..4185b72 100644 --- a/lib/app/app_widget.dart +++ b/lib/app/app_widget.dart @@ -6,13 +6,11 @@ class AppWidget extends StatelessWidget { Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, - navigatorKey: Modular.navigatorKey, title: 'Flutter Slidy', theme: ThemeData( primarySwatch: Colors.blue, ), initialRoute: '/', - onGenerateRoute: Modular.generateRoute, - ); + ).modular(); } } diff --git a/lib/app/modules/home/components/item/item_widget.dart b/lib/app/modules/home/components/item/item_widget.dart index 74aa1ff..be34bef 100644 --- a/lib/app/modules/home/components/item/item_widget.dart +++ b/lib/app/modules/home/components/item/item_widget.dart @@ -8,7 +8,7 @@ class ItemWidget extends StatelessWidget { final HomeController controller = Modular.get(); - ItemWidget({Key key, this.index}) : super(key: key); + ItemWidget({Key? key, required this.index}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/app/modules/home/home_controller.dart b/lib/app/modules/home/home_controller.dart index 6a711ea..22d0a66 100644 --- a/lib/app/modules/home/home_controller.dart +++ b/lib/app/modules/home/home_controller.dart @@ -22,9 +22,8 @@ abstract class _HomeBase with Store { _HomeBase() { init(); textController.addListener(() { - disableAdd = textController.text == null || - textController.text.isEmpty || - textController.text.length < 3; + disableAdd = + textController.text.isEmpty || textController.text.length < 3; }); } diff --git a/lib/app/modules/home/home_module.dart b/lib/app/modules/home/home_module.dart index c7de973..edf06ee 100644 --- a/lib/app/modules/home/home_module.dart +++ b/lib/app/modules/home/home_module.dart @@ -4,7 +4,7 @@ import 'package:login/app/modules/home/home_page.dart'; import 'package:login/app/shared/repositories/localstorage/local_storage_interface.dart'; import 'package:login/app/shared/repositories/localstorage/local_storage_share.dart'; -class HomeModule extends ChildModule { +class HomeModule extends Module { @override List get binds => [ Bind((i) { @@ -13,9 +13,7 @@ class HomeModule extends ChildModule { ]; @override - List get routers => [ - Router('/', child: (_, args) => HomePage()), + List get routers => [ + ChildRoute('/', child: (_, args) => HomePage()), ]; - - static Inject get to => Inject.of(); } diff --git a/lib/app/modules/home/home_page.dart b/lib/app/modules/home/home_page.dart index d8a5dcd..39c86b0 100644 --- a/lib/app/modules/home/home_page.dart +++ b/lib/app/modules/home/home_page.dart @@ -7,7 +7,7 @@ import 'home_controller.dart'; class HomePage extends StatefulWidget { final String title; - const HomePage({Key key, this.title = "Home"}) : super(key: key); + const HomePage({Key? key, this.title = "Home"}) : super(key: key); @override _HomePageState createState() => _HomePageState(); diff --git a/lib/app/modules/login/login_module.dart b/lib/app/modules/login/login_module.dart index 2bcc393..caa3689 100644 --- a/lib/app/modules/login/login_module.dart +++ b/lib/app/modules/login/login_module.dart @@ -3,16 +3,14 @@ import 'package:flutter_modular/flutter_modular.dart'; import 'login_controller.dart'; -class LoginModule extends ChildModule { +class LoginModule extends Module { @override List get binds => [ Bind((i) => LoginController()), ]; @override - List get routers => [ - Router('/', child: (_, args) => LoginPage()), + List get routers => [ + ChildRoute('/', child: (_, args) => LoginPage(title: "Login")), ]; - - static Inject get to => Inject.of(); } diff --git a/lib/main.dart b/lib/main.dart index e6ff8b8..4802741 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -2,4 +2,10 @@ import 'package:flutter/material.dart'; import 'package:login/app/app_module.dart'; import 'package:flutter_modular/flutter_modular.dart'; -void main() => runApp(ModularApp(module: AppModule())); +void main() async { + WidgetsFlutterBinding.ensureInitialized(); + runApp(ModularApp( + module: AppModule(), + child: AppWidget(), + )); +} From 2add9d6727f6832c7eb218f231d2174dcf53e3fb Mon Sep 17 00:00:00 2001 From: Luis Roseno Date: Fri, 16 Apr 2021 07:23:02 -0300 Subject: [PATCH 3/8] Null Safety migration & newer firebase_auth version & initial support to web --- lib/app/modules/login/login_page.dart | 2 +- lib/app/shared/auth/auth_controller.dart | 6 +-- .../auth/repositories/auth_repository.dart | 41 ++++++++++++------- .../auth_repository_interface.dart | 4 +- .../localstorage/local_storage_hive.dart | 11 +++-- .../localstorage/local_storage_mock.dart | 2 +- .../localstorage/local_storage_share.dart | 3 +- lib/app/splash/splash_page.dart | 4 +- lib/main.dart | 2 + 9 files changed, 48 insertions(+), 27 deletions(-) diff --git a/lib/app/modules/login/login_page.dart b/lib/app/modules/login/login_page.dart index c30ff5d..9eb43fc 100644 --- a/lib/app/modules/login/login_page.dart +++ b/lib/app/modules/login/login_page.dart @@ -5,7 +5,7 @@ import 'login_controller.dart'; class LoginPage extends StatefulWidget { final String title; - const LoginPage({Key key, this.title = "Login"}) : super(key: key); + const LoginPage({Key? key, this.title = "Login"}) : super(key: key); @override _LoginPageState createState() => _LoginPageState(); diff --git a/lib/app/shared/auth/auth_controller.dart b/lib/app/shared/auth/auth_controller.dart index d34b97d..9aa2c86 100644 --- a/lib/app/shared/auth/auth_controller.dart +++ b/lib/app/shared/auth/auth_controller.dart @@ -13,17 +13,17 @@ abstract class _AuthControllerBase with Store { AuthStatus status = AuthStatus.loading; @observable - FirebaseUser user; + User? user; @action - setUser(FirebaseUser value) { + setUser(User? value) { user = value; status = user == null ? AuthStatus.logoff : AuthStatus.login; } _AuthControllerBase() { _authRepository.getUser().then(setUser).catchError((e) { - print('ERRORRRRRR'); + print('ERROR: $e'); }); } diff --git a/lib/app/shared/auth/repositories/auth_repository.dart b/lib/app/shared/auth/repositories/auth_repository.dart index 6301378..5432793 100644 --- a/lib/app/shared/auth/repositories/auth_repository.dart +++ b/lib/app/shared/auth/repositories/auth_repository.dart @@ -1,5 +1,6 @@ import 'package:firebase_auth/firebase_auth.dart'; import 'package:google_sign_in/google_sign_in.dart'; +import 'package:flutter/foundation.dart' show kIsWeb; import 'auth_repository_interface.dart'; @@ -26,24 +27,36 @@ class AuthRepository implements IAuthRepository { } @override - Future getGoogleLogin() async { - final GoogleSignInAccount googleUser = await _googleSignIn.signIn(); - final GoogleSignInAuthentication googleAuth = - await googleUser.authentication; - - final AuthCredential credential = GoogleAuthProvider.getCredential( - accessToken: googleAuth.accessToken, - idToken: googleAuth.idToken, - ); - - final FirebaseUser user = - (await _auth.signInWithCredential(credential)).user; + Future getGoogleLogin() async { + late final user; + try { + UserCredential userCredential; + + if (kIsWeb) { + GoogleAuthProvider googleProvider = GoogleAuthProvider(); + userCredential = await _auth.signInWithPopup(googleProvider); + } else { + final GoogleSignInAccount googleUser = (await _googleSignIn.signIn())!; + final GoogleSignInAuthentication googleAuth = + await googleUser.authentication; + + final AuthCredential credential = GoogleAuthProvider.credential( + accessToken: googleAuth.accessToken, + idToken: googleAuth.idToken, + ); + + userCredential = await _auth.signInWithCredential(credential); + } + user = userCredential.user; + } catch (e) { + print(e); + } return user; } @override - Future getUser() { - return _auth.currentUser(); + Future getUser() async { + return _auth.currentUser; } @override diff --git a/lib/app/shared/auth/repositories/auth_repository_interface.dart b/lib/app/shared/auth/repositories/auth_repository_interface.dart index 3b89793..25d727e 100644 --- a/lib/app/shared/auth/repositories/auth_repository_interface.dart +++ b/lib/app/shared/auth/repositories/auth_repository_interface.dart @@ -1,8 +1,8 @@ import 'package:firebase_auth/firebase_auth.dart'; abstract class IAuthRepository { - Future getUser(); - Future getGoogleLogin(); + Future getUser(); + Future getGoogleLogin(); Future getFacebookLogin(); Future getEmailPasswordLogin(); Future getToken(); diff --git a/lib/app/shared/repositories/localstorage/local_storage_hive.dart b/lib/app/shared/repositories/localstorage/local_storage_hive.dart index f4c270c..0cb569c 100644 --- a/lib/app/shared/repositories/localstorage/local_storage_hive.dart +++ b/lib/app/shared/repositories/localstorage/local_storage_hive.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:hive/hive.dart'; import 'package:path_provider/path_provider.dart'; +import 'package:flutter/foundation.dart' show kIsWeb; import 'local_storage_interface.dart'; @@ -9,8 +10,11 @@ class LocalStorageHive implements ILocalStorage { Completer _instance = Completer(); _init() async { - var dir = await getApplicationDocumentsDirectory(); - Hive.init(dir.path); + if (!kIsWeb) { + var dir = await getApplicationDocumentsDirectory(); + Hive.init(dir.path); + } + var box = await Hive.openBox('db'); _instance.complete(box); } @@ -28,7 +32,8 @@ class LocalStorageHive implements ILocalStorage { @override Future> get(String key) async { var box = await _instance.future; - return box.get(key); + List defaultValue = []; + return box.get(key, defaultValue: defaultValue); } @override diff --git a/lib/app/shared/repositories/localstorage/local_storage_mock.dart b/lib/app/shared/repositories/localstorage/local_storage_mock.dart index 47dd6d4..8c5e1da 100644 --- a/lib/app/shared/repositories/localstorage/local_storage_mock.dart +++ b/lib/app/shared/repositories/localstorage/local_storage_mock.dart @@ -4,7 +4,7 @@ class LocalStorageMock implements ILocalStorage { List storage = []; @override - Future delete(String key) { + Future delete(String key) async { return null; } diff --git a/lib/app/shared/repositories/localstorage/local_storage_share.dart b/lib/app/shared/repositories/localstorage/local_storage_share.dart index b3a8c37..7291823 100644 --- a/lib/app/shared/repositories/localstorage/local_storage_share.dart +++ b/lib/app/shared/repositories/localstorage/local_storage_share.dart @@ -24,7 +24,8 @@ class LocalStorageShared implements ILocalStorage { @override Future> get(String key) async { var shared = await _instance.future; - return shared.getStringList(key); + List list = shared.getStringList(key) ?? []; + return list; } @override diff --git a/lib/app/splash/splash_page.dart b/lib/app/splash/splash_page.dart index d7f974d..74b1e87 100644 --- a/lib/app/splash/splash_page.dart +++ b/lib/app/splash/splash_page.dart @@ -5,14 +5,14 @@ import 'package:mobx/mobx.dart'; class SplashPage extends StatefulWidget { final String title; - const SplashPage({Key key, this.title = "Splash"}) : super(key: key); + const SplashPage({Key? key, this.title = "Splash"}) : super(key: key); @override _SplashPageState createState() => _SplashPageState(); } class _SplashPageState extends State { - ReactionDisposer disposer; + late ReactionDisposer disposer; @override void initState() { diff --git a/lib/main.dart b/lib/main.dart index 4802741..414f301 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -2,6 +2,8 @@ import 'package:flutter/material.dart'; import 'package:login/app/app_module.dart'; import 'package:flutter_modular/flutter_modular.dart'; +import 'app/app_widget.dart'; + void main() async { WidgetsFlutterBinding.ensureInitialized(); runApp(ModularApp( From cd3709e1097e014b4029b2ecb92634fb450ed6d4 Mon Sep 17 00:00:00 2001 From: Luis Roseno Date: Fri, 16 Apr 2021 07:37:59 -0300 Subject: [PATCH 4/8] Regenerated build_runner files --- lib/app/app_controller.g.dart | 20 ++++++---- lib/app/modules/home/home_controller.g.dart | 34 ++++++++++------- lib/app/modules/login/login_controller.g.dart | 20 ++++++---- lib/app/shared/auth/auth_controller.g.dart | 38 +++++++++++-------- 4 files changed, 68 insertions(+), 44 deletions(-) diff --git a/lib/app/app_controller.g.dart b/lib/app/app_controller.g.dart index dcb48f4..60372f5 100644 --- a/lib/app/app_controller.g.dart +++ b/lib/app/app_controller.g.dart @@ -6,35 +6,41 @@ part of 'app_controller.dart'; // StoreGenerator // ************************************************************************** -// ignore_for_file: non_constant_identifier_names, unnecessary_lambdas, prefer_expression_function_bodies, lines_longer_than_80_chars, avoid_as, avoid_annotating_with_dynamic +// ignore_for_file: non_constant_identifier_names, unnecessary_brace_in_string_interps, unnecessary_lambdas, prefer_expression_function_bodies, lines_longer_than_80_chars, avoid_as, avoid_annotating_with_dynamic mixin _$AppController on _AppBase, Store { final _$valueAtom = Atom(name: '_AppBase.value'); @override int get value { - _$valueAtom.context.enforceReadPolicy(_$valueAtom); - _$valueAtom.reportObserved(); + _$valueAtom.reportRead(); return super.value; } @override set value(int value) { - _$valueAtom.context.conditionallyRunInAction(() { + _$valueAtom.reportWrite(value, super.value, () { super.value = value; - _$valueAtom.reportChanged(); - }, _$valueAtom, name: '${_$valueAtom.name}_set'); + }); } final _$_AppBaseActionController = ActionController(name: '_AppBase'); @override void increment() { - final _$actionInfo = _$_AppBaseActionController.startAction(); + final _$actionInfo = + _$_AppBaseActionController.startAction(name: '_AppBase.increment'); try { return super.increment(); } finally { _$_AppBaseActionController.endAction(_$actionInfo); } } + + @override + String toString() { + return ''' +value: ${value} + '''; + } } diff --git a/lib/app/modules/home/home_controller.g.dart b/lib/app/modules/home/home_controller.g.dart index 1cb9ad3..4d47b5b 100644 --- a/lib/app/modules/home/home_controller.g.dart +++ b/lib/app/modules/home/home_controller.g.dart @@ -6,44 +6,40 @@ part of 'home_controller.dart'; // StoreGenerator // ************************************************************************** -// ignore_for_file: non_constant_identifier_names, unnecessary_lambdas, prefer_expression_function_bodies, lines_longer_than_80_chars, avoid_as, avoid_annotating_with_dynamic +// ignore_for_file: non_constant_identifier_names, unnecessary_brace_in_string_interps, unnecessary_lambdas, prefer_expression_function_bodies, lines_longer_than_80_chars, avoid_as, avoid_annotating_with_dynamic mixin _$HomeController on _HomeBase, Store { final _$disableAddAtom = Atom(name: '_HomeBase.disableAdd'); @override bool get disableAdd { - _$disableAddAtom.context.enforceReadPolicy(_$disableAddAtom); - _$disableAddAtom.reportObserved(); + _$disableAddAtom.reportRead(); return super.disableAdd; } @override set disableAdd(bool value) { - _$disableAddAtom.context.conditionallyRunInAction(() { + _$disableAddAtom.reportWrite(value, super.disableAdd, () { super.disableAdd = value; - _$disableAddAtom.reportChanged(); - }, _$disableAddAtom, name: '${_$disableAddAtom.name}_set'); + }); } final _$listAtom = Atom(name: '_HomeBase.list'); @override ObservableList get list { - _$listAtom.context.enforceReadPolicy(_$listAtom); - _$listAtom.reportObserved(); + _$listAtom.reportRead(); return super.list; } @override set list(ObservableList value) { - _$listAtom.context.conditionallyRunInAction(() { + _$listAtom.reportWrite(value, super.list, () { super.list = value; - _$listAtom.reportChanged(); - }, _$listAtom, name: '${_$listAtom.name}_set'); + }); } - final _$initAsyncAction = AsyncAction('init'); + final _$initAsyncAction = AsyncAction('_HomeBase.init'); @override Future init() { @@ -54,7 +50,8 @@ mixin _$HomeController on _HomeBase, Store { @override void save() { - final _$actionInfo = _$_HomeBaseActionController.startAction(); + final _$actionInfo = + _$_HomeBaseActionController.startAction(name: '_HomeBase.save'); try { return super.save(); } finally { @@ -64,11 +61,20 @@ mixin _$HomeController on _HomeBase, Store { @override void remove(int index) { - final _$actionInfo = _$_HomeBaseActionController.startAction(); + final _$actionInfo = + _$_HomeBaseActionController.startAction(name: '_HomeBase.remove'); try { return super.remove(index); } finally { _$_HomeBaseActionController.endAction(_$actionInfo); } } + + @override + String toString() { + return ''' +disableAdd: ${disableAdd}, +list: ${list} + '''; + } } diff --git a/lib/app/modules/login/login_controller.g.dart b/lib/app/modules/login/login_controller.g.dart index 6783145..1bd269c 100644 --- a/lib/app/modules/login/login_controller.g.dart +++ b/lib/app/modules/login/login_controller.g.dart @@ -6,30 +6,36 @@ part of 'login_controller.dart'; // StoreGenerator // ************************************************************************** -// ignore_for_file: non_constant_identifier_names, unnecessary_lambdas, prefer_expression_function_bodies, lines_longer_than_80_chars, avoid_as, avoid_annotating_with_dynamic +// ignore_for_file: non_constant_identifier_names, unnecessary_brace_in_string_interps, unnecessary_lambdas, prefer_expression_function_bodies, lines_longer_than_80_chars, avoid_as, avoid_annotating_with_dynamic mixin _$LoginController on _LoginBase, Store { final _$loadingAtom = Atom(name: '_LoginBase.loading'); @override bool get loading { - _$loadingAtom.context.enforceReadPolicy(_$loadingAtom); - _$loadingAtom.reportObserved(); + _$loadingAtom.reportRead(); return super.loading; } @override set loading(bool value) { - _$loadingAtom.context.conditionallyRunInAction(() { + _$loadingAtom.reportWrite(value, super.loading, () { super.loading = value; - _$loadingAtom.reportChanged(); - }, _$loadingAtom, name: '${_$loadingAtom.name}_set'); + }); } - final _$loginWithGoogleAsyncAction = AsyncAction('loginWithGoogle'); + final _$loginWithGoogleAsyncAction = + AsyncAction('_LoginBase.loginWithGoogle'); @override Future loginWithGoogle() { return _$loginWithGoogleAsyncAction.run(() => super.loginWithGoogle()); } + + @override + String toString() { + return ''' +loading: ${loading} + '''; + } } diff --git a/lib/app/shared/auth/auth_controller.g.dart b/lib/app/shared/auth/auth_controller.g.dart index 1cb941d..e16918b 100644 --- a/lib/app/shared/auth/auth_controller.g.dart +++ b/lib/app/shared/auth/auth_controller.g.dart @@ -6,44 +6,41 @@ part of 'auth_controller.dart'; // StoreGenerator // ************************************************************************** -// ignore_for_file: non_constant_identifier_names, unnecessary_lambdas, prefer_expression_function_bodies, lines_longer_than_80_chars, avoid_as, avoid_annotating_with_dynamic +// ignore_for_file: non_constant_identifier_names, unnecessary_brace_in_string_interps, unnecessary_lambdas, prefer_expression_function_bodies, lines_longer_than_80_chars, avoid_as, avoid_annotating_with_dynamic mixin _$AuthController on _AuthControllerBase, Store { final _$statusAtom = Atom(name: '_AuthControllerBase.status'); @override AuthStatus get status { - _$statusAtom.context.enforceReadPolicy(_$statusAtom); - _$statusAtom.reportObserved(); + _$statusAtom.reportRead(); return super.status; } @override set status(AuthStatus value) { - _$statusAtom.context.conditionallyRunInAction(() { + _$statusAtom.reportWrite(value, super.status, () { super.status = value; - _$statusAtom.reportChanged(); - }, _$statusAtom, name: '${_$statusAtom.name}_set'); + }); } final _$userAtom = Atom(name: '_AuthControllerBase.user'); @override - FirebaseUser get user { - _$userAtom.context.enforceReadPolicy(_$userAtom); - _$userAtom.reportObserved(); + User? get user { + _$userAtom.reportRead(); return super.user; } @override - set user(FirebaseUser value) { - _$userAtom.context.conditionallyRunInAction(() { + set user(User? value) { + _$userAtom.reportWrite(value, super.user, () { super.user = value; - _$userAtom.reportChanged(); - }, _$userAtom, name: '${_$userAtom.name}_set'); + }); } - final _$loginWithGoogleAsyncAction = AsyncAction('loginWithGoogle'); + final _$loginWithGoogleAsyncAction = + AsyncAction('_AuthControllerBase.loginWithGoogle'); @override Future loginWithGoogle() { @@ -54,12 +51,21 @@ mixin _$AuthController on _AuthControllerBase, Store { ActionController(name: '_AuthControllerBase'); @override - dynamic setUser(FirebaseUser value) { - final _$actionInfo = _$_AuthControllerBaseActionController.startAction(); + dynamic setUser(User? value) { + final _$actionInfo = _$_AuthControllerBaseActionController.startAction( + name: '_AuthControllerBase.setUser'); try { return super.setUser(value); } finally { _$_AuthControllerBaseActionController.endAction(_$actionInfo); } } + + @override + String toString() { + return ''' +status: ${status}, +user: ${user} + '''; + } } From 2782d0db4bcc223b59bbd18775c6636cca14640b Mon Sep 17 00:00:00 2001 From: Luis Roseno Date: Fri, 16 Apr 2021 07:40:11 -0300 Subject: [PATCH 5/8] Updated SDK Version and http_multi_server to fix build_runner problem --- pubspec.lock | 4 ++-- pubspec.yaml | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pubspec.lock b/pubspec.lock index 6295047..686c384 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -325,12 +325,12 @@ packages: source: hosted version: "2.0.3" http_multi_server: - dependency: transitive + dependency: "direct main" description: name: http_multi_server url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "3.0.1" http_parser: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 6eff2e4..f459b4d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -14,7 +14,7 @@ description: A new Flutter project. version: 1.0.0+2 environment: - sdk: ">=2.1.0 <3.0.0" + sdk: ">=2.12.0 <3.0.0" dependencies: shared_preferences: ^2.0.5 @@ -26,6 +26,7 @@ dependencies: flutter_mobx: ^2.0.0 mobx: ^2.0.1 flutter_modular: any + http_multi_server: ^3.0.1 flutter: sdk: flutter From ef567467b339d43f2a92f00a326b5d2e3d6782a9 Mon Sep 17 00:00:00 2001 From: Luis Roseno Date: Fri, 16 Apr 2021 08:01:31 -0300 Subject: [PATCH 6/8] Web configuration instructions --- README.md | 5 +++++ web/index.html | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/README.md b/README.md index 9a0cfa5..0e42008 100644 --- a/README.md +++ b/README.md @@ -14,3 +14,8 @@ A few resources to get you started if this is your first Flutter project: For help getting started with Flutter, view our [online documentation](https://flutter.dev/docs), which offers tutorials, samples, guidance on mobile development, and a full API reference. + +## WEB Configuration of this project + +Inside the web folder on the index.html and set your keys. +Like in this page [Firebase web installation](https://firebase.flutter.dev/docs/installation/web/) \ No newline at end of file diff --git a/web/index.html b/web/index.html index d2b4221..d086e97 100644 --- a/web/index.html +++ b/web/index.html @@ -25,6 +25,24 @@ }); } + + + From 46d30060f929481355760187b63943e9f0a1f8d7 Mon Sep 17 00:00:00 2001 From: Luis Roseno Date: Fri, 16 Apr 2021 13:20:17 -0300 Subject: [PATCH 7/8] Updated some tests --- lib/app/modules/login/login_module.dart | 2 +- .../localstorage/local_storage_mock.dart | 1 + lib/app/splash/splash_page.dart | 3 +++ pubspec.lock | 7 +++++++ pubspec.yaml | 1 + .../modules/login/login_controller_test.dart | 20 ++++++++++--------- test/app/modules/login/login_page_test.dart | 5 ++++- test/app/splash/splash_page_test.dart | 2 +- test/home_controller_test.dart | 11 +++++----- 9 files changed, 35 insertions(+), 17 deletions(-) diff --git a/lib/app/modules/login/login_module.dart b/lib/app/modules/login/login_module.dart index caa3689..df85432 100644 --- a/lib/app/modules/login/login_module.dart +++ b/lib/app/modules/login/login_module.dart @@ -11,6 +11,6 @@ class LoginModule extends Module { @override List get routers => [ - ChildRoute('/', child: (_, args) => LoginPage(title: "Login")), + ChildRoute('/', child: (_, args) => LoginPage()), ]; } diff --git a/lib/app/shared/repositories/localstorage/local_storage_mock.dart b/lib/app/shared/repositories/localstorage/local_storage_mock.dart index 8c5e1da..e04f29d 100644 --- a/lib/app/shared/repositories/localstorage/local_storage_mock.dart +++ b/lib/app/shared/repositories/localstorage/local_storage_mock.dart @@ -5,6 +5,7 @@ class LocalStorageMock implements ILocalStorage { @override Future delete(String key) async { + storage.remove(key); return null; } diff --git a/lib/app/splash/splash_page.dart b/lib/app/splash/splash_page.dart index 74b1e87..be475b9 100644 --- a/lib/app/splash/splash_page.dart +++ b/lib/app/splash/splash_page.dart @@ -37,6 +37,9 @@ class _SplashPageState extends State { @override Widget build(BuildContext context) { return Scaffold( + appBar: AppBar( + title: Text(widget.title), + ), body: Center( child: CircularProgressIndicator(), ), diff --git a/pubspec.lock b/pubspec.lock index 686c384..9082324 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -272,6 +272,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.0.2" + flutter_modular_test: + dependency: "direct dev" + description: + name: flutter_modular_test + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" flutter_test: dependency: "direct dev" description: flutter diff --git a/pubspec.yaml b/pubspec.yaml index f459b4d..6845ea5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -37,6 +37,7 @@ dev_dependencies: mockito: ^5.0.2 build_runner: ^1.12.2 mobx_codegen: ^2.0.1+2 + flutter_modular_test: ^1.0.1 flutter_test: sdk: flutter diff --git a/test/app/modules/login/login_controller_test.dart b/test/app/modules/login/login_controller_test.dart index be60034..8df6609 100644 --- a/test/app/modules/login/login_controller_test.dart +++ b/test/app/modules/login/login_controller_test.dart @@ -1,16 +1,18 @@ -import 'package:flutter_modular/flutter_modular_test.dart'; +import 'package:flutter_modular_test/flutter_modular_test.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_modular/flutter_modular.dart'; - +import 'package:login/app/shared/auth/auth_controller.dart'; +import 'package:mockito/mockito.dart'; import 'package:login/app/modules/login/login_controller.dart'; import 'package:login/app/modules/login/login_module.dart'; +//TODO: Mock auth to pasthrough it void main() { initModule(LoginModule()); - LoginController login; + late LoginController login; setUp(() { - login = LoginModule.to.get(); + login = Modular.get(); }); group('LoginController Test', () { @@ -18,10 +20,10 @@ void main() { expect(login, isInstanceOf()); }); - test("Set Value", () { - expect(login.value, equals(0)); - login.increment(); - expect(login.value, equals(1)); - }); + // test("Set Value", () { + // expect(login.value, equals(0)); + // login.increment(); + // expect(login.value, equals(1)); + // }); }); } diff --git a/test/app/modules/login/login_page_test.dart b/test/app/modules/login/login_page_test.dart index d2fce4f..8448705 100644 --- a/test/app/modules/login/login_page_test.dart +++ b/test/app/modules/login/login_page_test.dart @@ -1,8 +1,11 @@ import 'package:flutter/material.dart'; +import 'package:mockito/mockito.dart'; +import 'package:flutter_modular/flutter_modular.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:flutter_modular/flutter_modular_test.dart'; +import 'package:flutter_modular_test/flutter_modular_test.dart'; import 'package:login/app/modules/login/login_page.dart'; +//TODO: Mock Login Controller to passthrough it main() { testWidgets('LoginPage has title', (WidgetTester tester) async { await tester.pumpWidget(buildTestableWidget(LoginPage(title: 'Login'))); diff --git a/test/app/splash/splash_page_test.dart b/test/app/splash/splash_page_test.dart index 25351ac..8440f66 100644 --- a/test/app/splash/splash_page_test.dart +++ b/test/app/splash/splash_page_test.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:flutter_modular/flutter_modular_test.dart'; +import 'package:flutter_modular_test/flutter_modular_test.dart'; import 'package:login/app/splash/splash_page.dart'; diff --git a/test/home_controller_test.dart b/test/home_controller_test.dart index b0141cb..bc313ab 100644 --- a/test/home_controller_test.dart +++ b/test/home_controller_test.dart @@ -1,6 +1,6 @@ import 'package:flutter_modular/flutter_modular.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:flutter_modular/flutter_modular_test.dart'; +import 'package:flutter_modular_test/flutter_modular_test.dart'; import 'package:login/app/app_module.dart'; import 'package:login/app/modules/home/home_controller.dart'; import 'package:login/app/modules/home/home_module.dart'; @@ -9,8 +9,9 @@ import 'package:login/app/shared/repositories/localstorage/local_storage_mock.da import 'package:login/app/shared/repositories/localstorage/local_storage_share.dart'; main() { - initModule(AppModule(), changeBinds: [ - Bind((i) => LocalStorageMock()), + final storageMock = LocalStorageMock(); + initModule(AppModule(), replaceBinds: [ + Bind.instance(storageMock), ]); initModule(HomeModule()); @@ -21,7 +22,7 @@ main() { expect(controller.list.length, 1); expect(controller.list[0], 'jacob'); - List listStorage = await Modular.get().get('key'); + List listStorage = await Modular.get().get('list'); expect(listStorage[0], 'jacob'); }); @@ -32,7 +33,7 @@ main() { controller.remove(0); expect(controller.list.length, 0); - List listStorage = await Modular.get().get('key'); + List listStorage = await Modular.get().get('list'); expect(listStorage.isEmpty, true); }); } From 27d05aa1a0611f5cdcca98a12dcfb922ad8717f5 Mon Sep 17 00:00:00 2001 From: Luis Roseno Date: Fri, 16 Apr 2021 13:38:18 -0300 Subject: [PATCH 8/8] Removed unused imports --- lib/app/app_module.dart | 3 --- lib/app/modules/home/home_module.dart | 2 -- test/app/modules/login/login_controller_test.dart | 1 - test/app/modules/login/login_page_test.dart | 2 -- test/app/splash/splash_page_test.dart | 1 - test/home_controller_test.dart | 1 - 6 files changed, 10 deletions(-) diff --git a/lib/app/app_module.dart b/lib/app/app_module.dart index c5b6cba..53dde33 100644 --- a/lib/app/app_module.dart +++ b/lib/app/app_module.dart @@ -1,11 +1,8 @@ import 'package:login/app/app_controller.dart'; import 'package:flutter_modular/flutter_modular.dart'; -import 'package:flutter/material.dart'; -import 'package:login/app/app_widget.dart'; import 'package:login/app/modules/home/home_module.dart'; import 'package:login/app/shared/auth/auth_controller.dart'; import 'package:login/app/shared/auth/repositories/auth_repository.dart'; -import 'package:login/app/shared/repositories/localstorage/local_storage_hive.dart'; import 'package:login/app/shared/repositories/localstorage/local_storage_interface.dart'; import 'package:login/app/shared/repositories/localstorage/local_storage_share.dart'; diff --git a/lib/app/modules/home/home_module.dart b/lib/app/modules/home/home_module.dart index edf06ee..a9baeae 100644 --- a/lib/app/modules/home/home_module.dart +++ b/lib/app/modules/home/home_module.dart @@ -1,8 +1,6 @@ import 'package:login/app/modules/home/home_controller.dart'; import 'package:flutter_modular/flutter_modular.dart'; import 'package:login/app/modules/home/home_page.dart'; -import 'package:login/app/shared/repositories/localstorage/local_storage_interface.dart'; -import 'package:login/app/shared/repositories/localstorage/local_storage_share.dart'; class HomeModule extends Module { @override diff --git a/test/app/modules/login/login_controller_test.dart b/test/app/modules/login/login_controller_test.dart index 8df6609..21f8a9d 100644 --- a/test/app/modules/login/login_controller_test.dart +++ b/test/app/modules/login/login_controller_test.dart @@ -1,7 +1,6 @@ import 'package:flutter_modular_test/flutter_modular_test.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_modular/flutter_modular.dart'; -import 'package:login/app/shared/auth/auth_controller.dart'; import 'package:mockito/mockito.dart'; import 'package:login/app/modules/login/login_controller.dart'; import 'package:login/app/modules/login/login_module.dart'; diff --git a/test/app/modules/login/login_page_test.dart b/test/app/modules/login/login_page_test.dart index 8448705..064cf1d 100644 --- a/test/app/modules/login/login_page_test.dart +++ b/test/app/modules/login/login_page_test.dart @@ -1,6 +1,4 @@ -import 'package:flutter/material.dart'; import 'package:mockito/mockito.dart'; -import 'package:flutter_modular/flutter_modular.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_modular_test/flutter_modular_test.dart'; import 'package:login/app/modules/login/login_page.dart'; diff --git a/test/app/splash/splash_page_test.dart b/test/app/splash/splash_page_test.dart index 8440f66..c8daf2d 100644 --- a/test/app/splash/splash_page_test.dart +++ b/test/app/splash/splash_page_test.dart @@ -1,4 +1,3 @@ -import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_modular_test/flutter_modular_test.dart'; diff --git a/test/home_controller_test.dart b/test/home_controller_test.dart index bc313ab..cd0698a 100644 --- a/test/home_controller_test.dart +++ b/test/home_controller_test.dart @@ -6,7 +6,6 @@ import 'package:login/app/modules/home/home_controller.dart'; import 'package:login/app/modules/home/home_module.dart'; import 'package:login/app/shared/repositories/localstorage/local_storage_interface.dart'; import 'package:login/app/shared/repositories/localstorage/local_storage_mock.dart'; -import 'package:login/app/shared/repositories/localstorage/local_storage_share.dart'; main() { final storageMock = LocalStorageMock();