Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter auto_route, getter 'key' was called on null

Tags:

flutter

dart

import 'package:myapp/core/routes/router.gr.dart' as app_router;

child: MaterialApp(
    title: 'MyApp',
    debugShowCheckedModeBanner: false,
    builder: ExtendedNavigator.builder<app_router.Router>(
      router: app_router.Router()
    ),

I have implememented autoroute however I get an error here that the getter key was called on null

like image 600
Davii The King Avatar asked Dec 30 '22 19:12

Davii The King


2 Answers

As Masnun pointed out, commenting out the line 37 solves the issue. However, there is a different solution that doesn't involve touching the source of the auto_route.

I fixed this issue by removing .builder from:

builder: ExtendedNavigator.builder(
  router: Router(),
  ...
),

and changed to

builder: ExtendedNavigator(
  router: Router(),
  ...
),
like image 189
Taiyr Begeyev Avatar answered Jan 02 '23 09:01

Taiyr Begeyev


The problem is here is this line (line 37).

key: GlobalObjectKey(nav.key),

Commenting out the line from library works fine for me. It may be a temporary problem.

like image 35
Masnun Siam Avatar answered Jan 02 '23 07:01

Masnun Siam