Flutterfire: 🐛 [firebase_auth] signOut/signInWithCredential do not emit authStateChanges event after app reinstall

Created on 27 Oct 2020  ·  7Comments  ·  Source: FirebaseExtended/flutterfire

Bug report

Describe the bug
Normally successful calls of signInWithCredential or signOut lead to a state change emitted by the authStateChanges stream.
If my app (iOS) is being deleted from the device and installed again immediately, this behavior is different.
When the reinstalled app is reopened, the user is still signed in (if he was before he deleted the app).
Calls to signOut however do not trigger an event to be emitted by authStateChanges.
They result in no action whatsoever.
Same behavior if the user was logged out before deletion and then calling signInWithCredential after reinstall.

The state of a user session after an app reinstall is not yet totally clear to me and I've not found any documentation on this so far.

Steps to reproduce

Steps to reproduce the behavior:

  1. Maintain an active user session
  2. Delete app
  3. Reinstall app
  4. Call signOut()
  5. listen to events of authStateChanges

Expected behavior

After a reinstall, the calls to signOut or signInWithCredential emit a authStateChanges when successful.


Flutter doctor

Click To Expand

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, 1.23.0-18.1.pre, on Mac OS X 10.15.7 19H2 x86_64, locale en-US)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 12.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] VS Code (version 1.50.1)
[✓] Connected device (2 available)

• No issues found!


Flutter dependencies

Click To Expand

Dart SDK 2.11.0-213.1.beta
Flutter SDK 1.23.0-18.1.pre
flathunt_app 1.2.0+1

dependencies:
- add_2_calendar 1.4.0 [flutter]
- auto_animated 2.1.0 [flutter visibility_detector]
- auto_size_text 2.1.0 [flutter]
- cloud_firestore 0.14.1+3 [flutter meta quiver firebase_core firebase_core_platform_interface cloud_firestore_platform_interface cloud_firestore_web]
- cupertino_icons 1.0.0
- curved_navigation_bar 0.3.4 [flutter meta]
- dough 0.3.6 [flutter sensors equatable vector_math provider]
- enum_to_string 1.0.13
- firebase_analytics 6.0.2 [meta flutter firebase_core firebase_analytics_web firebase_analytics_platform_interface]
- firebase_auth 0.18.1+2 [meta firebase_core firebase_core_platform_interface firebase_auth_platform_interface firebase_auth_web flutter]
- firebase_core 0.5.0+1 [firebase_core_platform_interface flutter quiver meta firebase_core_web]
- firebase_crashlytics 0.2.1+1 [flutter stack_trace firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface]
- flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine]
- flutter_chips_input 1.9.4 [flutter]
- flutter_form_builder 3.14.0-alpha.2 [flutter flutter_typeahead intl flutter_chips_input datetime_picker_formfield flutter_colorpicker signature validators date_range_picker flutter_touch_spin image_picker image_picker_for_web rating_bar country_pickers phone_number]
- flutter_launcher_icons 0.8.1 [image args yaml path]
- flutter_localizations 0.0.0 [flutter intl characters collection meta path typed_data vector_math]
- flutter_native_splash 0.1.9 [yaml image color]
- flutter_rating_bar 3.0.1+1 [flutter]
- flutter_svg 0.19.1 [flutter meta path_drawing vector_math xml]
- flutter_vector_icons 0.2.1 [flutter]
- font_awesome_flutter 8.10.0 [flutter]
- google_fonts 1.1.1 [flutter http path_provider crypto pedantic]
- introduction_screen 1.0.9 [flutter dots_indicator]
- modal_bottom_sheet 0.2.2 [flutter]
- package_info_plus 0.5.0 [flutter package_info_plus_platform_interface package_info_plus_web package_info_plus_macos]
- progress_state_button 1.0.1 [flutter]
- provider 4.3.2+2 [flutter nested collection]
- shared_preferences 0.5.12+2 [meta flutter shared_preferences_platform_interface shared_preferences_linux shared_preferences_macos shared_preferences_web shared_preferences_windows]
- sign_in_with_apple 2.5.4 [meta flutter]
- url_launcher 5.7.8 [flutter url_launcher_platform_interface url_launcher_web url_launcher_linux url_launcher_macos url_launcher_windows]

