fix: homeBloc state managment

This commit is contained in:
J. A. Messias 2024-12-06 15:04:21 -03:00
parent 92a8986a7e
commit d787f8e89c
2 changed files with 27 additions and 17 deletions

View File

@ -1,13 +1,24 @@
import 'dart:async';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:hub/shared/helpers/storage/base_storage.dart';
import 'package:hub/shared/helpers/storage/storage_helper.dart';
import '../../../../shared/components/molecules/locals/index.dart';
import 'index.dart';
class HomeBloc extends Bloc<HomeEvent, HomeState> {
late StreamSubscription<bool> _completer;
HomeBloc() : super(HomeState()) {
on<HomeEvent>((event, emit) async {
on<HomeEvent>(_onHomeEvent);
_completer = LocalsRepositoryImpl.license.stream.listen((v) {
add(HomeEvent());
});
}
Future<void> _onHomeEvent(HomeEvent event, Emitter<HomeState> emit) async {
final devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? '';
final userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? '';
final cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? '';
@ -21,6 +32,7 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
userName: userName,
userEmail: userEmail,
));
});
}
}

View File

@ -52,8 +52,6 @@ class _LocalProfileComponentWidgetState extends State<LocalProfileComponentWidge
return _buildDefaultLocalProfile(context, limitedFontSize);
},
);
}
return BlocBuilder<LocalProfileBloc, LocalProfileState>(