web-dev-qa-db-fra.com

ERREUR: flutter / lib / ui / ui_Dart_state.cc (148) Exception non gérée

Obtenir cette erreur au démarrage de l'application. Au départ, je pensais que c'était un problème de migration vers AndroidX , j'ai fait toutes les étapes pour migrer vers la bibliothèque de support androidx, en vain.

  1. Publié un problème Github ici
  2. J'ai cherché de l'aide dans les commentaires sur problème similaire .

Impossible de déboguer car j'obtiens cette erreur avant le point d'arrêt à la première ligne des hits de la fonction principale.

Erreur

Built build/app/outputs/apk/debug/app-debug.apk.
Installing build/app/outputs/apk/app.apk...
E/flutter (30114): [ERROR:flutter/lib/ui/ui_Dart_state.cc(148)] Unhandled Exception: type 'List<String>' is not a subtype of type 'ReactiveFeedsRepository' of 'feedsRepository'
E/flutter (30114): #0      _runMainZoned.<anonymous closure>.<anonymous closure> (Dart:ui/hooks.Dart:185:38)
E/flutter (30114): #1      _rootRun (Dart:async/zone.Dart:1124:13)
E/flutter (30114): #2      _CustomZone.run (Dart:async/zone.Dart:1021:19)
E/flutter (30114): #3      _runZoned (Dart:async/zone.Dart:1516:10)
E/flutter (30114): #4      runZoned (Dart:async/zone.Dart:1500:12)
E/flutter (30114): #5      _runMainZoned.<anonymous closure> (Dart:ui/hooks.Dart:180:5)
E/flutter (30114): #6      _startIsolate.<anonymous closure> (Dart:isolate/runtime/libisolate_patch.Dart:300:19)
E/flutter (30114): #7      _RawReceivePortImpl._handleMessage (Dart:isolate/runtime/libisolate_patch.Dart:171:12)
E/flutter (30114): 
Syncing files to device ONEPLUS A5000...
V/FA      (30114): Inactivity, disconnecting from the service

Mon docteur Flutter

[✓] Flutter (Channel stable, v1.2.1, on Mac OS X 10.13.6 17G65, locale en-SG)
    • Flutter version 1.2.1 at /Users/harshvardhan/Documents/work/portable/flutter
    • Framework revision 8661d8aecd (13 days ago), 2019-02-14 19:19:53 -0800
    • Engine revision 3757390fa4
    • Dart version 2.1.2 (build 2.1.2-dev.0.0 0a7dcf17eb)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/harshvardhan/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform Android-28, build-tools 28.0.3
    • Android_HOME = /Users/harshvardhan/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/Java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
    • All Android licenses accepted.

[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.1, Build version 10B61
    • ios-deploy 2.0.0
    • CocoaPods version 1.5.3

[✓] Android Studio (version 3.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 33.3.1
    • Dart plugin version 182.5215
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)

[✓] Connected device (1 available)
    • ONEPLUS A5000 • fe6f9295 • Android-arm64 • Android 9 (API 28)

Main.Dart

void main([
  ReactiveTodosRepository todosRepository,
  ReactiveFeedsRepository feedsRepository,
  ReactiveUserFeedsRepository userFeedsRepository,
  ReactiveAuditRepository auditRepository,
  UserFirebaseRepository userRepository,
  SCUserRepositoryImpl scUserRepository
]) async {
  bool isInDebugMode = true;
  SystemChrome.setPreferredOrientations([
    DeviceOrientation.portraitDown,
    DeviceOrientation.portraitUp,
  ]);

  FlutterError.onError = (FlutterErrorDetails details) {
    if (isInDebugMode) {
      // In development mode simply print to console.
      FlutterError.dumpErrorToConsole(details);
    } else {
      // In production mode report to the application zone to report to
      // Crashlytics.
      Zone.current.handleUncaughtError(details.exception, details.stack);
    }
  };

  await FlutterCrashlytics().initialize();

  runZoned<Future<Null>>(() async {
    runApp(ReduxApp(
      todosRepository: todosRepository,
      feedsRepository: feedsRepository,
      userFeedsRepository: userFeedsRepository,
      auditRepository: auditRepository,
      userRepository: userRepository,
      scUserRepository: scUserRepository,
    ));
  }, onError: (error, stackTrace) async {
    // Whenever an error occurs, call the `reportCrash` function. This will send
    // Dart errors to our dev console or Crashlytics depending on the environment.
    await FlutterCrashlytics().reportCrash(error, stackTrace, forceCrash: false);
  });
}

class ReduxApp extends StatelessWidget {
  final Store<AppState> store;
  ReduxApp({
    Key key,
    ReactiveTodosRepository todosRepository,
    ReactiveFeedsRepository feedsRepository,
    ReactiveUserFeedsRepository userFeedsRepository,
    ReactiveAuditRepository auditRepository,
    UserFirebaseRepository userRepository,
    SCUserRepositoryImpl scUserRepository,
  })  : store = Store<AppState>(
          appReducer,
          initialState: AppState.initial(),
          middleware: createStoreTodosMiddleware(
            todosRepository ??
                FirestoreReactiveTodosRepository(Firestore.instance),
            feedsRepository ??
                FirestoreReactiveFeedsRepository(Firestore.instance),
            userFeedsRepository ??
                FirestoreReactiveUserFeedsRepository(Firestore.instance),
            auditRepository ?? AuditAPIRepository(),
            userRepository ?? FirebaseUserRepository(FirebaseAuth.instance),
            scUserRepository ?? SCUserRepositoryImpl(),
          ),
        ),
        super(key: key) {
    store.dispatch(InitAppAction());
  }

  @override
  Widget build(BuildContext context) {
    return StoreProvider(
      store: store,
      child: MaterialApp(
        debugShowCheckedModeBanner: false,
        title: FirestoreReduxLocalizations().appTitle,
        theme: ArchSampleTheme.theme,
        localizationsDelegates: [
          ArchSampleLocalizationsDelegate(),
          FirestoreReduxLocalizationsDelegate(),
        ],
        routes: {
          ArchSampleRoutes.signin: (context) => SignIn(),
          ArchSampleRoutes.newPassword: (context) => NewPassword(),
          ArchSampleRoutes.home: (context) => HomeScreen(),
          ArchSampleRoutes.analytics: (context) => Chart(),
          ArchSampleRoutes.addTodo: (context) => AddTodo(),
          ArchSampleRoutes.forgotPasswordEmailPrompt: (context) => ForgotPasswordEmailPromptScreen(),
          ArchSampleRoutes.forgotPasswordOtpPrompt: (context) => ForgotPasswordOtpPromptScreen(),
        },
      ),
    );
  }
}
4
Harsh Vardhan

Il s'agit d'une erreur de non-concordance de type, assurez-vous que votre type de retour est le même que le type de variable

1
Brinda Rathod

Veuillez vérifier le type de demande, que ce soit GET ou POST. Si vous appelez get request for post request, il affiche cette erreur. Si le type de demande est correct, veuillez vérifier votre réponse JSON, qu'elle soit au format JSON ou non. J'espère que ça aide.

0
Ruturaj Chavda