feat(api_service): Update try-catch funtion and handle exception
update(loading_animation): Update loading animation using Lottie
This commit is contained in:
anhtunz
2025-06-09 14:29:43 +07:00
parent 477646ab9d
commit 3a8fa3633c
44 changed files with 1659 additions and 1065 deletions

View File

@@ -1,10 +1,15 @@
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:sfm_app/product/services/api_services.dart';
import '../feature/settings/profile/profile_model.dart';
import '../product/base/bloc/base_bloc.dart';
import '../product/shared/shared_snack_bar.dart';
class SettingsBloc extends BlocBase {
// Settings Screen
APIServices apiServices = APIServices();
final userProfile = StreamController<User>.broadcast();
StreamSink<User> get sinkUserProfile => userProfile.sink;
Stream<User> get streamUserProfile => userProfile.stream;
@@ -18,6 +23,17 @@ class SettingsBloc extends BlocBase {
isChangeProfileInfomation.stream;
void getUserProfile(BuildContext context) async {
try {
User user = await apiServices.getUserDetail();
sinkUserProfile.add(user);
} catch (e) {
if (!context.mounted) return;
showErrorTopSnackBarCustom(
context, e.toString());
}
}
@override
void dispose() {