Andrew
Andrew

Reputation: 145

Navigator navigatorKey parameters error (flutter)

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

Upvotes: 0

Views: 188

Answers (1)

Kaushik Chandru
Kaushik Chandru

Reputation: 17802

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}),

Upvotes: 2

Related Questions