Flutter auto_route, getter 'key' was called on null

Viewed 1175
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

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(),
  ...
),

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.

Related