dev dependencies:
- flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher meta source_span stream_channel string_scanner term_glyph typed_data]

transitive dependencies:
- archive 2.0.13 [crypto args path]
- args 1.6.0
- asn1lib 0.6.5
- async 2.5.0-nullsafety.1 [collection]
- basic_utils 2.6.3 [http logging json_annotation pointycastle asn1lib convert crypto]
- boolean_selector 2.1.0-nullsafety.1 [source_span string_scanner]
- characters 1.1.0-nullsafety.3
- charcode 1.2.0-nullsafety.1
- clock 1.1.0-nullsafety.1
- cloud_firestore_platform_interface 2.1.2 [flutter meta collection firebase_core plugin_platform_interface]
- cloud_firestore_web 0.2.0+4 [flutter flutter_web_plugins firebase http_parser meta firebase_core cloud_firestore_platform_interface js]
- collection 1.15.0-nullsafety.3
- color 2.1.1
- convert 2.1.1 [charcode typed_data]
- country_pickers 1.3.0 [flutter]
- crypto 2.1.5 [collection convert typed_data]
- date_range_picker 1.0.6 [flutter]
- datetime_picker_formfield 1.0.0 [flutter intl]
- dots_indicator 1.2.0 [flutter]
- equatable 1.2.5 [collection meta]
- fake_async 1.2.0-nullsafety.1 [clock collection]
- ffi 0.1.3
- file 5.2.1 [intl meta path]
- firebase 7.3.2 [http http_parser js]
- firebase_analytics_platform_interface 1.0.3 [flutter meta]
- firebase_analytics_web 0.1.1 [flutter flutter_web_plugins firebase firebase_analytics_platform_interface meta]
- firebase_auth_platform_interface 2.1.1 [flutter meta firebase_core plugin_platform_interface]
- firebase_auth_web 0.3.1+1 [flutter flutter_web_plugins firebase meta http_parser intl firebase_core firebase_auth_platform_interface js]
- firebase_core_platform_interface 2.0.0 [flutter meta plugin_platform_interface quiver]
- firebase_core_web 0.2.0 [firebase firebase_core_platform_interface flutter flutter_web_plugins meta js]
- firebase_crashlytics_platform_interface 1.1.1 [flutter meta collection firebase_core plugin_platform_interface]
- flutter_colorpicker 0.3.4 [flutter]
- flutter_keyboard_visibility 3.2.2 [flutter]
- flutter_plugin_android_lifecycle 1.0.11 [flutter]
- flutter_touch_spin 1.0.1 [flutter intl]
- flutter_typeahead 1.8.8 [flutter flutter_keyboard_visibility]
- flutter_web_plugins 0.0.0 [flutter js characters collection meta typed_data vector_math]
- http 0.12.2 [http_parser path pedantic]
- http_parser 3.1.4 [charcode collection source_span string_scanner typed_data]
- image 2.1.18 [archive xml meta]
- image_picker 0.6.7+12 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface]
- image_picker_for_web 0.1.0+2 [image_picker_platform_interface flutter flutter_web_plugins meta js]
- image_picker_platform_interface 1.1.1 [flutter meta http plugin_platform_interface]
- intl 0.16.1 [path]
- js 0.6.3-nullsafety.1
- json_annotation 3.0.1
- logging 0.11.4
- matcher 0.12.10-nullsafety.1 [stack_trace]
- meta 1.3.0-nullsafety.4
- nested 0.0.4 [flutter]
- package_info_plus_macos 0.1.0 [flutter]
- package_info_plus_platform_interface 0.1.0 [flutter meta plugin_platform_interface]
- package_info_plus_web 0.1.0 [http package_info_plus_platform_interface platform_detect flutter flutter_web_plugins meta]
- path 1.8.0-nullsafety.1
- path_drawing 0.4.1+1 [vector_math meta path_parsing flutter]
- path_parsing 0.1.4 [vector_math meta]
- path_provider 1.6.22 [flutter path_provider_platform_interface path_provider_macos path_provider_linux path_provider_windows]
- path_provider_linux 0.0.1+2 [path xdg_directories path_provider_platform_interface flutter]
- path_provider_macos 0.0.4+4 [flutter]
- path_provider_platform_interface 1.0.3 [flutter meta platform plugin_platform_interface]
- path_provider_windows 0.0.4+1 [path_provider_platform_interface meta path flutter ffi win32]
- pedantic 1.9.2 [meta]
- petitparser 3.1.0 [meta]
- phone_number 0.6.3 [flutter]
- platform 2.2.1
- platform_detect 1.4.0 [meta pub_semver]
- plugin_platform_interface 1.0.3 [meta]
- pointycastle 1.0.2
- process 3.0.13 [file intl meta path platform]
- pub_semver 1.4.4 [collection]
- quiver 2.1.4+1 [matcher meta]
- random_string 2.1.0
- rating_bar 0.2.0 [flutter]
- sensors 0.4.2+6 [flutter]
- shared_preferences_linux 0.0.2+2 [file flutter meta path path_provider_linux shared_preferences_platform_interface]
- shared_preferences_macos 0.0.1+10 [shared_preferences_platform_interface flutter]
- shared_preferences_platform_interface 1.0.4 [meta flutter]
- shared_preferences_web 0.1.2+7 [shared_preferences_platform_interface flutter flutter_web_plugins meta]
- shared_preferences_windows 0.0.1+1 [shared_preferences_platform_interface flutter ffi file meta path path_provider_platform_interface path_provider_windows]
- signature 3.2.0 [flutter image]
- sky_engine 0.0.99
- source_span 1.8.0-nullsafety.2 [charcode collection path term_glyph]
- stack_trace 1.10.0-nullsafety.2 [path]
- stream_channel 2.1.0-nullsafety.1 [async]
- string_scanner 1.1.0-nullsafety.1 [charcode source_span]
- term_glyph 1.2.0-nullsafety.1
- test_api 0.2.19-nullsafety.2 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher]
- typed_data 1.3.0-nullsafety.3 [collection]
- url_launcher_linux 0.0.1+3 [flutter]
- url_launcher_macos 0.0.1+8 [flutter]
- url_launcher_platform_interface 1.0.9 [flutter meta plugin_platform_interface]
- url_launcher_web 0.1.5 [url_launcher_platform_interface flutter flutter_web_plugins meta]
- url_launcher_windows 0.0.1+1 [flutter]
- validators 2.0.1 [vin_decoder]
- vector_math 2.1.0-nullsafety.3
- vin_decoder 0.1.2 [meta basic_utils http random_string]
- visibility_detector 0.1.5 [flutter]
- win32 1.7.3 [ffi]
- xdg_directories 0.1.2 [meta path process]
- xml 4.5.1 [collection convert meta petitparser]
- yaml 2.2.1 [charcode collection string_scanner source_span]


