搜索插件、代码仓与 APP 分类

插件详情v0.0.1

fire_flutter_db

FlutterFire 通过简洁直观的 API 简化了 Flutter 应用中的 Firebase 集成,提供了流畅的认证和 Firestore 数据库操作。

AndroidiOSWebmacOS
近 30 天下载
29
喜欢数
7
Pub 分数
120

安装插件

flutter pub add fire_flutter_db

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

FireFlutterDB 是一个 Flutter 包,可简化与 Firebase 的集成,为身份验证和 Firestore 数据库操作提供直观的 API。它简化了用户登录、数据检索以及在 Android、iOS、Web 和 macOS 平台上实现实时更新等常见任务。专为希望无缝使用 Firebase 功能而无需编写样板代码的开发者设计,可提升开发效率并降低设置复杂性。该包是更广泛的 FlutterFire 生态系统的一部分,确保兼容性和一致的设计模式。

适合场景

  • 实时数据同步
  • 用户身份验证工作流
  • 跨平台应用开发
  • 基于云的状态管理
  • 离线优先应用功能

主要特点

  • 简洁直观的 API
  • 实时 Firestore 监听器
  • 内置的认证方法
  • 多平台支持
  • 最小化样板代码

适合对象

  • 初学者到中级 Flutter 开发者
  • 需要实时数据的应用程序
  • 使用 Firebase 作为后端的项目
  • 跨平台移动和网页应用
  • 快速原型设计

使用建议

  • 需要 Firebase 项目设置
  • 仅限 Firebase 服务
  • 依赖于 FlutterFire 生态系统
  • 可能增加应用大小
  • 需要互联网连接以进行云同步

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

FLUTTER FIRE 🔥

This Flutter package, named flutter_fire, provides convenient and streamlined access to Firebase Authentication and Firestore operations within your Flutter applications. It simplifies tasks such as user authentication via email/password and Google Sign-In, as well as common Firestore operations like retrieving single documents, fetching all documents in a collection, and streaming data updates. With its intuitive methods, flutter_fire aims to enhance your development experience by seamlessly integrating Firebase services into your Flutter projects.

Features

  1. Authentication:

    • Sign in with email and password.
    • Create a new user with email and password.
    • Sign in with Google authentication.
  2. Firebase Firestore Operations:

    • Find a single document by ID.
    • Find all documents in a collection.
    • Get a stream of data from a Firestore collection.
    • Retrieve data from a Firestore collection.
    • Find a list of documents present in a list of document IDs and return them as a stream.
  3. Convenience Features:

    • Access to the current user.
    • Stream for authentication state changes.

Getting started

Prerequisites
  1. Flutter Setup: Ensure you have Flutter installed on your system. You can find installation instructions on the official Flutter website.

  2. Firebase Account: Create a Firebase account if you haven't already. You can sign up for free on the Firebase website.

@echo off

echo Firebase Login checking...
call firebase login
echo Adding Firebase plugins to the Flutter project...
call firebase init
echo Adding Firebase plugins to the Flutter project...
call flutter pub add firebase_core firebase_auth cloud_firestore
echo Running Flutter project...
call flutter run

To use this script, create a new text file in your project directory, name it firebase_init.bat, and paste the above code into it. Then, you can simply run this file from the command line to set up Firebase and add the necessary plugins to your Flutter project. Make sure you have both the Firebase CLI and Flutter installed and configured on your system before running this script.

Usage

import 'package:flutter_fire/flutter_fire.dart';

1. Authentication :

// Initialize FlutterFire instance
FlutterFire flutterFire = FlutterFire();

// Sign in with email and password
await flutterFire.signInWithEmailAndPassword(email: 'example@email.com', password: 'password');

// Create a new user with email and password
await flutterFire.createUserWithEmailAndPassword(email: 'newuser@email.com', password: 'newpassword');

// Sign in with Google authentication
await flutterFire.signInWithGoogle();

2. Firestore Operations :

// Get a single document by ID
Map<String, dynamic>? document = await flutterFire.findOne('collectionName', 'documentId');

// Get all documents in a collection
List<dynamic>? documents = await flutterFire.findAll('collectionName');

// Stream data from a Firestore collection
Stream<QuerySnapshot<Map<String, dynamic>>> stream = flutterFire.getStreamData('collectionName');

// Retrieve data from a Firestore collection
Map<String, dynamic> data = flutterFire.getData('collectionName');

// Find documents present in a list of document IDs and return them as a stream
Stream<List<Map<String, dynamic>>> docStream = flutterFire.findStreamContainingList('collectionName', 'documentId', ['id1', 'id2']);

3. Convenience Features:

// Access the current user
User? currentUser = flutterFire.currentUser;

// Stream for authentication state changes
Stream<User?> authStream = flutterFire.authStateChanges;

These examples showcase how to perform common authentication and Firestore operations using the flutter_fire package, making it easier for developers to integrate Firebase services into their Flutter applications.

所属分类

依赖

依赖清单 5 项

源码仓库

使用此插件的项目

暂无相关数据。