mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-25 08:57:54 +00:00
getting spaces and rooms from api {null checks}
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:syncrow_app/features/app_layout/bloc/nav_cubit.dart';
|
||||
import 'package:syncrow_app/features/auth/model/login_with_email_model.dart';
|
||||
import 'package:syncrow_app/features/auth/model/token.dart';
|
||||
import 'package:syncrow_app/features/auth/model/user_model.dart';
|
||||
@@ -20,7 +21,7 @@ class AuthCubit extends Cubit<AuthState> {
|
||||
TextEditingController passwordController = TextEditingController();
|
||||
bool isPasswordVisible = false;
|
||||
|
||||
GlobalKey<FormState> formKey = GlobalKey<FormState>();
|
||||
static GlobalKey<FormState> formKey = GlobalKey<FormState>();
|
||||
|
||||
void changePasswordVisibility() {
|
||||
isPasswordVisible = !isPasswordVisible;
|
||||
@@ -54,15 +55,16 @@ class AuthCubit extends Cubit<AuthState> {
|
||||
FlutterSecureStorage storage = const FlutterSecureStorage();
|
||||
await storage.write(
|
||||
key: Token.loginAccessTokenKey, value: token.accessToken);
|
||||
|
||||
const FlutterSecureStorage().write(
|
||||
key: UserModel.userUuidKey,
|
||||
value: Token.decodeToken(token.accessToken)['uuid'].toString());
|
||||
user = UserModel.fromToken(token);
|
||||
emit(AuthSuccess());
|
||||
} else {
|
||||
emit(AuthError('Something went wrong'));
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
emit(AuthError(e.message ?? "Something went wrong"));
|
||||
throw ServerFailure.fromDioError(e);
|
||||
emit(AuthError(ServerFailure.fromDioError(e).errMessage));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,9 +73,10 @@ class AuthCubit extends Cubit<AuthState> {
|
||||
try {
|
||||
FlutterSecureStorage storage = const FlutterSecureStorage();
|
||||
await storage.delete(key: Token.loginAccessTokenKey);
|
||||
NavCubit.clear();
|
||||
emit(AuthLoggedOut());
|
||||
} on DioException catch (e) {
|
||||
throw ServerFailure.fromDioError(e);
|
||||
emit(AuthError(ServerFailure.fromDioError(e).errMessage));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user