0
votes

I have been trying to show this alert message in column within safearea. I have to show this message as error message, where initially errormessage is string with null value. The error message appears successfully in terminal but not getting on screen.

 try {

SharedPreferences prefs = await SharedPreferences.getInstance();

  FirebaseAuth _auth = FirebaseAuth.instance;
  _auth
      .signInWithEmailAndPassword(
          email: username + '@mail.com', password: password)
      .then((log) {

    var key = prefs.setString('key', username);
    Navigator.pushAndRemoveUntil(
        context,
        MaterialPageRoute(builder: (BuildContext context) => Mails()),
        (Route<dynamic> route) => false);
  });
} catch (e) {
  showDialog(context: context, builder: (context) => Dialog(child: Text(e.toString()),));
  
  print('This is what we got ${e.message}');
}

here is my debug console

E/flutter ( 3195): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] 
Unhandled Exception: PlatformException(ERROR_USER_NOT_FOUND, There 
is no user record corresponding to this identifier. The user may 
have been deleted., null)
[38;5;244mE/flutter ( 3195): #0      
StandardMethodCodec.decodeEnvelope[39;49m
[38;5;244mE/flutter ( 3195): #1      
MethodChannel.invokeMethod[39;49m
E/flutter ( 3195): <asynchronous suspension>
[38;5;244mE/flutter ( 3195): #2       
MethodChannel.invokeMapMethod[39;49m
[38;5;248mE/flutter ( 3195): #3      
FirebaseAuth.signInWithCredential[39;49m
[38;5;248mE/flutter ( 3195): #4      
FirebaseAuth.signInWithEmailAndPassword[39;49m
[38;5;248mE/flutter ( 3195): #5      _LoginState.loginuser[39;49m
[38;5;244mE/flutter ( 3195): #6      _asyncThenWrapperHelper. 

(dart:async- patch/async_patch.dart:73:64)[39;49m [38;5;244mE/flutter ( 3195): #7 _rootRunUnary (dart:async/zone.dart:1134:38)[39;49m [38;5;244mE/flutter ( 3195): #8 _CustomZone.runUnary (dart:async/zone.dart:1031:19)[39;49m [38;5;244mE/flutter ( 3195): #9 _FutureListener.handleValue (dart:async/future_impl.dart:139:18)[39;49m [38;5;244mE/flutter ( 3195): #10 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:680:45)[39;49m [38;5;244mE/flutter ( 3195): #11 Future._propagateToListeners (dart:async/future_impl.dart:709:32)[39;49m [38;5;244mE/flutter ( 3195): #12 Future._addListener. (dart:async/future_impl.dart:389:9)[39;49m [38;5;244mE/flutter ( 3195): #13 _rootRun (dart:async/zone.dart:1126:13)[39;49m [38;5;244mE/flutter ( 3195): #14 _CustomZone.run (dart:async/zone.dart:1023:19)[39;49m [38;5;244mE/flutter ( 3195): #15 _CustomZone.runGuarded (dart:async/zone.dart:925:7)[39;49m [38;5;244mE/flutter ( 3195): #16 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:965:23)[39;49m [38;5;244mE/flutter ( 3195): #17 _microtaskLoop (dart:async/schedule_microtask.dart:43:21)[39;49m [38;5;244mE/flutter ( 3195): #18 _startMicrotaskLoop (dart:async/schedule_microtask.dart:52:5)[39;49m E/flutter ( 3195):

1

1 Answers

0
votes

do this

catch(e){
  showDialog(
    context: context,
    builder: (context) => Dialog(child: Container(..<What you want to show>...)); );
}

you dont need setState