This Flutter project integrates Firebase services for authentication, database, and storage. It's built using the FlutterFire plugins for Firebase.
- Flutter SDK
- Firebase Project: Create a new project on the Firebase Console.
- Firebase Configuration Files: Download
google-services.json
(Android) andGoogleService-Info.plist
(iOS) from Firebase Console and place them in the respective folders.
-
Clone the repository:
git clone https://github.com/Xelame/firebase.git
-
Navigate to the project directory:
cd firebase
-
Install dependencies:
flutter pub get
- Enable the Authentication service in the Firebase Console.
- Follow the setup instructions to configure authentication providers.
- Enable Cloud Firestore in the Firebase Console.
- Set up your Firestore database and collections.
- Enable Firebase Storage in the Firebase Console.
- Set up your storage buckets and permissions.
// Sign in
await FirebaseAuth.instance.signInWithEmailAndPassword(
email: _emailController.text,
password: _passwordController.text,
);
// Sign up
await FirebaseAuth.instance.createUserWithEmailAndPassword(
email: _emailController.text,
password: _passwordController.text,
);
// Writing Data
final notes = FirebaseFirestore.instance.collection('notes');
notes.add({
'title': taskTitle,
'content': taskDescription,
'done': false,
'file': 'file/${_file!.name}',
}
);
// Reading Data
StreamBuilder<QuerySnapshot>(
stream: notes.snapshots(),
...
children: snapshot.data!.docs.map((DocumentSnapshot document) {
Map<String, dynamic> data =
document.data()! as Map<String, dynamic>;
return ListTile(
...
title: Text(data['title']),
subtitle: Text(data['content']),
...
// Upload File
Future _uploadFile() async {
final path = 'file/${_file!.name}';
final file = File(_file!.path!);
final ref = FirebaseStorage.instance.ref().child(path);
setState(() {
_task = ref.putFile(file);
});
await _task!.whenComplete(() async {
_urlDownload = await ref.getDownloadURL();
});
setState(() {
_task = null;
});
}
Contributions are welcome! See the Contributing Guidelines for more details.
This project is licensed under the MIT License.