GithubHelp home page GithubHelp logo

Comments (9)

yuio4235 avatar yuio4235 commented on August 27, 2024 12

Still hit this issue on iOS 13.3 with flutter 1.12.13+hotfix1.5

The error as below:

'package:flutter/src/widgets/navigator.dart': Failed assertion: line 2330 pos 12: '!_debugLocked': is not true.

Here is my code:
Navigator.push(context, MaterialPageRoute( builder: (context) { return DetailPage(value); }, ));

from catcher.

robertodoering avatar robertodoering commented on August 27, 2024 6

I can reproduce it with catcher 0.1.4 and the DialogReportMode whenever I am trying to navigate to a new screen where an exception is thrown during the first build.

Here is an example app where the error occurs:

import 'package:catcher/catcher_plugin.dart';
import 'package:flutter/material.dart';

void main() {
  final debugOptions = CatcherOptions(DialogReportMode(), [
    ConsoleHandler(),
  ]);

  Catcher(
    MyApp(),
    debugConfig: debugOptions,
  );
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      navigatorKey: Catcher.navigatorKey,
      home: HomePage(),
    );
  }
}

class HomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: Center(
        child: RaisedButton(
          child: Text("navigate"),
          onPressed: () {
            Navigator.of(context).pushReplacement(MaterialPageRoute(
              builder: (context) => CrashScreen(),
            ));
          },
        ),
      ),
    );
  }
}

class CrashScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    throw Exception();

    return Container();
  }
}

I assume the problem is that the dialog is trying to be shown in the same frame when the new screen is being built. A fix for that would be to simply make the _showDialog method in dialog_report_mode.dart asynchronous and adding a await Future.delayed(Duration.zero); to force the dialog to be shown one frame after the build method runs.

The same works for the PageReportMode by adding the await before the Navigator.pushis being called.

I am not sure if this is the most elegant solution but it worked for me.
@jhomlala if you like I can create a PR with the fix.

from catcher.

fsresponser avatar fsresponser commented on August 27, 2024 4