customer-response bug

Most helpful comment

I was not able to reproduce the bug with the code sample provided by @markusaksli-nc

I will close this issue for now.
Once I find the difference between my codebase and the sample code I will reopen the issue.

Thanks to everyone involved

All 7 comments

@eliabieri This does not sound like typical behaviour.

Is this consistent across multiple devices?

By cleaning the apps application data on the device, is this reproducible?

@dackers86 I am able to consistently reproduce it on a iPhone and iPad (iOS 14.1).
I'm also able to reproduce this by deleting the App via Settings->General->iPhone Storage->APP->Delete App

There must remain certain information in the keychain to trigger this behavior.
Sadly I was not able to read the content of the keychain. I'd be happy to hear about any ideas.

Any idea how I can further examine this?
I already wasted days on this issue
Thanks for the help!

Further context:
In the above mentioned state (first launch after app reinstall), FirebaseAuth.instance.currentUser returns a fully populated User instance.
I don't understand how signOut does not emit a authStateChanges event in that state.

Works just fine for me on flutter master 1.24.0-4.0.pre.138 with firebase_auth: ^0.18.0+1 on both simulator and physical.


flutter doctor -v

[✓] Flutter (Channel master, 1.24.0-4.0.pre.138, on Mac OS X 10.15.7 19H2 darwin-x64, locale en-GB)
    • Flutter version 1.24.0-4.0.pre.138 at /Users/markus/development/flutter_master
    • Framework revision 13896b3bd1 (5 hours ago), 2020-10-28 19:43:19 -0700
    • Engine revision 073263e39d
    • Dart version 2.11.0 (build 2.11.0-260.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
    • Android SDK at /Users/markus/Library/Android/sdk
    • Platform android-30, build-tools 30.0.1
    • Java binary at: /Users/markus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/201.6858069/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.1, Build version 12A7403
    • CocoaPods version 1.10.0

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Users/markus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/201.6858069/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      � https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      � https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] Connected device (5 available)
    • Nevercode’s iPhone (mobile) • b668e524315069f3db3661ac11ff1f66afafebdb • ios            • iOS 14.1
    • iPhone 12 Pro Max (mobile)  • 1C7EE787-1EC9-427C-AFEE-224EF736BBCA     • ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-1 (simulator)
    • macOS (desktop)             • macos                                    • darwin-x64     • Mac OS X 10.15.7 19H2 darwin-x64
    • Web Server (web)            • web-server                               • web-javascript • Flutter Tools
    • Chrome (web)                • chrome                                   • web-javascript • Google Chrome 86.0.4240.111
    ! Error: Nevercode’s iPhone is busy: Copying cache files from device. Xcode will continue when Nevercode’s iPhone is finished. (code -10)

