我特灵实现云Firestore到我的笔记程序,但我不断得到这个错误两次:
I/扑动(5328):(未在通道plugins.flutter.io/firebase_core上找到方法Firebase#initializeCore的实现)〉I/flutter(5328):未找到通道plugins.flutter.io/firebase_core上的方法Firebase#initializeCore的实现)
我已经尝试了所有其他补救措施从其他类似的网页,但没有一个工作。这是我的main.dart:
//imports like material and cupertino above
import 'package:cloud_firestore/cloud_firestore.dart';
// Import the firebase_core plugin
import 'package:firebase_core/firebase_core.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
runApp(MaterialApp(home: App(),));
}
class App extends StatefulWidget {
_AppState createState() => _AppState();
}
class _AppState extends State<App> {
// Set default `_initialized` and `_error` state to false
bool _initialized = false;
bool _error = false;
String error = '';
// Define an async function to initialize FlutterFire
void initializeFlutterFire() async {
try {
// Wait for Firebase to initialize and set `_initialized` state to true
await Firebase.initializeApp();
setState(() {
_initialized = true;
});
} catch(e) {
// Set `_error` state to true if Firebase initialization fails
setState(() {
error = e.toString();
_error = true;
});
}
}
@override
void initState() {
initializeFlutterFire();
super.initState();
}
@override
Widget build(BuildContext context) {
// Show error message if initialization failed
if(_error) {
print(error);
return Scaffold(
body: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
'${error}'
),
],
),
),
);
}
// Show a loader until FlutterFire is initialized
if (!_initialized) {
return Scaffold(
body: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
CircularProgressIndicator()
],
),
),
);;
}
return NoteApp();
}
}
class NoteApp extends StatefulWidget {
const NoteApp({Key? key}) : super(key: key);
@override
_NoteAppState createState() => _NoteAppState();
}
class _NoteAppState extends State<NoteApp> {
...
}
这是我的酒吧说明书
dependencies:
cloud_firestore_platform_interface: ^5.4.1
cloud_firestore_web: ^2.4.1
cloud_firestore: ^2.5.1
collection: ^1.0.0
firebase_core: ^1.6.0
firebase_core_platform_interface: ^4.0.1
这是我的身材
buildTypes {
release {
signingConfig signingConfigs.debug
minifyEnabled false
shrinkResources false
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
}
defaultConfig{
// add the following line
multiDexEnabled true
}
}
有没有人知道如何解决这个不像其他问题?
2条答案
按热度按时间l7wslrjt1#
使用命令
flutter create myapp
创建一个新项目,并按照here所述将gradle构建工具的版本升级到3.5.0。mcdcgff02#
我只是创建一个新项目,并将我所有的文件移动到它然后每件事都为我工作,也许是因为我创建我的旧项目之前升级我的flutter(不同的flutter版本旧项目和当前flutter)。