mirror of https://github.com/flutter/pinball.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.3 KiB
49 lines
1.3 KiB
// Copyright (c) 2021, Very Good Ventures
|
|
// https://verygood.ventures
|
|
//
|
|
// Use of this source code is governed by an MIT-style
|
|
// license that can be found in the LICENSE file or at
|
|
// https://opensource.org/licenses/MIT.
|
|
|
|
// ignore_for_file: public_member_api_docs
|
|
|
|
import 'dart:async';
|
|
import 'dart:developer';
|
|
|
|
import 'package:bloc/bloc.dart';
|
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
|
import 'package:flutter/widgets.dart';
|
|
|
|
class AppBlocObserver extends BlocObserver {
|
|
@override
|
|
void onChange(BlocBase bloc, Change change) {
|
|
super.onChange(bloc, change);
|
|
log('onChange(${bloc.runtimeType}, $change)');
|
|
}
|
|
|
|
@override
|
|
void onError(BlocBase bloc, Object error, StackTrace stackTrace) {
|
|
log('onError(${bloc.runtimeType}, $error, $stackTrace)');
|
|
super.onError(bloc, error, stackTrace);
|
|
}
|
|
}
|
|
|
|
Future<void> bootstrap(
|
|
Future<Widget> Function(FirebaseFirestore firestore) builder,
|
|
) async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
FlutterError.onError = (details) {
|
|
log(details.exceptionAsString(), stackTrace: details.stack);
|
|
};
|
|
|
|
await runZonedGuarded(
|
|
() async {
|
|
await BlocOverrides.runZoned(
|
|
() async => runApp(await builder(FirebaseFirestore.instance)),
|
|
blocObserver: AppBlocObserver(),
|
|
);
|
|
},
|
|
(error, stackTrace) => log(error.toString(), stackTrace: stackTrace),
|
|
);
|
|
}
|