1

navigatorKey has already been added to the code, still it shows error(red line) under the 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();
});
}

1 Answers1

0

change navigatorKey to key:

you code must look like belew:

@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();
});
}
Taleb
  • 1,944
  • 2
  • 11
  • 36