• No issues found!



Used code sample

import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:flutter_signin_button/flutter_signin_button.dart';

final FirebaseAuth _auth = FirebaseAuth.instance;

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  runApp(AuthExampleApp());
}

/// The entry point of the application.
///
/// Returns a [MaterialApp].
class AuthExampleApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(title: 'Firebase Example App', theme: ThemeData.dark(), home: SignInPage());
  }
}

/// Entrypoint example for various sign-in flows with Firebase.
class SignInPage extends StatefulWidget {
  /// The page title.
  final String title = 'authStateChanges';

  @override
  State<StatefulWidget> createState() => _SignInPageState();
}

class _SignInPageState extends State<SignInPage> {
  String uid = "";

  @override
  void initState() {
    changeUidText(_auth.currentUser);
    _auth.authStateChanges().listen((user) => changeUidText(user));
    super.initState();
  }

  void changeUidText(User user){
    setState(() {
      if (user == null) {
        uid = "Signed out";
        return;
      }
      uid = user.uid;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
        actions: <Widget>[
          Builder(builder: (BuildContext context) {
            return FlatButton(
              child: const Text('Sign out'),
              textColor: Theme.of(context).buttonColor,
              onPressed: () async {
                final User user = await _auth.currentUser;
                if (user == null) {
                  Scaffold.of(context).showSnackBar(const SnackBar(
                    content: Text('No one has signed in.'),
                  ));
                  return;
                }
                _signOut();
                final String uid = user.uid;
                Scaffold.of(context).showSnackBar(SnackBar(
                  content: Text(uid + ' has successfully signed out.'),
                ));
              },
            );
          })
        ],
      ),
      body: Builder(builder: (BuildContext context) {
        return ListView(
          padding: EdgeInsets.all(8),
          scrollDirection: Axis.vertical,
          children: <Widget>[
            Text(uid),
            _AnonymouslySignInSection(),
          ],
        );
      }),
    );
  }

