http - 无法启动 Alice HTTP Inspector。请将 NavigatorKey 添加到您的应用程序
问题描述
navigatorKey 已经添加到代码中,但在 navigatorKey 下仍然显示错误(红线)。
@override
Widget build(BuildContext context) {
return WillPopScope(
navigatorKey: _alice.getNavigatorKey(),
child: Theme(
data: ThemeData(
brightness: Brightness.light,
primarySwatch: AppColor.appColor,
primaryColor: AppColor.white,
buttonTheme: ButtonThemeData().copyWith(
buttonColor: AppColor.appColor,
textTheme: ButtonTextTheme.primary),
fontFamily: "EncodeSans",
),
child: layout()),
onWillPop: () {
return handleBackPress();
});
}
解决方案
将 navigatorKey 更改为键:
您的代码必须如下所示:
@override
Widget build(BuildContext context) {
return WillPopScope(
key: _alice.getNavigatorKey(), // here i replace key with navigatorKey
child: Theme(
data: ThemeData(
brightness: Brightness.light,
primarySwatch: AppColor.appColor,
primaryColor: AppColor.white,
buttonTheme: ButtonThemeData().copyWith(
buttonColor: AppColor.appColor,
textTheme: ButtonTextTheme.primary),
fontFamily: "EncodeSans",
),
child: layout()),
onWillPop: () {
return handleBackPress();
});
}
推荐阅读
- http - 为什么 curl 从 Web 服务器的 telnet 返回不同的响应
- swift - SwiftUI 是否可以禁用 UIViewRepresentable 实现的 UITextView 的 Text 上的手势?
- kotlin - 如何从请求中获取数据
在使用 Vollely 库的其他类中, - networking - 如何让传感器/海龟运行功能优先考虑当前最高能量的传感器/海龟?网标
- nestjs - 如何使用 { scope: Scope.REQUEST } 对服务上的每个请求调用方法?
- python - 熊猫:无法根据其他列的条件设置单元格值
- php - 在循环中渲染树枝组件
- c++ - Code Chef DSA 学习系列 : Multiple of 3 Multhree
- postgresql - 将 hasura 连接到现有的 postgresql
- python - 安装 scikit-image 时如何解决此错误?