Flutterando / modular

A smart project structure
https://pub.dev/packages/flutter_modular
Other
1.31k stars 253 forks source link

The method Modular.isModuleReady isn't defined in version 6.x #969

Open frankylee opened 19 hours ago

frankylee commented 19 hours ago

Describe the bug

Hello! I just upgraded flutter_modular from 5.0.3 to 6.3.4 and noticed that the previously used Modular.isModuleReady is no longer available. There was no mention of how to handle this in the CHANGELOG.md or the Migration Docs.

The error I am seeing is:

The method 'isModuleReady' isn't defined for the type 'IModularBase'. Try correcting the name to the name of an existing method, or defining a method named 'isModuleReady'.

Environment

Add your flutter doctor -v

[✓] Flutter (Channel stable, 3.24.3, on macOS 14.6.1 23G93 darwin-arm64, locale en-US)
    • Flutter version 3.24.3 on channel stable at
      /Users/xxx/fvm/versions/3.24.3
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2663184aa7 (5 weeks ago), 2024-09-11 16:27:48 -0500
    • Engine revision 36335019a8
    • Dart version 3.5.3
    • DevTools version 2.37.3

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at /Users/xxx/Library/Android/sdk
    • Platform android-35, build-tools 35.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11609105)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11609105)

[✓] VS Code (version 1.94.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.98.0

[✓] Connected device (5 available)
    • ...
    • macOS (desktop)                          • macos                     •
      darwin-arm64   • macOS 14.6.1 23G93 darwin-arm64
    • Mac Designed for iPad (desktop)          • mac-designed-for-ipad     • darwin
      • macOS 14.6.1 23G93 darwin-arm64
    • Chrome (web)                             • chrome                    •
      web-javascript • Google Chrome XXX.X.XXXX.XX

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Add your pubspec.yaml

environment:
  sdk: '>=3.5.3 <4.0.0'

dependencies:
  asuka: ^2.2.1
  csv: ^6.0.0
  cupertino_icons: ^1.0.8
  dartz: ^0.10.1
  dio: ^5.7.0
  envied: ^0.5.4+1
  equatable: ^2.0.3
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter
  flutter_mobx: ^2.2.1+1
  flutter_modular: ^6.3.4
  intl: ^0.19.0
  jiffy: ^6.2.2
  js: ^0.6.7
  json_annotation: ^4.9.0
  json_serializable: ^6.8.0
  mobx: ^2.3.3+2
  syncfusion_flutter_xlsio: ^27.1.53
  url_strategy: ^0.3.0
  wakelock_web: ^0.4.0

dev_dependencies:
  analyzer: ^6.7.0
  build_runner: ^2.4.13
  envied_generator: ^0.5.4+1
  flutter_lints: ^5.0.0
  flutter_test:
    sdk: flutter
  mobx_codegen: ^2.6.1
  mocktail: ^1.0.4

flutter:
  generate: true
  uses-material-design: true

To Reproduce

class SessionGuard extends RouteGuard {
  SessionGuard() : super(redirectTo: AppRoutes.home);

  @override
  Future<bool> canActivate(String path, ModularRoute route) async {
    await Modular.isModuleReady<CoreModule>();
    final controller = Modular.get<CoreController>();
    await controller.validateSession();
    return controller.loggedIn;
  }
}

Expected behavior

I expected there to be some notice about the deprecation or removal of Modular.isModuleReady or migration documentation on how to migrate to version 6.x.

eduardoflorence commented 5 hours ago

In Modular 6 there are no more AsyncBinds and all modules are synchronous, so there is no need to check if a module is ready.

eduardoflorence commented 5 hours ago

See this issue: https://github.com/Flutterando/modular/issues/894