nc-photos/app/lib/main.dart

43 lines
1.3 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/bloc.dart';
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';
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';
import 'package:nc_photos/platform/k.dart' as platform_k;
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';
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
2022-01-17 11:59:40 +01:00
if (platform_k.isMobile) {
// reset orientation override just in case, see #59
2022-07-28 18:59:26 +02:00
unawaited(SystemChrome.setPreferredOrientations([]));
2022-11-07 12:32:04 +01:00
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
));
2022-01-17 11:59:40 +01:00
}
2022-07-09 07:59:09 +02:00
BlocOverrides.runZoned(
() => runApp(const MyApp()),
blocObserver: _BlocObserver(),
eventTransformer: sequential(),
);
}
2022-12-16 16:01:04 +01:00
@npLog
2022-07-09 07:59:09 +02:00
class _BlocObserver extends BlocObserver {
@override
void onChange(BlocBase bloc, Change change) {
2022-07-09 07:59:09 +02:00
super.onChange(bloc, change);
final tag = bloc is BlocTag ? (bloc as BlocTag).tag : bloc.runtimeType;
_log.finer("$tag $change");
2022-07-09 07:59:09 +02:00
}
2021-04-10 06:28:12 +02:00
}