  // Example code for sign out.
  void _signOut() async {
    await _auth.signOut();
  }
}

class _AnonymouslySignInSection extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => _AnonymouslySignInSectionState();
}

class _AnonymouslySignInSectionState extends State<_AnonymouslySignInSection> {
  bool _success;
  String _userID;

  @override
  Widget build(BuildContext context) {
    return Card(
        child: Padding(
            padding: const EdgeInsets.all(16.0),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Container(
                  child: const Text('Test sign in anonymously', style: TextStyle(fontWeight: FontWeight.bold)),
                  alignment: Alignment.center,
                ),
                Container(
                  padding: const EdgeInsets.only(top: 16.0),
                  alignment: Alignment.center,
                  child: SignInButtonBuilder(
                    text: "Sign In",
                    icon: Icons.person_outline,
                    backgroundColor: Colors.deepPurple,
                    onPressed: () async {
                      _signInAnonymously();
                    },
                  ),
                ),
                Visibility(
                  visible: _success == null ? false : true,
                  child: Container(
                    alignment: Alignment.center,
                    padding: const EdgeInsets.symmetric(horizontal: 16),
                    child: Text(
                      _success == null ? '' : (_success ? 'Successfully signed in, uid: ' + _userID : 'Sign in failed'),
                      style: TextStyle(color: Colors.red),
                    ),
                  ),
                )
              ],
            )));
  }

  // Example code of how to sign in anonymously.
  void _signInAnonymously() async {
    try {
      final User user = (await _auth.signInAnonymously()).user;

      Scaffold.of(context).showSnackBar(SnackBar(
        content: Text("Signed in Anonymously as user ${user.uid}"),
      ));
    } catch (e) {
      Scaffold.of(context).showSnackBar(SnackBar(
        content: Text("Failed to sign in Anonymously"),
      ));
    }
  }
}

Thanks a lot for trying to reproduce this.
According to this, anonymous login is not suitable to reproduce it:

It is null becase Firebase Anonymous Authentication accounts does not persist across application uninstalls

I use the following for my login:

Click To Expand

    AuthorizationCredentialAppleID appleCredentials;
    try {
      appleCredentials = await SignInWithApple.getAppleIDCredential(
        scopes: [
          AppleIDAuthorizationScopes.email,
          AppleIDAuthorizationScopes.fullName
        ],
      );
    } catch (e) {
      print(e);
      return Future.error(e.toString());
    }

    final oAuthProvider = OAuthProvider('apple.com');
    final credential = oAuthProvider.credential(
      idToken: appleCredentials.identityToken,
      accessToken: appleCredentials.authorizationCode,
    );

    UserCredential authResult;
    try {
      authResult = await _firebaseAuth.signInWithCredential(credential);
    } catch (e) {
      print(e);
      return Future.error(e.toString());
    }

    if (null != appleCredentials.givenName) {
      await authResult.user.updateProfile(
          displayName:
              '${appleCredentials.givenName} ${appleCredentials.familyName}');
    }

I will rewrite the code snipped provided by @markusaksli-nc to use email password authentication and see if I can reproduce the bug this way.

@eliabieri We can just use the one from the official example.


Email and password code sample

import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:flutter_signin_button/flutter_signin_button.dart';

final FirebaseAuth _auth = FirebaseAuth.instance;

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  runApp(AuthExampleApp());
}

/// The entry point of the application.
///
/// Returns a [MaterialApp].
class AuthExampleApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(title: 'Firebase Example App', theme: ThemeData.dark(), home: SignInPage());
  }
}

/// Entrypoint example for various sign-in flows with Firebase.
class SignInPage extends StatefulWidget {
  /// The page title.
  final String title = 'authStateChanges';

