diff --git a/lib/presentation/common_widgets/drawer/drawer_widget.dart b/lib/presentation/common_widgets/drawer/drawer_widget.dart index 4c58c1c..2235831 100644 --- a/lib/presentation/common_widgets/drawer/drawer_widget.dart +++ b/lib/presentation/common_widgets/drawer/drawer_widget.dart @@ -3,8 +3,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc_advance/configuration/app_key_constants.dart'; import 'package:flutter_bloc_advance/configuration/local_storage.dart'; +import 'package:flutter_bloc_advance/routes/app_router.dart'; import 'package:flutter_bloc_advance/routes/app_routes_constants.dart'; -import 'package:go_router/go_router.dart'; import 'package:string_2_icon/string_2_icon.dart'; import '../../../generated/l10n.dart'; @@ -72,7 +72,7 @@ class ApplicationDrawer extends StatelessWidget { ), onTap: () { Navigator.pop(context); - context.go(childMenu.url); + AppRouter().push(context, childMenu.url); }, ); }).toList(), @@ -104,7 +104,7 @@ class ApplicationDrawer extends StatelessWidget { listener: (context, state) { if (state.isLogout) { context.read().add(Logout()); - context.go(ApplicationRoutesConstants.login); + AppRouter().push(context, ApplicationRoutesConstants.login); } }, ), @@ -112,7 +112,7 @@ class ApplicationDrawer extends StatelessWidget { listener: (context, state) { if (state.status == AccountStatus.failure) { context.read().add(Logout()); - context.go(ApplicationRoutesConstants.login); + AppRouter().push(context, ApplicationRoutesConstants.login); } }, ), @@ -146,7 +146,7 @@ class ApplicationDrawer extends StatelessWidget { void onLogout(context) { BlocProvider.of(context).add(Logout()); Navigator.pop(context); - context.go(ApplicationRoutesConstants.login); + AppRouter().push(context, ApplicationRoutesConstants.login); } void onCancel(context) { @@ -221,7 +221,7 @@ class LanguageSwitchButtonState extends State { await S.load(Locale(isTurkish ? 'tr' : 'en')); if (mounted) { setState( - () => context.go(ApplicationRoutesConstants.home), + () => AppRouter().push(context, ApplicationRoutesConstants.home), ); } }, diff --git a/lib/presentation/screen/login/login_screen.dart b/lib/presentation/screen/login/login_screen.dart index 8f23b55..8a80065 100644 --- a/lib/presentation/screen/login/login_screen.dart +++ b/lib/presentation/screen/login/login_screen.dart @@ -7,7 +7,6 @@ import 'package:flutter_bloc_advance/routes/app_routes_constants.dart'; import 'package:flutter_bloc_advance/utils/app_constants.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart'; import 'package:form_builder_validators/form_builder_validators.dart'; -import 'package:go_router/go_router.dart'; import '../../../generated/l10n.dart'; import 'bloc/login.dart'; @@ -128,17 +127,29 @@ class LoginScreen extends StatelessWidget { debugPrint("BEGIN: login submit button listener ${state.username}"); if (state is LoginLoadingState) { - ScaffoldMessenger.of(_scaffoldKey.currentContext!).showSnackBar(SnackBar(behavior: SnackBarBehavior.floating, content: Text(S.of(context).loading), backgroundColor: Theme.of(context).colorScheme.primary, width: MediaQuery.of(context).size.width* 0.8)); + ScaffoldMessenger.of(_scaffoldKey.currentContext!).showSnackBar(SnackBar( + behavior: SnackBarBehavior.floating, + content: Text(S.of(context).loading), + backgroundColor: Theme.of(context).colorScheme.primary, + width: MediaQuery.of(context).size.width * 0.8)); } else if (state is LoginLoadedState) { debugPrint("BEGIN: login submit button listener LoginLoadedState"); AppRouter().push(context, ApplicationRoutesConstants.home); ScaffoldMessenger.of(_scaffoldKey.currentContext!).hideCurrentSnackBar(); - ScaffoldMessenger.of(_scaffoldKey.currentContext!).showSnackBar(SnackBar(behavior: SnackBarBehavior.floating,content: Text(S.of(context).success), backgroundColor: Theme.of(context).colorScheme.primary, width: MediaQuery.of(context).size.width* 0.8)); + ScaffoldMessenger.of(_scaffoldKey.currentContext!).showSnackBar(SnackBar( + behavior: SnackBarBehavior.floating, + content: Text(S.of(context).success), + backgroundColor: Theme.of(context).colorScheme.primary, + width: MediaQuery.of(context).size.width * 0.8)); debugPrint("END: login submit button listener LoginLoadedState"); } else if (state is LoginErrorState) { debugPrint("BEGIN: login submit button listener LoginErrorState"); ScaffoldMessenger.of(_scaffoldKey.currentContext!).hideCurrentSnackBar(); - ScaffoldMessenger.of(_scaffoldKey.currentContext!).showSnackBar(SnackBar(behavior: SnackBarBehavior.floating,content: Text(S.of(context).failed), backgroundColor: Theme.of(context).colorScheme.primary, width: MediaQuery.of(context).size.width* 0.8)); + ScaffoldMessenger.of(_scaffoldKey.currentContext!).showSnackBar(SnackBar( + behavior: SnackBarBehavior.floating, + content: Text(S.of(context).failed), + backgroundColor: Theme.of(context).colorScheme.primary, + width: MediaQuery.of(context).size.width * 0.8)); debugPrint("END: login submit button listener LoginErrorState"); } }, @@ -166,7 +177,7 @@ class LoginScreen extends StatelessWidget { return SizedBox( child: TextButton( key: loginButtonForgotPasswordKey, - onPressed: () => context.go(ApplicationRoutesConstants.forgotPassword), + onPressed: () => AppRouter().push(context, ApplicationRoutesConstants.forgotPassword), child: Text(S.of(context).password_forgot), ), ); @@ -176,7 +187,7 @@ class LoginScreen extends StatelessWidget { return SizedBox( child: TextButton( key: loginButtonRegisterKey, - onPressed: () => context.go(ApplicationRoutesConstants.register), + onPressed: () => AppRouter().push(context, ApplicationRoutesConstants.register), child: Text(S.of(context).register), ), );