Last active
September 12, 2024 11:50
-
-
Save AliEsmaeil/a1621e6f9471168573c5347b7a0d6b7f to your computer and use it in GitHub Desktop.
how to know whether bottom sheet is open or not through scaffold key?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SignInScreen extends StatelessWidget { | |
static const routeName = '/SignIn'; | |
final ScrollController scrollController = ScrollController(); | |
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>(); | |
SignInScreen({super.key}); | |
@override | |
Widget build(BuildContext context) { | |
return BlocProvider( | |
create: (context) => SignInCubit(), | |
child: BlocConsumer<SignInCubit, SignInStates>( | |
listener: (context, state) { | |
var cubit = SignInCubit.getCubit(context); | |
if(state is SignInSuccessState){ | |
Navigator.of(context).pushNamed(HomeScreen.routeName); | |
} | |
if(state is SignInFailureState){ | |
....................................................... | |
// Here i need to know if any bottom sheet is open or not? | |
....................................................... | |
showSnackBar( | |
context, color: redColor, message: state.failure.errMessage); | |
} | |
if(state is WannaEnterPhoneInForgottenPassword){ | |
scaffoldKey.currentState!.showBottomSheet( | |
(context)=>ForgetPasswordBottomSheet(scaffoldKey : scaffoldKey), | |
showDragHandle: true, | |
backgroundColor: radialColor.withOpacity(1), | |
enableDrag: true, | |
sheetAnimationStyle: AnimationStyle( | |
duration: Duration(seconds: 1), | |
curve: Curves.easeOut, | |
reverseCurve: Curves.easeOut, | |
reverseDuration: const Duration(seconds: 1)), | |
); | |
} | |
}, | |
builder: (context, state) { | |
var cubit = SignInCubit.getCubit(context); | |
return RadialGradientScaffold( | |
scaffoldKey: scaffoldKey, | |
body: Padding( | |
padding: EdgeInsets.symmetric( | |
horizontal: AppStyles.defaultPadding, vertical: MediaQuery | |
.of(context) | |
.padding | |
.top), | |
child: SingleChildScrollView( | |
controller: scrollController, | |
child: Column( | |
children: [ | |
127.verticalSpace, | |
Text( | |
'Welcome Back', | |
style: AppStyles.styleMedium24, | |
), | |
10.verticalSpace, | |
Text( | |
'You can book an appointment, chat with doctors or even make a video call!', | |
textAlign: TextAlign.center, | |
style: AppStyles.styleLight14.copyWith( | |
color: Color(0xff677294), | |
), | |
), | |
LoginSection( | |
scrollController: scrollController, | |
), | |
], | |
), | |
), | |
) | |
); | |
}, | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can you format and share so that it can be used on dartPad, more about this https://github.com/dart-lang/dart-pad/wiki/Sharing-guide