Skip to content

Commit 55d4524

Browse files
move bloc observer to seperate file
1 parent 4734719 commit 55d4524

File tree

5 files changed

+48
-18
lines changed

5 files changed

+48
-18
lines changed

lib/bloc/process_bloc/process_event.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class ProcessFileExtractorProgress extends ProcessEvent {
5252
final String progress;
5353

5454
const ProcessFileExtractorProgress(this.progress);
55+
5556
}
5657

5758
class ProcessFileComplete extends ProcessEvent {

lib/bloc/updater_bloc/updater_bloc.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ class UpdaterBloc extends Bloc<UpdaterEvent, UpdaterState> {
3838

3939
bool updateAvailable =
4040
double.parse(latestVersion) > double.parse(event.currentVersion);
41-
print(latestVersion);
4241
yield state.copyWith(
4342
currentVersion: event.currentVersion,
4443
latestVersion: latestVersion,

lib/bloc_observer.dart

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Logs events and states during transition, needs some improvement to reduce spam
2+
// @override
3+
// String toString() => 'Event { prop: prop }';
4+
import 'package:bloc/bloc.dart';
5+
6+
class SimpleBlocObserver extends BlocObserver {
7+
@override
8+
void onCreate(BlocBase bloc) {
9+
super.onCreate(bloc);
10+
print('onCreate -- ${bloc.runtimeType}');
11+
}
12+
13+
// @override
14+
// void onEvent(Bloc bloc, Object? event) {
15+
// super.onEvent(bloc, event);
16+
17+
// if ({ProcessFileExtractorOutput, ProcessFileExtractorProgress}
18+
// .contains(event)) print('onEvent -- ${bloc.runtimeType}, $event');
19+
// }
20+
21+
// @override
22+
// void onTransition(Bloc bloc, Transition transition) {
23+
// // CurrentSettingsState and ProcessState have a lot of spam
24+
// if ({transition.nextState, transition.nextState}
25+
// .contains(CurrentSettingsState) ||
26+
// {transition.nextState, transition.nextState}.contains(ProcessState)) {
27+
// print(transition);
28+
// }
29+
// super.onTransition(bloc, transition);
30+
// }
31+
32+
@override
33+
void onError(BlocBase bloc, Object error, StackTrace stackTrace) {
34+
print('${bloc.runtimeType} $error $stackTrace');
35+
super.onError(bloc, error, stackTrace);
36+
}
37+
38+
@override
39+
void onClose(BlocBase bloc) {
40+
super.onClose(bloc);
41+
print('onClose -- ${bloc.runtimeType}');
42+
}
43+
}

lib/main.dart

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import 'package:ccxgui/repositories/settings_repository.dart';
1313
import 'package:ccxgui/screens/home.dart';
1414
import 'package:ccxgui/utils/constants.dart';
1515

16+
import 'bloc_observer.dart';
17+
1618
void main() async {
1719
WidgetsFlutterBinding.ensureInitialized();
1820
Bloc.observer = SimpleBlocObserver();
@@ -63,18 +65,3 @@ class MyApp extends StatelessWidget {
6365
);
6466
}
6567
}
66-
67-
// Logs events and states during transition
68-
class SimpleBlocObserver extends BlocObserver {
69-
// @override
70-
// void onTransition(Bloc bloc, Transition transition) {
71-
// print(transition);
72-
// super.onTransition(bloc, transition);
73-
// }
74-
75-
@override
76-
void onError(BlocBase bloc, Object error, StackTrace stackTrace) {
77-
print('${bloc.runtimeType} $error $stackTrace');
78-
super.onError(bloc, error, stackTrace);
79-
}
80-
}

lib/repositories/ccextractor.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class CCExtractor {
6666
listenVideoDetails(i[1]!.split('#'));
6767
}
6868
}
69-
update.contains('Error') ? listenOutput(update) : print(update);
69+
update.contains('Error') ? listenOutput(update) : null;
7070
});
7171
return process.exitCode;
7272
}
@@ -119,7 +119,7 @@ class CCExtractor {
119119
listenVideoDetails(i[1]!.split('#'));
120120
}
121121
}
122-
update.contains('Error') ? listenOutput(update) : print(update);
122+
update.contains('Error') ? listenOutput(update) : null;
123123
});
124124
return process.exitCode;
125125
}

0 commit comments

Comments
 (0)