2022-07-29 00:59:26 +08:00
|
|
|
import 'dart:async';
|
|
|
|
|
2022-07-09 13:59:09 +08:00
|
|
|
import 'package:bloc_concurrency/bloc_concurrency.dart';
|
2021-04-10 12:28:12 +08:00
|
|
|
import 'package:flutter/material.dart';
|
2022-01-17 18:59:40 +08:00
|
|
|
import 'package:flutter/services.dart';
|
2023-05-24 00:47:32 +08:00
|
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
2022-07-09 13:59:09 +08:00
|
|
|
import 'package:logging/logging.dart';
|
2022-03-28 01:55:31 +08:00
|
|
|
import 'package:nc_photos/app_init.dart' as app_init;
|
2023-04-13 23:32:31 +08:00
|
|
|
import 'package:nc_photos/bloc_util.dart';
|
2021-04-17 16:42:57 +08:00
|
|
|
import 'package:nc_photos/widget/my_app.dart';
|
2022-12-16 23:01:04 +08:00
|
|
|
import 'package:np_codegen/np_codegen.dart';
|
2023-08-27 18:58:05 +08:00
|
|
|
import 'package:np_platform_util/np_platform_util.dart';
|
2022-12-16 23:01:04 +08:00
|
|
|
|
|
|
|
part 'main.g.dart';
|
2021-04-10 12:28:12 +08:00
|
|
|
|
|
|
|
void main() async {
|
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
2022-07-06 04:20:24 +08:00
|
|
|
await app_init.init(app_init.InitIsolateType.main);
|
2021-04-10 12:28:12 +08:00
|
|
|
|
2023-08-27 18:58:05 +08:00
|
|
|
if (getRawPlatform().isMobile) {
|
2022-01-17 18:59:40 +08:00
|
|
|
// reset orientation override just in case, see #59
|
2022-07-29 00:59:26 +08:00
|
|
|
unawaited(SystemChrome.setPreferredOrientations([]));
|
2022-01-17 18:59:40 +08:00
|
|
|
}
|
2023-05-26 01:26:42 +08:00
|
|
|
Bloc.observer = const _BlocObserver();
|
|
|
|
Bloc.transformer = sequential();
|
|
|
|
runApp(const MyApp());
|
2022-07-09 13:59:09 +08:00
|
|
|
}
|
|
|
|
|
2022-12-16 23:01:04 +08:00
|
|
|
@npLog
|
2022-07-09 13:59:09 +08:00
|
|
|
class _BlocObserver extends BlocObserver {
|
2023-05-26 01:26:42 +08:00
|
|
|
const _BlocObserver();
|
|
|
|
|
2022-07-09 13:59:09 +08:00
|
|
|
@override
|
2023-04-13 23:32:31 +08:00
|
|
|
void onChange(BlocBase bloc, Change change) {
|
2022-07-09 13:59:09 +08:00
|
|
|
super.onChange(bloc, change);
|
2023-06-18 22:26:19 +08: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 13:59:09 +08:00
|
|
|
}
|
2021-04-10 12:28:12 +08:00
|
|
|
}
|