Before using any Firebase service, you must first install the firebase_core plugin, which is responsible for connecting your application to Firebase. Add the plugin to your pubspec.yaml file:
pubspec.yaml
dependencies:
flutter:
sdk: flutter
firebase_core: "0.7.0"
Before using any Firebase service, you need to initialize FlutterFire (you can think of this process as FlutterFire "bootstrap" itself). The initialization step is asynchronous, which means you need to block any FlutterFire related use until the initialization is complete.
To initialize FlutterFire, call the initializeApp method on the Firebase class:
await Firebase.initializeApp();
The method is asynchronous and returns a Future, so you need to make sure it has completed before you can display the main application. The following example shows how to use FutureBuilder or StatefulWidget for this purpose:
import 'package:flutter/material.dart';
// Import the firebase_core plugin
import 'package:firebase_core/firebase_core.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
runApp(App());
}
class App extends StatelessWidget {
// Create the initialization Future outside of `build`:
final Future<FirebaseApp> _initialization = Firebase.initializeApp();
@override
Widget build(BuildContext context) {
return FutureBuilder(
// Initialize FlutterFire:
future: _initialization,
builder: (context, snapshot) {
// Check for errors
if (snapshot.hasError) {
return SomethingWentWrong();
}
// Once complete, show your application
if (snapshot.connectionState == ConnectionState.done) {
return MyAwesomeApp();
}
// Otherwise, show something whilst waiting for initialization to complete
return Loading();
},
);
}
}
The firebase_core plugin itself provides basic functions for use with Firebase. FlutterFire is divided into several separate installable plugins that allow you to integrate with specific Firebase services.
The following table lists all currently supported plug-ins. You can follow the documentation of each plugin:
firebase_auth :
the usage of Firebase Authentication you may authenticate customers on your app the usage of numerous techniques which include passwords, telephone numbers, and popular federated providers like Google, fb, and greater.
cloud_firestore :
Cloud Firestore is a flexible, scalable database for mobile, web, and server development from Firebase and Google Cloud Platform. Cloud Firestore also gives seamless integration with other Firebase and Google Cloud Platform products, including Cloud functions.
firebase_core :
The firebase_core plugin is used to initialize FlutterFire and join your software with a couple of Firebase projects.
firebase_storage :
Cloud storage is designed to help you quickly and without difficulty shop and serve person-generated content, which include pics and videos.
google developer console, google play developer console, android app development, paytm mini app store, google develop, android sdks, flutter web, google play developer, google play publish, google console developer, google play store console,
No comments:
Post a Comment