为什么它不起作用?当我删除 Firebase.initializeApp();它工作得很好。我把它放在任何地方,它仍然不起作用。我已经尝试将它添加到每个不同的地方,但它仍然没有做任何事情。
import 'package:firebase_storage/firebase_storage.dart';
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_core/firebase_core.dart';
void main() => runApp(MaterialApp(
Firebase.initializeApp();
home: Scaffold(
appBar: AppBar(
title: Text('123'),
centerTitle: true,
backgroundColor: Colors.red[600],
),
body: Center(
child: Text(
'hello mars!',
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold,
letterSpacing: 2.0,
color: Colors.grey[600],
),
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {},
child: Text('click'),
backgroundColor: Colors.red[600],
),
),
));
答案 0 :(得分:0)
It should be something like this
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MaterialApp(
debugShowCheckedModeBanner: false,
initialRoute: '/',
routes: {
'/': (context) => LoadScreen(),
},
));
}