the whole purpose of this is that i want to signout the current user using app, immediately when i open firebase console and delete his account from Authentication tab.
i want the signout process to be done smoothly without any errors.
what i've tried so far:
in my main function():
runApp(MyApp());
and this is myApp class:
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MultiProvider(
providers: [
Provider<AuthService>(
create: (_) => AuthService(),
),
StreamProvider(
create: (context) => context.read<AuthService>().onAuthStateChanged,
),
],
child: MaterialApp(
debugShowCheckedModeBanner: false,
routes: <String, WidgetBuilder>{
'/home': (BuildContext context) => HomeController(),
'/signUp': (BuildContext context) => SignUpView(
authFormType: AuthFormType.signUp,
),
'/signIn': (BuildContext context) => SignUpView(
authFormType: AuthFormType.signIn,
),
'/addGig': (BuildContext context) => Home(passedSelectedIndex: 1),
},
home: HomeController(),
));
}
}
and this is the HomeController():
class _HomeControllerState extends State<HomeController> {
AuthService authService = locator.get<AuthService>();
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
final firebaseUserUid = context.watch<String>();
if (firebaseUserUid != null) {
return HomePage();
return MaterialApp(
debugShowCheckedModeBanner: false,
routes: <String, WidgetBuilder>{
'/home': (BuildContext context) => HomeController(),
'/signUp': (BuildContext context) => SignUpView(
authFormType: AuthFormType.signUp,
),
'/signIn': (BuildContext context) => SignUpView(
authFormType: AuthFormType.signIn,
),
'/addGig': (BuildContext context) => Home(passedSelectedIndex: 1),
},
theme: fyreworkTheme(),
builder: EasyLoading.init(),
home: Home(passedSelectedIndex: 0),
);
} else {
return StartPage();
}
}
}
in the build function of MyApp class, the provider is listening to this stream from the AuthService class:
Stream<String> get onAuthStateChanged => _firebaseAuth.onAuthStateChanged.map(
(FirebaseUser user) => user?.uid,
);
so far so good...when i start or restart the App...every thing works as intended...no probs.
what i wanted to achieve is that if i open the firebase console / Authentication tab and i know the identifier of a specific user i want to delete his account and i delete it.
i thought that would signout that user from the app and navigates him to StartPage()..as the whole app is listening to onAuthStateChanged
stream from the Provider.
but that didn't achieve what i was trying to do.
how can i sign out a specific user from the App after i delete his data from Authentication tab in firebase console ?
i hope i've described the problem and the desired goal well....
any help would be much appreciated.