forked from eatvio/eatvio_app
refactor(token): add token storage, remove hive
This commit is contained in:
@@ -12,6 +12,4 @@ export 'package:eatvio_app/theme/custom_text_style.dart';
|
||||
export 'package:eatvio_app/theme/theme_helper.dart';
|
||||
export 'package:eatvio_app/widgets/custom_image_view.dart';
|
||||
export 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
export '../theme/bloc/theme_bloc.dart';
|
||||
export '../theme/custom_button_style.dart';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:eatvio_app/locator_service.dart';
|
||||
import 'package:hive_flutter/hive_flutter.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
|
||||
abstract class TokenStorage {
|
||||
static _addTokenToDioHeader(String token) {
|
||||
@@ -8,22 +8,20 @@ abstract class TokenStorage {
|
||||
}
|
||||
|
||||
static haveTokenInStorage() async {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
if (await FlutterSecureStorage().read(key: 'token') == null) {
|
||||
return false;
|
||||
} else {
|
||||
_addTokenToDioHeader(token);
|
||||
_addTokenToDioHeader((await FlutterSecureStorage().read(key: 'token'))!);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static Future<String> getTokenFromStorage() async => (await Hive.openBox('token')).get('token');
|
||||
static Future<String> getTokenFromStorage() async => (await FlutterSecureStorage().read(key: 'token'))!;
|
||||
|
||||
static saveTokenInStorage(String token) async {
|
||||
(await Hive.openBox('token')).put('token', token);
|
||||
await FlutterSecureStorage().write(key: 'token', value: token);
|
||||
_addTokenToDioHeader(token);
|
||||
}
|
||||
|
||||
static removeTokenInStorage() async => (await Hive.openBox('token')).delete('token');
|
||||
static removeTokenInStorage() async => (await FlutterSecureStorage().delete(key: 'token'));
|
||||
}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class PrefUtils {
|
||||
static SharedPreferences? _sharedPreferences;
|
||||
|
||||
PrefUtils() {
|
||||
// init();
|
||||
SharedPreferences.getInstance().then((value) {
|
||||
_sharedPreferences = value;
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> init() async {
|
||||
_sharedPreferences ??= await SharedPreferences.getInstance();
|
||||
print('SharedPreference Initialized');
|
||||
}
|
||||
|
||||
///will clear all the data stored in preference
|
||||
void clearPreferencesData() async {
|
||||
_sharedPreferences!.clear();
|
||||
}
|
||||
|
||||
Future<void> setThemeData(String value) {
|
||||
return _sharedPreferences!.setString('themeData', value);
|
||||
}
|
||||
|
||||
String getThemeData() {
|
||||
try {
|
||||
return _sharedPreferences!.getString('themeData')!;
|
||||
} catch (e) {
|
||||
return 'primary';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
import 'package:hive/hive.dart';
|
||||
|
||||
/// https://pub.dev/packages/flutter_secure_storage TODO replace hive to secure_storage for token storage
|
||||
@HiveType(typeId: 0)
|
||||
class TokenModel {
|
||||
@HiveField(0)
|
||||
String token;
|
||||
|
||||
TokenModel({required this.token});
|
||||
}
|
||||
@@ -17,11 +17,8 @@ import 'package:eatvio_app/presentation/profile/my_profile_screen/models/my_prof
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:hive_flutter/hive_flutter.dart';
|
||||
import 'package:intl/date_symbol_data_local.dart';
|
||||
import 'package:keyboard_dismisser/keyboard_dismisser.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
import 'core/app_export.dart';
|
||||
|
||||
var globalMessengerKey = GlobalKey<ScaffoldMessengerState>();
|
||||
@@ -29,15 +26,11 @@ var globalMessengerKey = GlobalKey<ScaffoldMessengerState>();
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
await di.init();
|
||||
final appDocumentDir = await getApplicationDocumentsDirectory();
|
||||
final path = appDocumentDir.path;
|
||||
await Hive.initFlutter(path);
|
||||
SystemChrome.setPreferredOrientations([
|
||||
DeviceOrientation.landscapeLeft,
|
||||
DeviceOrientation.landscapeRight,
|
||||
DeviceOrientation.portraitUp,
|
||||
]);
|
||||
await PrefUtils().init();
|
||||
initializeDateFormatting().then((_) => runApp(MyApp()));
|
||||
}
|
||||
|
||||
@@ -49,7 +42,6 @@ class MyApp extends StatelessWidget {
|
||||
BlocProvider<InitializationCubit>(create: (context) => sl<InitializationCubit>()),
|
||||
BlocProvider<NewMessagesCubit>(create: (context) => sl<NewMessagesCubit>()),
|
||||
BlocProvider<NotificationsCubit>(create: (context) => sl<NotificationsCubit>()),
|
||||
BlocProvider<ThemeBloc>(create: (context) => ThemeBloc(ThemeState(themeType: PrefUtils().getThemeData()))),
|
||||
BlocProvider<FeedCubit>(create: (context) => sl<FeedCubit>()..loadFeedBlogPostList()),
|
||||
BlocProvider<RecipesCubit>(create: (context) => sl<RecipesCubit>()..loadRecipesList()),
|
||||
BlocProvider<DietsCubit>(create: (context) => sl<DietsCubit>()..loadDiets()),
|
||||
@@ -61,31 +53,27 @@ class MyApp extends StatelessWidget {
|
||||
],
|
||||
child: BlocListener<InitializationCubit, InitializationState>(
|
||||
listener: (BuildContext context, InitializationState state) {},
|
||||
child: BlocBuilder<ThemeBloc, ThemeState>(
|
||||
builder: (context, state) {
|
||||
return KeyboardDismisser(
|
||||
gestures: [
|
||||
GestureType.onTap,
|
||||
GestureType.onPanUpdateDownDirection,
|
||||
],
|
||||
child: MaterialApp.router(
|
||||
theme: theme,
|
||||
routerConfig: AppRouter.appRouter,
|
||||
debugShowCheckedModeBanner: false,
|
||||
localizationsDelegates: [
|
||||
AppLocalizationDelegate(),
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: [
|
||||
Locale(
|
||||
'ru',
|
||||
),
|
||||
],
|
||||
child: KeyboardDismisser(
|
||||
gestures: [
|
||||
GestureType.onTap,
|
||||
GestureType.onPanUpdateDownDirection,
|
||||
],
|
||||
child: MaterialApp.router(
|
||||
theme: theme,
|
||||
routerConfig: AppRouter.appRouter,
|
||||
debugShowCheckedModeBanner: false,
|
||||
localizationsDelegates: [
|
||||
AppLocalizationDelegate(),
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: [
|
||||
Locale(
|
||||
'ru',
|
||||
),
|
||||
);
|
||||
},
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -6,7 +6,6 @@ import 'package:eatvio_app/widgets/app_bar/appbar_title_image.dart';
|
||||
import 'package:eatvio_app/widgets/custom_text_form_field.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:validators/validators.dart';
|
||||
@@ -167,9 +166,7 @@ class _AuthScreenState extends State<AuthScreen> {
|
||||
print(response.statusCode);
|
||||
if (response.statusCode == 200) {
|
||||
var res = await jsonDecode(response.body);
|
||||
final box = await Hive.openBox('token');
|
||||
final token = res['token'];
|
||||
box.put('token', token);
|
||||
await TokenStorage.saveTokenInStorage(token);
|
||||
GoRouter.of(context).go('/my-profile-screen');
|
||||
} else {
|
||||
|
||||
@@ -2,11 +2,11 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:eatvio_app/app_router.dart';
|
||||
import 'package:eatvio_app/core/token_storage.dart';
|
||||
import 'package:eatvio_app/presentation/diets/diet_create_screen/models/diet_create_model.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import '/core/app_export.dart';
|
||||
@@ -25,9 +25,7 @@ class DietCreateBloc extends Bloc<DietCreateEvent, DietCreateState> {
|
||||
DietCreateInitialEvent event,
|
||||
Emitter<DietCreateState> emit,
|
||||
) async {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
if (!await TokenStorage.haveTokenInStorage()) {
|
||||
AppRouter.navigatorKey.currentContext?.goNamed('authScreen');
|
||||
}
|
||||
if (state is DietCreateLoadedState) {
|
||||
|
||||
@@ -2,11 +2,11 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:eatvio_app/app_router.dart';
|
||||
import 'package:eatvio_app/core/token_storage.dart';
|
||||
import 'package:eatvio_app/presentation/diets/diet_edit_screen/models/diet_edit_model.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import '/core/app_export.dart';
|
||||
@@ -26,16 +26,14 @@ class DietEditBloc extends Bloc<DietEditEvent, DietEditState> {
|
||||
Emitter<DietEditState> emit,
|
||||
) async {
|
||||
try {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
if (!await TokenStorage.haveTokenInStorage()) {
|
||||
AppRouter.navigatorKey.currentContext?.goNamed('authScreen');
|
||||
}
|
||||
final String? dietID = state.dietModelObj?.dietID;
|
||||
final response = await http.get(
|
||||
Uri.parse(baseUrl + '/api/diets/show/$dietID'),
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token',
|
||||
'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}',
|
||||
},
|
||||
);
|
||||
if (response.statusCode == 200) {
|
||||
|
||||
@@ -3,11 +3,11 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:eatvio_app/app_router.dart';
|
||||
import 'package:eatvio_app/core/token_storage.dart';
|
||||
import 'package:eatvio_app/presentation/diets/diet_select_screen/models/diet_select_model.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
|
||||
@@ -27,15 +27,13 @@ class DietSelectBloc extends Bloc<DietSelectEvent, DietSelectState> {
|
||||
Emitter<DietSelectState> emit,
|
||||
) async {
|
||||
try {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
if (!await TokenStorage.haveTokenInStorage()) {
|
||||
AppRouter.navigatorKey.currentContext?.goNamed('authScreen');
|
||||
}
|
||||
final response = await http.get(
|
||||
Uri.parse(baseUrl + '/api/diets/index'),
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token',
|
||||
'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}',
|
||||
},
|
||||
);
|
||||
print('Got response');
|
||||
|
||||
@@ -2,11 +2,11 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:eatvio_app/app_router.dart';
|
||||
import 'package:eatvio_app/core/token_storage.dart';
|
||||
import 'package:eatvio_app/presentation/diets/diet_show_screen/models/diet_show_model.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import '/core/app_export.dart';
|
||||
@@ -26,16 +26,14 @@ class DietBloc extends Bloc<DietEvent, DietState> {
|
||||
Emitter<DietState> emit,
|
||||
) async {
|
||||
try {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
if (!await TokenStorage.haveTokenInStorage()) {
|
||||
AppRouter.navigatorKey.currentContext?.goNamed('authScreen');
|
||||
}
|
||||
final String? dietID = state.dietModelObj?.dietID;
|
||||
final response = await http.get(
|
||||
Uri.parse(baseUrl + '/api/diets/show/$dietID'),
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token',
|
||||
'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}',
|
||||
},
|
||||
);
|
||||
if (response.statusCode == 200) {
|
||||
@@ -62,16 +60,14 @@ class DietBloc extends Bloc<DietEvent, DietState> {
|
||||
}
|
||||
|
||||
FutureOr<void> _deleteEntry(DeleteEntry event, Emitter<DietState> emit) async {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
if (!await TokenStorage.haveTokenInStorage()) {
|
||||
AppRouter.navigatorKey.currentContext?.goNamed('authScreen');
|
||||
}
|
||||
final int id = event.id;
|
||||
final response = await http.post(
|
||||
Uri.parse(baseUrl + '/api/diets/delete/$id'),
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token',
|
||||
'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}',
|
||||
},
|
||||
);
|
||||
if (response.statusCode == 200) {
|
||||
|
||||
@@ -2,12 +2,12 @@ import 'dart:async';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:eatvio_app/app_router.dart';
|
||||
import 'package:eatvio_app/core/token_storage.dart';
|
||||
import 'package:eatvio_app/locator_service.dart';
|
||||
import 'package:eatvio_app/presentation/feed/blog_post_create_screen/models/blog_post_create_model.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
|
||||
import '/core/app_export.dart';
|
||||
@@ -27,9 +27,7 @@ class BlogPostCreateBloc extends Bloc<BlogPostCreateEvent, BlogPostCreateState>
|
||||
BlogPostCreateInitialEvent event,
|
||||
Emitter<BlogPostCreateState> emit,
|
||||
) async {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
if (!await TokenStorage.haveTokenInStorage()) {
|
||||
AppRouter.navigatorKey.currentContext?.goNamed('authScreen');
|
||||
}
|
||||
if (state is BlogPostCreateLoadedState) {
|
||||
@@ -46,7 +44,7 @@ class BlogPostCreateBloc extends Bloc<BlogPostCreateEvent, BlogPostCreateState>
|
||||
} else {
|
||||
emit(
|
||||
BlogPostCreateLoadedState(
|
||||
token: token,
|
||||
token: await TokenStorage.getTokenFromStorage(),
|
||||
title: TextEditingController(),
|
||||
description: TextEditingController(),
|
||||
youtubeURL: TextEditingController(),
|
||||
|
||||
@@ -2,11 +2,11 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:eatvio_app/app_router.dart';
|
||||
import 'package:eatvio_app/core/token_storage.dart';
|
||||
import 'package:eatvio_app/presentation/feed/blog_post_edit_screen/models/blog_post_edit_model.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import '/core/app_export.dart';
|
||||
@@ -26,16 +26,14 @@ class BlogPostEditBloc extends Bloc<BlogPostEditEvent, BlogPostEditState> {
|
||||
Emitter<BlogPostEditState> emit,
|
||||
) async {
|
||||
try {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
if (!await TokenStorage.haveTokenInStorage()) {
|
||||
AppRouter.navigatorKey.currentContext?.goNamed('authScreen');
|
||||
}
|
||||
final String? blog_postID = state.blog_postModelObj?.blog_postID;
|
||||
final response = await http.get(
|
||||
Uri.parse(baseUrl + '/api/blogPosts/show/$blog_postID'),
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token',
|
||||
'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}',
|
||||
},
|
||||
);
|
||||
if (response.statusCode == 200) {
|
||||
|
||||
@@ -2,11 +2,11 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:eatvio_app/app_router.dart';
|
||||
import 'package:eatvio_app/core/token_storage.dart';
|
||||
import 'package:eatvio_app/presentation/glossary/glossary_screen/models/glossary_screen_model.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import '/core/app_export.dart';
|
||||
@@ -26,15 +26,13 @@ class GlossaryBloc extends Bloc<GlossaryEvent, GlossaryState> {
|
||||
Emitter<GlossaryState> emit,
|
||||
) async {
|
||||
try {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
if (!await TokenStorage.haveTokenInStorage()) {
|
||||
AppRouter.navigatorKey.currentContext?.goNamed('authScreen');
|
||||
}
|
||||
final responseProductGroups = await http.get(
|
||||
Uri.parse(baseUrl + '/api/glossaries/group/index'),
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token',
|
||||
'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}',
|
||||
},
|
||||
);
|
||||
if (responseProductGroups.statusCode == 200) {
|
||||
@@ -54,12 +52,12 @@ class GlossaryBloc extends Bloc<GlossaryEvent, GlossaryState> {
|
||||
List<SelectionPopupModel> productGroupsModel = _fillProductGroups(dataProductGroups);
|
||||
emit(
|
||||
GlossaryLoadedState(
|
||||
token: token,
|
||||
token: await TokenStorage.getTokenFromStorage(),
|
||||
productGroups: productGroupsModel,
|
||||
productList: [],
|
||||
),
|
||||
);
|
||||
await _getProductListById(token, emit, productGroupsModel[0].id);
|
||||
await _getProductListById(await TokenStorage.getTokenFromStorage(), emit, productGroupsModel[0].id);
|
||||
}
|
||||
} else {
|
||||
// Один или несколько ключевых полей отсутствуют, обрабатываем ошибку
|
||||
|
||||
@@ -2,11 +2,11 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:eatvio_app/app_router.dart';
|
||||
import 'package:eatvio_app/core/token_storage.dart';
|
||||
import 'package:eatvio_app/presentation/plans/plan_create_screen/models/plan_create_model.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import '/core/app_export.dart';
|
||||
@@ -25,9 +25,7 @@ class PlanCreateBloc extends Bloc<PlanCreateEvent, PlanCreateState> {
|
||||
PlanCreateInitialEvent event,
|
||||
Emitter<PlanCreateState> emit,
|
||||
) async {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
if (!await TokenStorage.haveTokenInStorage()) {
|
||||
AppRouter.navigatorKey.currentContext?.goNamed('authScreen');
|
||||
}
|
||||
if (state is PlanCreateLoadedState) {
|
||||
|
||||
@@ -2,11 +2,11 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:eatvio_app/app_router.dart';
|
||||
import 'package:eatvio_app/core/token_storage.dart';
|
||||
import 'package:eatvio_app/presentation/plans/plan_edit_screen/models/plan_edit_model.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import '/core/app_export.dart';
|
||||
@@ -26,16 +26,14 @@ class PlanEditBloc extends Bloc<PlanEditEvent, PlanEditState> {
|
||||
Emitter<PlanEditState> emit,
|
||||
) async {
|
||||
try {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
if (!await TokenStorage.haveTokenInStorage()) {
|
||||
AppRouter.navigatorKey.currentContext?.goNamed('authScreen');
|
||||
}
|
||||
final String? planID = state.planModelObj?.planID;
|
||||
final response = await http.get(
|
||||
Uri.parse(baseUrl + '/api/plans/show/$planID'),
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token',
|
||||
'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}',
|
||||
},
|
||||
);
|
||||
if (response.statusCode == 200) {
|
||||
|
||||
@@ -3,11 +3,11 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:eatvio_app/app_router.dart';
|
||||
import 'package:eatvio_app/core/token_storage.dart';
|
||||
import 'package:eatvio_app/presentation/plans/plan_select_screen/models/plan_select_model.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
|
||||
@@ -27,9 +27,7 @@ class PlanSelectBloc extends Bloc<PlanSelectEvent, PlanSelectState> {
|
||||
Emitter<PlanSelectState> emit,
|
||||
) async {
|
||||
try {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
if (!await TokenStorage.haveTokenInStorage()) {
|
||||
AppRouter.navigatorKey.currentContext?.goNamed('authScreen');
|
||||
}
|
||||
final response = await http.get(
|
||||
|
||||
@@ -2,11 +2,11 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:eatvio_app/app_router.dart';
|
||||
import 'package:eatvio_app/core/token_storage.dart';
|
||||
import 'package:eatvio_app/presentation/plans/plan_show_screen/models/plan_show_model.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import '/core/app_export.dart';
|
||||
@@ -26,16 +26,14 @@ class PlanBloc extends Bloc<PlanEvent, PlanState> {
|
||||
Emitter<PlanState> emit,
|
||||
) async {
|
||||
try {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
if (!await TokenStorage.haveTokenInStorage()) {
|
||||
AppRouter.navigatorKey.currentContext?.goNamed('authScreen');
|
||||
}
|
||||
final String? planID = state.planModelObj?.planID;
|
||||
final response = await http.get(
|
||||
Uri.parse(baseUrl + '/api/plans/show/$planID'),
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token',
|
||||
'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}',
|
||||
},
|
||||
);
|
||||
if (response.statusCode == 200) {
|
||||
@@ -62,16 +60,14 @@ class PlanBloc extends Bloc<PlanEvent, PlanState> {
|
||||
}
|
||||
|
||||
FutureOr<void> _deleteEntry(DeleteEntry event, Emitter<PlanState> emit) async {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
if (!await TokenStorage.haveTokenInStorage()) {
|
||||
AppRouter.navigatorKey.currentContext?.goNamed('authScreen');
|
||||
}
|
||||
final int id = event.id;
|
||||
final response = await http.post(
|
||||
Uri.parse(baseUrl + '/api/plans/delete/$id'),
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token',
|
||||
'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}',
|
||||
},
|
||||
);
|
||||
if (response.statusCode == 200) {
|
||||
|
||||
@@ -3,11 +3,11 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:eatvio_app/app_router.dart';
|
||||
import 'package:eatvio_app/core/token_storage.dart';
|
||||
import 'package:eatvio_app/presentation/profile/my_profile_screen/models/my_profile_model.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
|
||||
@@ -28,9 +28,7 @@ class MyProfileBloc extends Bloc<MyProfileEvent, MyProfileState> {
|
||||
Emitter<MyProfileState> emit,
|
||||
) async {
|
||||
try {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
if (!await TokenStorage.haveTokenInStorage()) {
|
||||
AppRouter.navigatorKey.currentContext?.goNamed('authScreen');
|
||||
}
|
||||
//final token =
|
||||
@@ -38,7 +36,7 @@ class MyProfileBloc extends Bloc<MyProfileEvent, MyProfileState> {
|
||||
final response = await http.get(
|
||||
Uri.parse(baseUrl + '/api/profile/index'),
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token',
|
||||
'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}',
|
||||
},
|
||||
);
|
||||
if (response.statusCode == 200) {
|
||||
@@ -48,10 +46,6 @@ class MyProfileBloc extends Bloc<MyProfileEvent, MyProfileState> {
|
||||
data.containsKey('userDetails') &&
|
||||
data.containsKey('chartPoints') &&
|
||||
data.containsKey('circumferences')) {
|
||||
final avatarBox = await Hive.openBox('avatar');
|
||||
final avatar = data['user']['profile_photo_path'];
|
||||
print(avatar);
|
||||
avatarBox.put('avatar', avatar);
|
||||
if (state is MyProfileLoadedState) {
|
||||
var currentState = state as MyProfileLoadedState;
|
||||
var plans = []
|
||||
@@ -69,7 +63,7 @@ class MyProfileBloc extends Bloc<MyProfileEvent, MyProfileState> {
|
||||
user: data['user'],
|
||||
userDetails: data['userDetails'],
|
||||
plans: plans,
|
||||
token: token,
|
||||
token: await TokenStorage.getTokenFromStorage(),
|
||||
chestCircumferenceController: TextEditingController(),
|
||||
waistCircumferenceController: TextEditingController(),
|
||||
hipCircumferenceController: TextEditingController(),
|
||||
@@ -172,7 +166,7 @@ class MyProfileBloc extends Bloc<MyProfileEvent, MyProfileState> {
|
||||
user: data['user'],
|
||||
userDetails: data['userDetails'],
|
||||
plans: plans,
|
||||
token: token,
|
||||
token: await TokenStorage.getTokenFromStorage(),
|
||||
chestCircumferenceController: TextEditingController(),
|
||||
waistCircumferenceController: TextEditingController(),
|
||||
hipCircumferenceController: TextEditingController(),
|
||||
|
||||
@@ -2,11 +2,11 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:eatvio_app/app_router.dart';
|
||||
import 'package:eatvio_app/core/token_storage.dart';
|
||||
import 'package:eatvio_app/presentation/recipe/recipe_edit_screen/models/recipe_edit_model.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import '/core/app_export.dart';
|
||||
@@ -29,16 +29,14 @@ class RecipeEditBloc extends Bloc<RecipeEditEvent, RecipeEditState> {
|
||||
Emitter<RecipeEditState> emit,
|
||||
) async {
|
||||
try {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
if (!await TokenStorage.haveTokenInStorage()) {
|
||||
AppRouter.navigatorKey.currentContext?.goNamed('authScreen');
|
||||
}
|
||||
final String? recipeID = state.recipeModelObj?.recipeID;
|
||||
final response = await http.get(
|
||||
Uri.parse(baseUrl + '/api/recipes/show/$recipeID'),
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token',
|
||||
'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}',
|
||||
},
|
||||
);
|
||||
if (response.statusCode == 200) {
|
||||
@@ -79,7 +77,7 @@ class RecipeEditBloc extends Bloc<RecipeEditEvent, RecipeEditState> {
|
||||
|
||||
emit(
|
||||
RecipeEditLoadedState(
|
||||
token: token,
|
||||
token: await TokenStorage.getTokenFromStorage(),
|
||||
recipe: data,
|
||||
title: TextEditingController(text: data['title']),
|
||||
description: TextEditingController(text: data['description']),
|
||||
@@ -191,17 +189,14 @@ class RecipeEditBloc extends Bloc<RecipeEditEvent, RecipeEditState> {
|
||||
}
|
||||
|
||||
_fetchTags(int id) async {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
|
||||
if (token == null) {
|
||||
if (!await TokenStorage.haveTokenInStorage()) {
|
||||
AppRouter.navigatorKey.currentContext?.goNamed('authScreen');
|
||||
}
|
||||
|
||||
final response = await http.get(
|
||||
Uri.parse(baseUrl + '/api/recipes/getTags/$id'),
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token',
|
||||
'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}',
|
||||
},
|
||||
);
|
||||
final data = jsonDecode(response.body);
|
||||
@@ -210,9 +205,7 @@ class RecipeEditBloc extends Bloc<RecipeEditEvent, RecipeEditState> {
|
||||
|
||||
FutureOr<void> _reloadScreen(RecipeEditEvent? event, Emitter<RecipeEditState> emit) async {
|
||||
print('Reloading..');
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
if (!await TokenStorage.haveTokenInStorage()) {
|
||||
AppRouter.navigatorKey.currentContext?.goNamed('authScreen');
|
||||
}
|
||||
if (state is RecipeEditLoadedState) {
|
||||
|
||||
@@ -2,12 +2,12 @@ import 'dart:async';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:eatvio_app/app_router.dart';
|
||||
import 'package:eatvio_app/core/token_storage.dart';
|
||||
import 'package:eatvio_app/locator_service.dart';
|
||||
import 'package:eatvio_app/presentation/recipe/recipe_select_screen/models/recipe_select_model.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
|
||||
import '/core/app_export.dart';
|
||||
@@ -26,9 +26,7 @@ class RecipeSelectBloc extends Bloc<RecipeSelectEvent, RecipeSelectState> {
|
||||
Emitter<RecipeSelectState> emit,
|
||||
) async {
|
||||
try {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
if (!await TokenStorage.haveTokenInStorage()) {
|
||||
AppRouter.navigatorKey.currentContext?.goNamed('authScreen');
|
||||
}
|
||||
final response = await sl<Dio>().get(baseUrl + '/api/recipes/index');
|
||||
|
||||
@@ -2,12 +2,12 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:eatvio_app/app_router.dart';
|
||||
import 'package:eatvio_app/core/token_storage.dart';
|
||||
import 'package:eatvio_app/presentation/feed/blog_post_screen/models/comment_model.dart';
|
||||
import 'package:eatvio_app/presentation/recipe/recipe_show_screen/models/recipe_show_model.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
@@ -29,16 +29,14 @@ class RecipeBloc extends Bloc<RecipeEvent, RecipeState> {
|
||||
Emitter<RecipeState> emit,
|
||||
) async {
|
||||
try {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
if (!await TokenStorage.haveTokenInStorage()) {
|
||||
AppRouter.navigatorKey.currentContext?.goNamed('authScreen');
|
||||
}
|
||||
final String? recipeID = state.recipeModelObj?.recipeID;
|
||||
final response = await http.get(
|
||||
Uri.parse(baseUrl + '/api/recipes/show/$recipeID'),
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token',
|
||||
'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}',
|
||||
},
|
||||
);
|
||||
if (response.statusCode == 200) {
|
||||
@@ -60,7 +58,7 @@ class RecipeBloc extends Bloc<RecipeEvent, RecipeState> {
|
||||
} else {
|
||||
emit(
|
||||
RecipeLoadedState(
|
||||
token: token,
|
||||
token: await TokenStorage.getTokenFromStorage(),
|
||||
recipe: data,
|
||||
steps: data['steps'],
|
||||
author: await _fetchAuthor(data['id']),
|
||||
@@ -85,16 +83,14 @@ class RecipeBloc extends Bloc<RecipeEvent, RecipeState> {
|
||||
}
|
||||
|
||||
FutureOr<void> _deleteEntry(DeleteEntry event, Emitter<RecipeState> emit) async {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
if (!await TokenStorage.haveTokenInStorage()) {
|
||||
AppRouter.navigatorKey.currentContext?.goNamed('authScreen');
|
||||
}
|
||||
final int id = event.id;
|
||||
final response = await http.post(
|
||||
Uri.parse(baseUrl + '/api/recipes/delete/$id'),
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token',
|
||||
'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}',
|
||||
},
|
||||
);
|
||||
if (response.statusCode == 200) {
|
||||
@@ -122,17 +118,14 @@ class RecipeBloc extends Bloc<RecipeEvent, RecipeState> {
|
||||
}
|
||||
|
||||
_fetchAuthor(int id) async {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
|
||||
if (token == null) {
|
||||
if (!await TokenStorage.haveTokenInStorage()) {
|
||||
AppRouter.navigatorKey.currentContext?.goNamed('authScreen');
|
||||
}
|
||||
|
||||
final response = await http.get(
|
||||
Uri.parse(baseUrl + '/api/recipes/getAuthor/$id'),
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token',
|
||||
'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}',
|
||||
},
|
||||
);
|
||||
final data = jsonDecode(response.body);
|
||||
@@ -140,15 +133,13 @@ class RecipeBloc extends Bloc<RecipeEvent, RecipeState> {
|
||||
}
|
||||
|
||||
Future<List> _fetchComments(int id) async {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
if (!await TokenStorage.haveTokenInStorage()) {
|
||||
AppRouter.navigatorKey.currentContext?.goNamed('authScreen');
|
||||
}
|
||||
final response = await http.get(
|
||||
Uri.parse(baseUrl + '/api/recipes/getComments/$id'),
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token',
|
||||
'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}',
|
||||
},
|
||||
);
|
||||
final data = jsonDecode(response.body);
|
||||
@@ -156,17 +147,14 @@ class RecipeBloc extends Bloc<RecipeEvent, RecipeState> {
|
||||
}
|
||||
|
||||
_fetchTags(int id) async {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
|
||||
if (token == null) {
|
||||
if (!await TokenStorage.haveTokenInStorage()) {
|
||||
AppRouter.navigatorKey.currentContext?.goNamed('authScreen');
|
||||
}
|
||||
|
||||
final response = await http.get(
|
||||
Uri.parse(baseUrl + '/api/recipes/getTags/$id'),
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token',
|
||||
'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}',
|
||||
},
|
||||
);
|
||||
final data = jsonDecode(response.body);
|
||||
|
||||
@@ -3,11 +3,11 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:eatvio_app/app_router.dart';
|
||||
import 'package:eatvio_app/core/token_storage.dart';
|
||||
import 'package:eatvio_app/presentation/users/subscribers_screen/models/subscribers_model.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import '/core/app_export.dart';
|
||||
@@ -26,15 +26,13 @@ class SubscribersBloc extends Bloc<SubscribersEvent, SubscribersState> {
|
||||
Emitter<SubscribersState> emit,
|
||||
) async {
|
||||
try {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
if (!await TokenStorage.haveTokenInStorage()) {
|
||||
AppRouter.navigatorKey.currentContext?.goNamed('authScreen');
|
||||
}
|
||||
final response = await http.get(
|
||||
Uri.parse(baseUrl + '/api/profile/subscribers'),
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token',
|
||||
'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}',
|
||||
},
|
||||
);
|
||||
print('Got response');
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../core/app_export.dart';
|
||||
|
||||
part 'theme_event.dart';
|
||||
part 'theme_state.dart';
|
||||
|
||||
class ThemeBloc extends Bloc<ThemeEvent, ThemeState> {
|
||||
ThemeBloc(ThemeState initialState) : super(initialState) {
|
||||
on<ThemeChangeEvent>(_changeTheme);
|
||||
}
|
||||
|
||||
_changeTheme(
|
||||
ThemeChangeEvent event,
|
||||
Emitter<ThemeState> emit,
|
||||
) async {
|
||||
emit(state.copyWith(themeType: event.themeType));
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
part of 'theme_bloc.dart';
|
||||
|
||||
@immutable
|
||||
abstract class ThemeEvent extends Equatable {}
|
||||
|
||||
class ThemeChangeEvent extends ThemeEvent {
|
||||
ThemeChangeEvent({required this.themeType}) : super() {
|
||||
PrefUtils().setThemeData(themeType);
|
||||
}
|
||||
|
||||
final String themeType;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
part of 'theme_bloc.dart';
|
||||
|
||||
@immutable
|
||||
class ThemeState extends Equatable {
|
||||
ThemeState({required this.themeType});
|
||||
|
||||
final String themeType;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [themeType];
|
||||
|
||||
ThemeState copyWith({String? themeType}) {
|
||||
return ThemeState(themeType: themeType ?? this.themeType);
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import '../../core/app_export.dart';
|
||||
/// Helper class for managing themes and colors.
|
||||
class ThemeHelper {
|
||||
// The current app theme
|
||||
var _appTheme = PrefUtils().getThemeData();
|
||||
var _appTheme = 'primary';
|
||||
|
||||
// A map of custom color themes supported by the app
|
||||
Map<String, PrimaryColors> _supportedCustomColor = {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/core/token_storage.dart';
|
||||
import 'package:eatvio_app/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart';
|
||||
import 'package:eatvio_app/widgets/custom_hyper_switch.dart';
|
||||
import 'package:eatvio_app/widgets/custom_hypo_switch.dart';
|
||||
@@ -8,7 +9,6 @@ import 'package:eatvio_app/widgets/next_step_button.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
@@ -384,8 +384,7 @@ class _ExpandableListState extends State<ExpandableList> {
|
||||
}
|
||||
|
||||
Future<String?> _getTokenFromBox() async {
|
||||
final box = await Hive.openBox('token');
|
||||
return box.get('token');
|
||||
return await TokenStorage.getTokenFromStorage();
|
||||
}
|
||||
|
||||
String _buildApiUrl() {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/core/token_storage.dart';
|
||||
import 'package:eatvio_app/widgets/custom_navigation_menu_item.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
class CustomNavigationMenu extends StatelessWidget {
|
||||
@@ -61,8 +61,7 @@ class CustomNavigationMenu extends StatelessWidget {
|
||||
|
||||
_onTapLogout(BuildContext context) {
|
||||
return () async {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
final token = await TokenStorage.getTokenFromStorage();
|
||||
final response = await http.post(
|
||||
Uri.parse(baseUrl + '/api/profile/logout'),
|
||||
headers: {
|
||||
@@ -71,8 +70,7 @@ _onTapLogout(BuildContext context) {
|
||||
);
|
||||
|
||||
if (response.statusCode == 204) {
|
||||
print(response.statusCode);
|
||||
box.delete('token'); // Удаляем токен из Hive
|
||||
await TokenStorage.removeTokenInStorage();
|
||||
GoRouter.of(context).go('/auth-screen');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -13,10 +13,8 @@ dependencies:
|
||||
flutter_localizations:
|
||||
sdk: flutter
|
||||
|
||||
flutter_secure_storage: ^9.2.2
|
||||
flutter_bloc: ^8.1.6
|
||||
shared_preferences: ^2.3.2
|
||||
hive: ^2.2.3
|
||||
hive_flutter: ^1.1.0
|
||||
cached_network_image: ^3.4.1
|
||||
flutter_svg: ^2.0.10
|
||||
equatable: ^2.0.5
|
||||
|
||||
Reference in New Issue
Block a user