nc-photos/app/lib/main.dart

47 lines
1.4 KiB
Dart
Raw Normal View History

2022-07-28 18:59:26 +02:00
import 'dart:async';
2022-07-09 07:59:09 +02:00
import 'package:bloc_concurrency/bloc_concurrency.dart';
2021-04-10 06:28:12 +02:00
import 'package:flutter/material.dart';
2022-01-17 11:59:40 +01:00
import 'package:flutter/services.dart';
2023-05-23 18:47:32 +02:00
import 'package:flutter_bloc/flutter_bloc.dart';
2022-07-09 07:59:09 +02:00
import 'package:logging/logging.dart';
2022-03-27 19:55:31 +02:00
import 'package:nc_photos/app_init.dart' as app_init;
import 'package:nc_photos/bloc_util.dart';
2021-04-17 10:42:57 +02:00
import 'package:nc_photos/widget/my_app.dart';
2022-12-16 16:01:04 +01:00
import 'package:np_codegen/np_codegen.dart';
2023-08-27 12:58:05 +02:00
import 'package:np_platform_util/np_platform_util.dart';
2022-12-16 16:01:04 +01:00
part 'main.g.dart';
2021-04-10 06:28:12 +02:00
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await app_init.init(app_init.InitIsolateType.main);
2021-04-10 06:28:12 +02:00
2023-08-27 12:58:05 +02:00
if (getRawPlatform().isMobile) {
2022-01-17 11:59:40 +01:00
// reset orientation override just in case, see #59
2022-07-28 18:59:26 +02:00
unawaited(SystemChrome.setPreferredOrientations([]));
2022-01-17 11:59:40 +01:00
}
2023-05-25 19:26:42 +02:00
Bloc.observer = const _BlocObserver();
Bloc.transformer = sequential();
runApp(const MyApp());
2022-07-09 07:59:09 +02:00
}
2022-12-16 16:01:04 +01:00
@npLog
2022-07-09 07:59:09 +02:00
class _BlocObserver extends BlocObserver {
2023-05-25 19:26:42 +02:00
const _BlocObserver();
2022-07-09 07:59:09 +02:00
@override
void onChange(BlocBase bloc, Change change) {
2022-07-09 07:59:09 +02:00
super.onChange(bloc, change);
2023-06-18 16:26:19 +02:00
if (bloc is BlocLogger) {
final bl = bloc as BlocLogger;
final tag = bl.tag ?? bloc.runtimeType;
if (bl.shouldLog?.call(change.currentState, change.nextState) ?? true) {
_log.finer("$tag newState: ${change.nextState}");
}
} else {
_log.finer("${bloc.runtimeType} newState: ${change.nextState}");
}
2022-07-09 07:59:09 +02:00
}
2021-04-10 06:28:12 +02:00
}