logout function
Implementation
Future<void> logout(BuildContext context) async {
return showInDialog(
context,
contentPadding: EdgeInsets.zero,
builder: (p0) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
Image.asset(logout_image, width: context.width(), fit: BoxFit.cover),
32.height,
Text(language.ohNoYouAreLeaving, style: boldTextStyle(size: 18)),
16.height,
Text(language.doYouWantToLogout, style: secondaryTextStyle()),
28.height,
Row(
children: [
AppButton(
elevation: 0,
onTap: () {
finish(context);
},
color: whiteColor,
shapeBorder: RoundedRectangleBorder(borderRadius: radius(8), side: BorderSide(color: primaryColor)),
child: Text(language.no, style: boldTextStyle()),
).expand(),
16.width,
AppButton(
color: primaryColor,
elevation: 0,
onTap: () async {
finish(context);
if (await isNetworkAvailable()) {
appStore.setLoading(true);
await logoutApi().then((value) async {
toast(value.message);
}).catchError((e) {
log(e.toString());
});
await clearPreferences();
appStore.setLoading(false);
const SignInScreen().launch(context, isNewTask: true, pageRouteAnimation: PageRouteAnimation.Fade);
}
},
child: Text(language.yes, style: boldTextStyle(color: white)),
).expand(),
],
),
],
).paddingSymmetric(horizontal: 16, vertical: 24);
},
);
}