Couldn't use report mode because you didn't provide navigator key

flutter dart catcher 报错

Couldn't use report mode because you didn't provide navigator key

DialogReportMode

因为catcher 要想在页面显示对话框,需要知道页面的上下文 context,所以需要配置 navigatorKey: Catcher.navigatorKey,

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      //********************************************
      navigatorKey: Catcher.navigatorKey,
      //********************************************
      home: Scaffold(
          appBar: AppBar(
            title: const Text('Plugin example app'),
          ),
          body: ChildWidget()),
    );
  }

官方说明 https://github.com/jhomlala/catcher#adding-navigator-key

评论

Feng

登录过284天


河北地质大学(本科)
分享&发布