ui/lib/main.dart (33 lines of code) (raw):
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import 'package:cloudprovision/theme.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:url_strategy/url_strategy.dart';
import 'routing/app_router.dart';
import 'firebase_options.dart';
Future<void> main() async {
// TODO move Firebase options to env file
await dotenv.load(fileName: "assets/env");
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
// Uncomment to run with local Firebase emulator
// if (kDebugMode) {
// try {
// FirebaseFirestore.instance.useFirestoreEmulator('localhost', 8088);
// await FirebaseAuth.instance.useAuthEmulator('localhost', 9099);
// } catch (e) {
// print(e);
// }
// }
setPathUrlStrategy();
runApp(
ProviderScope(
child: const CloudProvisionApp(),
),
);
}
class CloudProvisionApp extends ConsumerWidget {
const CloudProvisionApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context, WidgetRef ref) {
final goRouter = ref.watch(goRouterProvider);
return MaterialApp.router(
debugShowCheckedModeBanner: false,
routerConfig: goRouter,
theme: CloudTheme().themeData,
);
}
}