74 lines
2.1 KiB
Dart
74 lines
2.1 KiB
Dart
import 'package:chicken/homeApp.dart';
|
|
import 'package:firebase_core/firebase_core.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:intl/date_symbol_data_local.dart';
|
|
|
|
void main() async{
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
await initializeDateFormatting('id_ID', null);
|
|
try {
|
|
await Firebase.initializeApp(
|
|
options: const FirebaseOptions(
|
|
apiKey: "AIzaSyBpjI0g0YeWkaLW4IfOmcpv3xOshEneF_A",
|
|
appId: "1:993868761781:android:303b1148634f3e582bccfc",
|
|
messagingSenderId: "459697250494",
|
|
projectId: "realtimeultrasonik",
|
|
storageBucket: "realtimeultrasonik.appspot.com",
|
|
databaseURL: "https://realtimeultrasonik-default-rtdb.firebaseio.com/"));
|
|
runApp(const MyApp());
|
|
} catch (e) {
|
|
print(e.toString());
|
|
runApp(MyAppNotConnected(errorMessage: e.toString()));
|
|
}
|
|
}
|
|
|
|
class MyAppNotConnected extends StatelessWidget {
|
|
final String errorMessage;
|
|
|
|
const MyAppNotConnected({Key? key, required this.errorMessage})
|
|
: super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
print('Firebase Initialization Error: $errorMessage');
|
|
|
|
return MaterialApp(
|
|
title: 'My App (Not Connected)',
|
|
home: Scaffold(
|
|
appBar: AppBar(
|
|
title: Text('Not Connected to Firebase'),
|
|
),
|
|
body: Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Text('Firebase is not available. Check your connection.'),
|
|
const SizedBox(height: 10),
|
|
Text('Error: $errorMessage'),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class MyApp extends StatelessWidget {
|
|
const MyApp({super.key});
|
|
|
|
// This widget is the root of your application.
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
title: 'Flutter Demo',
|
|
debugShowCheckedModeBanner: false,
|
|
/*theme: ThemeData(
|
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
|
|
useMaterial3: true,
|
|
),*/
|
|
home: HomeApp(),
|
|
);
|
|
}
|
|
}
|