1

I wrote this code, but I got the error.

void main() async {
  WidgetsFlutterBinding.ensureInitialized;
  if (kIsWeb) {
    await Firebase.initializeApp(
      options: const FirebaseOptions(
        apiKey: 'xxx',
        appId: 'xxx',
        messagingSenderId: 'xxxx',
        projectId: 'xxxx',
        storageBucket: 'xxx',
      ),
    );
  } else {
    await Firebase.initializeApp();
  }

Exception has occurred. _CastError (Null check operator used on a null value)

where has a problem? I think this code is correct.

Stanley
  • 311
  • 5
  • 15
  • See this [solution](https://stackoverflow.com/questions/64278595/null-check-operator-used-on-a-null-value) to a similar question. Hope this helps. :) – nonsocchi Mar 09 '22 at 10:21
  • @nonsocchi I'd saw it and tried it, but still cannot solve. – Stanley Mar 09 '22 at 10:29

0 Answers0