板球队
A Flutter application that demonstrate simple CRUD operations with Firebase cloud database.
预览
| 首页 | 空 | 滑动 |
|---|---|---|
![]() |
![]() |
![]() |
| 添加球员 | 更新球员 |
|---|---|
![]() |
![]() |
将 Firebase 添加到您的应用
- 创建 Firebase 项目。有关在您的 flutter 应用中设置 firebase 的信息,请查看 Firebase 文档。
- 创建新的 Firebase 控制台项目
- 将 Cloud Firestore 添加到 pubspec.yaml 中的项目
- 将创建的 _google-services.json_ 文件放入 _android/app_ 目录
Gradle
对 _android/build.gradle_ 的更改
buildscript {
repositories {
...
}
dependencies {
...
classpath 'com.google.gms:google-services:3.2.1' // Google Services plugin
}
}
然后我们有 _android/app/build.gradle_
//bottom of file
apply plugin: 'com.google.gms.google-services'
iOS CocoaPods
Google 服务使用 CocoaPods 安装和管理依赖项。打开一个终端窗口,导航到您应用程序的 Xcode 项目位置。
- 如果还没有 Podfile,请创建一个
pod init
- 打开您的 Podfile 并添加
pod 'Firebase/Core'
- 保存文件并运行
pod install
- 添加初始化代码
import UIKit
import Firebase // import the firebase
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?)
-> Bool {
FirebaseApp.configure() //configure the firebase
return true
}
}
入门
本项目是 Flutter 应用程序的起点。
如果您这是您的第一个 Flutter 项目,这里有一些入门资源
如需获取 Flutter 入门帮助,请参阅我们的
在线文档,其中提供了教程,
示例、移动开发指南和完整的 API 参考。




