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;
|
2023-04-13 17:32:31 +02:00
|
|
|
import 'package:nc_photos/bloc_util.dart';
|
2021-08-30 18:57:45 +02:00
|
|
|
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();
|
2022-07-05 22:20:24 +02:00
|
|
|
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-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
|
2023-04-13 17:32:31 +02:00
|
|
|
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
|
|
|
}
|