Home > Mobile >  Navigator navigatorKey parameters error (flutter)
Navigator navigatorKey parameters error (flutter)

Time:07-02

I have some error


  TabNavigator({this.navigatorKey, this.tabItem});

  final GlobalKey<NavigatorState> navigatorKey;
  final TabItem tabItem;

  @override
  Widget build(BuildContext context) {

    return Navigator(
      key: navigatorKey,

The parameter 'navigatorKey' can't have a value of 'null' because of its type, but the implicit default value is 'null'.

How to fix this error?

enter image description here

CodePudding user response:

the navigator key that you have defined is of type Global key but right now its null unless its passed from another class. So you have to mark it as required

TabNavigator({required this.navigatorKey, required this.tabItem}),
  • Related