|
|
|
|
|
|
|
|
import 'package:farm_tpf/authentication/authentication.dart'; |
|
|
import 'package:farm_tpf/authentication/authentication.dart'; |
|
|
|
|
|
import 'package:farm_tpf/data/repository/user_repository.dart'; |
|
|
import 'package:farm_tpf/presentation/screens/notification/sc_notification.dart'; |
|
|
import 'package:farm_tpf/presentation/screens/notification/sc_notification.dart'; |
|
|
import 'package:farm_tpf/presentation/screens/profile/sc_update_profile.dart'; |
|
|
import 'package:farm_tpf/presentation/screens/profile/sc_update_profile.dart'; |
|
|
import 'package:farm_tpf/utils/const_color.dart'; |
|
|
import 'package:farm_tpf/utils/const_color.dart'; |
|
|
|
|
|
import 'package:farm_tpf/utils/pref.dart'; |
|
|
import 'package:flutter/material.dart'; |
|
|
import 'package:flutter/material.dart'; |
|
|
import 'package:flutter_bloc/flutter_bloc.dart'; |
|
|
import 'package:flutter_bloc/flutter_bloc.dart'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
class _HomeDrawerState extends State<HomeDrawer> { |
|
|
class _HomeDrawerState extends State<HomeDrawer> { |
|
|
|
|
|
var pref = LocalPref(); |
|
|
|
|
|
UserRepository _userRepository = UserRepository(); |
|
|
List<DrawerList> drawerList; |
|
|
List<DrawerList> drawerList; |
|
|
@override |
|
|
@override |
|
|
void initState() { |
|
|
void initState() { |
|
|
|
|
|
|
|
|
widget.callBackIndex(indexScreen); |
|
|
widget.callBackIndex(indexScreen); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
_clickSignOut() { |
|
|
|
|
|
|
|
|
_clickSignOut() async { |
|
|
context.bloc<AuthenticationBloc>().add(AuthenticationLogoutRequested()); |
|
|
context.bloc<AuthenticationBloc>().add(AuthenticationLogoutRequested()); |
|
|
|
|
|
try { |
|
|
|
|
|
String pushKey = await pref.getString(DATA_CONST.PUSH_KEY); |
|
|
|
|
|
if (pushKey.isNotEmpty) { |
|
|
|
|
|
_userRepository |
|
|
|
|
|
.deleteFcmToken(pushKey) |
|
|
|
|
|
.then((value) {}) |
|
|
|
|
|
.catchError((err) {}) |
|
|
|
|
|
.whenComplete(() { |
|
|
|
|
|
pref.saveString(DATA_CONST.TOKEN_KEY, ""); |
|
|
|
|
|
pref.saveString(DATA_CONST.PUSH_KEY, ""); |
|
|
|
|
|
pref.saveString(DATA_CONST.CURRENT_FULL_NAME, ""); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
pref.saveString(DATA_CONST.CURRENT_FULL_NAME, ""); |
|
|
|
|
|
pref.saveString(DATA_CONST.TOKEN_KEY, ""); |
|
|
|
|
|
pref.saveString(DATA_CONST.PUSH_KEY, ""); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|