Logging data
Try-catch function
This commit is contained in:
anhtunz
2025-06-17 16:43:45 +07:00
parent 22fef0e0a8
commit 2d53f2cdd3
41 changed files with 1591 additions and 1299 deletions

View File

@@ -1,20 +1,17 @@
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:sfm_app/product/services/api_services.dart';
import '../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 {
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;
// Profile Screen
final isChangeProfileInfomation = StreamController<bool>.broadcast();
StreamSink<bool> get sinkIsChangeProfileInfomation =>
@@ -22,20 +19,13 @@ class SettingsBloc extends BlocBase {
Stream<bool> get streamIsChangeProfileInfomation =>
isChangeProfileInfomation.stream;
void getUserProfile(BuildContext context) async {
try {
void getUserProfile(BuildContext context) async {
await apiServices.execute(context, () async {
User user = await apiServices.getUserDetail();
sinkUserProfile.add(user);
} catch (e) {
if (!context.mounted) return;
showErrorTopSnackBarCustom(
context, e.toString());
}
});
}
@override
void dispose() {
}
void dispose() {}
}