forked from eatvio/eatvio_app
refactor(token): add token storage, remove hive
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user