the same thing.
My solution is: WidgetsBinding.instance.addPostFrameCallback((_){}。
I found it occurs when performing setState and navigate (probably Navigator.push, showDialog, showMenu etc) in the same time. So, i think we shouldn't perform actions that affect render process.

from catcher.

aemxn avatar aemxn commented on August 27, 2024

Never mind, I think I got it working now. It was due to the way I throw the exception. I mislooked at the code where I implement the return null statement. Turns out the button is already using MaterialPageRoute. Perhaps it conflicted with the navigatorKey from the main which invokes the same MaterialPageRoute to display the error page report.

... I don't know. I'm so new to Flutter navigation system. 🤷‍♂️

from catcher.

aemxn avatar aemxn commented on August 27, 2024

Had to reopen this issue since the same exception is still there even though producing different throwable event than the MaterialPageRoute.

from catcher.

jhomlala avatar jhomlala commented on August 27, 2024

Why don't you use AndroidX libs, even if it's recommended by Google? If you're creating new project, you should target the highest SDK version as possible. Plenty of Flutter libs are using AndroidX now.

from catcher.

kleinpetr avatar kleinpetr commented on August 27, 2024

Hey I have the same problem

CatcherOptions debugOptions =
    CatcherOptions(DialogReportMode(), [ConsoleHandler()]);
CatcherOptions releaseOptions = CatcherOptions(DialogReportMode(), [
  EmailManualHandler(["[email protected]"])
]);

Catcher(App(),
    debugConfig: debugOptions, releaseConfig: releaseOptions);
child: MaterialApp(
        debugShowCheckedModeBanner: false,
        title: 'Bazzarro',
        initialRoute: Routes.home, //default
        navigatorKey: Catcher.navigatorKey,
        onGenerateRoute: (RouteSettings settings) {
          switch (settings.name) {
            case Routes.home:
              return SimplePageRoute(builder: (context) => HomeScreen());
              break;
            case Routes.contacts:
              return SimplePageRoute(builder: (context) => ContactsScreen());
              break;
          }

          //*else
          return MaterialPageRoute(
              builder: (context) => NotFoundScreen(routeName: settings.name));
        },
      ),

I have got

E/flutter (21714): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: 'package:flutter/src/widgets/navigator.dart': Failed assertion: line 1736 pos 12: '!_debugLocked': is not true.
E/flutter (21714): #0      _AssertionError._doThrowNew  (dart:core-patch/errors_patch.dart:40:39)
E/flutter (21714): #1      _AssertionError._throwNew  (dart:core-patch/errors_patch.dart:36:5)
E/flutter (21714): #2      NavigatorState.push 
package:flutter/…/widgets/navigator.dart:1736
E/flutter (21714): #3      showGeneralDialog 
package:flutter/…/widgets/routes.dart:1558
E/flutter (21714): #4      showDialog 
package:flutter/…/material/dialog.dart:705
E/flutter (21714): #5      DialogReportMode._showDialog 
package:catcher/mode/dialog_report_mode.dart:12
E/flutter (21714): #6      DialogReportMode.requestAction 
package:catcher/mode/dialog_report_mode.dart:8
E/flutter (21714): #7      Catcher._reportError 
package:catcher/core/catcher.dart:264
E/flutter (21714): <asynchronous suspension>
E/flutter (21714): #8      Catcher._setupErrorHooks.<anonymous closure> 
package:catcher/core/catcher.dart:117
E/flutter (21714): <asynchronous suspension>
E/flutter (21714): #9      _rootRunBinary  (dart:async/zone.dart:1148:13)
E/flutter (21714): #10     _CustomZone.runBinary  (dart:async/zone.dart:1037:19)
E/flutter (21714): #11     runZoned.<anonymous closure>  (dart:async/zone.dart:1479:21)
E/flutter (21714): #12     _CustomZone.handleUncaughtError  (dart:async/zone.dart:1003:19)
E/flutter (21714): #13     Future._propagateToListeners  (dart:async/future_impl.dart:555:16)
E/flutter (21714): #14     Future._completeError  (dart:async/future_impl.dart:491:5)
E/flutter (21714): #15     _SyncCompleter._completeError  (dart:async/future_impl.dart:55:12)
E/flutter (21714): #16     _Completer.completeError  (dart:async/future_impl.dart:27:5)
E/flutter (21714): #17     _AsyncAwaitCompleter.completeError  (dart:async-patch/async_patch.dart:40:18)
E/flutter (21714): #18     Catcher._setupErrorHooks.<anonymous closure> (package:catcher/core/catcher.dart)
E/flutter (21714): <asynchronous suspension>
E/flutter (21714): #19     FlutterError.reportError 
package:flutter/…/foundation/assertions.dart:413
E/flutter (21714): #20     _UserData&Object&ChangeNotifier.notifyListeners 
package:flutter/…/foundation/change_notifier.dart:208
E/flutter (21714): #21     UserData.syncContacts 
package:bazzarro/models/user_data.dart:29
E/flutter (21714): <asynchronous suspension>
E/flutter (21714): #22     _ContactsScreenState.initState 
package:bazzarro/screens/contacts_screen.dart:27
E/flutter (21714): #23     StatefulElement._firstBuild 
package:flutter/…/widgets/framework.dart:3846
E/flutter (21714): #24     ComponentElement.mount 
package:flutter/…/widgets/framework.dart:3717
E/flutter (21714): #25     Element.inflateWidget 
package:flutter/…/widgets/framework.dart:2961
E/flutter (21714): #26     Element.updateChild 
package:flutter/…/widgets/framework.dart:2764
E/flutter (21714): #27     SingleChildRenderObjectElement.mount 
package:flutter/…/widgets/framework.dart:4876
E/flutter (21714): #28     Element.inflateWidget 
package:flutter/…/widgets/framework.dart:2961
E/flutter (21714): #29     Element.updateChild 
package:flutter/…/widgets/framework.dart:2764
E/flutter (21714): #30     ComponentElement.performRebuild 
package:flutter/…/widgets/framework.dart:3750
E/flutter (21714): #31     Element.rebuild 
package:flutter/…/widgets/framework.dart:3565
E/flutter (21714): #32     ComponentElement._firstBuild 
package:flutter/…/widgets/framework.dart:3722
E/flutter (21714): #33     ComponentElement.mount 
package:flutter/…/widgets/framework.dart:3717
E/flutter (21714): #34     Element.inflateWidget 
package:flutter/…/widgets/framework.dart:2961
E/flutter (21714): #35     Element.updateChild 
package:flutter/…/widgets/framework.dart:2764
E/flutter (21714): #36     SingleChildRenderObjectElement.mount 
package:flutter/…/widgets/framework.dart:4876
E/flutter (21714): #37     Element.inflateWidget 
package:flutter/…/widgets/framework.dart:2961
E/flutter (21714): #38     Element.updateChild 
package:flutter/…/widgets/framework.dart:2764
E/flutter (21714): #39     SingleChildRenderObjectElement.mount 
package:flutter/…/widgets/framework.dart:4876
E/flutter (21714): #40     Element.inflateWidget 
package:flutter/…/widgets/framework.dart:2961
E/flutter (21714): #41     Element.updateChild 
package:flutter/…/widgets/framework.dart:2764
E/flutter (21714): #42     SingleChildRenderObjectElement.mount 
package:flutter/…/widgets/framework.dart:4876
E/flutter (21714): #43     Element.inflateWidget 
package:flutter/…/widgets/framework.dart:2961
E/flutter (21714): #44     Element.updateChild 
package:flutter/…/widgets/framework.dart:2764
E/flutter (21714): #45     ComponentElement.performRebuild (package:flutter/src/widgets/framewo
E/flutter (21714): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: 'package:flutter/src/widgets/navigator.dart': Failed assertion: line 1736 pos 12: '!_debugLocked': is not true.

And yes, I am using Android X and the highest version of plugins.

from catcher.

jhomlala avatar jhomlala commented on August 27, 2024

Thank you @robertodoering for finding solution for this problem. I have fixed it in 0.1.5.

from catcher.

conceptualben avatar conceptualben commented on August 27, 2024

Thought of leaving a note here that may be useful for others experiencing this issue:

On my case the issue was I was navigating to a new route on a method called right on initialisation of my screen, waving a call with await right before the navigation solved things to me. (this was on was a startup screen that checked user and redirected accordingly)

from catcher.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.