AutoRoute package throw WidgetsBindings error

Viewed 219

I'd like to use the AutoRoute package to manage my routes, however after installing and configuring it, I'm unable to run my app and receive the following error on the console.

: Error: Property 'window' cannot be accessed on 'WidgetsBinding?' because it is potentially null.
../…/provider/auto_route_information_provider.dart:20
- 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../../flutter/packages/flutter/lib/src/widgets/binding.dart').
package:flutter/…/widgets/binding.dart:1
Try accessing using ?. instead.
            location: WidgetsBinding.instance.window.defaultRouteName);
                                              ^^^^^^
: Error: Property 'window' cannot be accessed on 'WidgetsBinding?' because it is potentially null.
../…/provider/auto_route_information_provider.dart:53
- 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../../flutter/packages/flutter/lib/src/widgets/binding.dart').
package:flutter/…/widgets/binding.dart:1
1 Answers

I was able to fix it by going to the library and adding a null check (?) to each lines of code that has throws that bug. You can easily navigate to the library code by using ctrl and tapping on the underlined reference code in your terminal

Related