  @override
  State<StatefulWidget> createState() => _SignInPageState();
}

class _SignInPageState extends State<SignInPage> {
  String uid = "";

  @override
  void initState() {
    changeUidText(_auth.currentUser);
    _auth.authStateChanges().listen((user) => changeUidText(user));
    super.initState();
  }

  void changeUidText(User user){
    setState(() {
      if (user == null) {
        uid = "Signed out";
        return;
      }
      uid = user.uid;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
        actions: <Widget>[
          Builder(builder: (BuildContext context) {
            return FlatButton(
              child: const Text('Sign out'),
              textColor: Theme.of(context).buttonColor,
              onPressed: () async {
                final User user = await _auth.currentUser;
                if (user == null) {
                  Scaffold.of(context).showSnackBar(const SnackBar(
                    content: Text('No one has signed in.'),
                  ));
                  return;
                }
                _signOut();
                final String uid = user.uid;
                Scaffold.of(context).showSnackBar(SnackBar(
                  content: Text(uid + ' has successfully signed out.'),
                ));
              },
            );
          })
        ],
      ),
      body: Builder(builder: (BuildContext context) {
        return ListView(
          padding: EdgeInsets.all(8),
          scrollDirection: Axis.vertical,
          children: <Widget>[
            Text(uid),
            _EmailPasswordForm(),
          ],
        );
      }),
    );
  }

  // Example code for sign out.
  void _signOut() async {
    await _auth.signOut();
  }
}

class _EmailPasswordForm extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => _EmailPasswordFormState();
}

class _EmailPasswordFormState extends State<_EmailPasswordForm> {
  final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
  final TextEditingController _emailController = TextEditingController();
  final TextEditingController _passwordController = TextEditingController();

  @override
  Widget build(BuildContext context) {
    return Form(
        key: _formKey,
        child: Card(
          child: Padding(
            padding: const EdgeInsets.all(16.0),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Container(
                  child: const Text(
                    'Sign in with email and password',
                    style: TextStyle(fontWeight: FontWeight.bold),
                  ),
                  alignment: Alignment.center,
                ),
                TextFormField(
                  controller: _emailController,
                  decoration: const InputDecoration(labelText: 'Email'),
                  validator: (String value) {
                    if (value.isEmpty) return 'Please enter some text';
                    return null;
                  },
                ),
                TextFormField(
                  controller: _passwordController,
                  decoration: const InputDecoration(labelText: 'Password'),
                  validator: (String value) {
                    if (value.isEmpty) return 'Please enter some text';
                    return null;
                  },
                  obscureText: true,
                ),
                Container(
                  padding: const EdgeInsets.only(top: 16.0),
                  alignment: Alignment.center,
                  child: SignInButton(
                    Buttons.Email,
                    text: "Sign In",
                    onPressed: () async {
                      if (_formKey.currentState.validate()) {
                        _signInWithEmailAndPassword();
                      }
                    },
                  ),
                ),
              ],
            ),
          ),
        ));
  }

  @override
  void dispose() {
    _emailController.dispose();
    _passwordController.dispose();
    super.dispose();
  }

  // Example code of how to sign in with email and password.
  void _signInWithEmailAndPassword() async {
    try {
      final User user = (await _auth.signInWithEmailAndPassword(
        email: _emailController.text,
        password: _passwordController.text,
      ))
          .user;

      Scaffold.of(context).showSnackBar(SnackBar(
        content: Text("${user.email} signed in"),
      ));
    } catch (e) {
      Scaffold.of(context).showSnackBar(SnackBar(
        content: Text("Failed to sign in with Email & Password"),
      ));
    }
  }
}

I was not able to reproduce the bug with the code sample provided by @markusaksli-nc

I will close this issue for now.
Once I find the difference between my codebase and the sample code I will reopen the issue.

Thanks to everyone involved

Was this page helpful?
0 / 5 - 0 ratings