Skip to content

Commit e596591

Browse files
committed
chore: update get started with firebase source code
1 parent b2084be commit e596591

File tree

7 files changed

+146
-84
lines changed

7 files changed

+146
-84
lines changed

firebase_start_tutorial/android/app/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ apply plugin: 'com.google.gms.google-services' //this line
2727
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
2828

2929
android {
30-
compileSdkVersion 30
30+
compileSdkVersion flutter.compileSdkVersion
3131

3232
sourceSets {
3333
main.java.srcDirs += 'src/main/kotlin'

firebase_start_tutorial/android/build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
buildscript {
2-
ext.kotlin_version = '1.3.50'
2+
ext.kotlin_version = '1.7.10'
33
repositories {
44
google()
55
jcenter()
66
}
77

88
dependencies {
9-
classpath 'com.android.tools.build:gradle:4.1.0'
9+
classpath 'com.android.tools.build:gradle:7.0.1'
1010
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1111
classpath 'com.google.gms:google-services:4.3.3'
1212
}
@@ -27,6 +27,6 @@ subprojects {
2727
project.evaluationDependsOn(':app')
2828
}
2929

30-
task clean(type: Delete) {
30+
tasks.register("clean", Delete) {
3131
delete rootProject.buildDir
3232
}

firebase_start_tutorial/android/gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-all.zip

firebase_start_tutorial/ios/Runner.xcodeproj/project.pbxproj

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
/* Begin PBXBuildFile section */
1010
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
11+
2884022CCAE83A6EE2EB7D4F /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = C7BA490C5F5ECF73E24F4223 /* GoogleService-Info.plist */; };
1112
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
1213
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
1314
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
@@ -42,6 +43,7 @@
4243
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
4344
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
4445
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
46+
C7BA490C5F5ECF73E24F4223 /* GoogleService-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "Runner/GoogleService-Info.plist"; sourceTree = "<group>"; };
4547
/* End PBXFileReference section */
4648

4749
/* Begin PBXFrameworksBuildPhase section */
@@ -72,6 +74,7 @@
7274
9740EEB11CF90186004384FC /* Flutter */,
7375
97C146F01CF9000F007C117D /* Runner */,
7476
97C146EF1CF9000F007C117D /* Products */,
77+
C7BA490C5F5ECF73E24F4223 /* GoogleService-Info.plist */,
7578
);
7679
sourceTree = "<group>";
7780
};
@@ -163,6 +166,7 @@
163166
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
164167
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
165168
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
169+
2884022CCAE83A6EE2EB7D4F /* GoogleService-Info.plist in Resources */,
166170
);
167171
runOnlyForDeploymentPostprocessing = 0;
168172
};

firebase_start_tutorial/lib/main.dart

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import 'package:firebase_core/firebase_core.dart';
22
import 'package:firebase_database/firebase_database.dart';
3+
import 'package:firebase_start_tutorial/firebase_options.dart';
34
import 'package:flutter/material.dart';
45

5-
6-
76
void main() async {
87
WidgetsFlutterBinding.ensureInitialized();
9-
await Firebase.initializeApp();
8+
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
109
runApp(MyApp());
1110
}
1211

@@ -40,7 +39,7 @@ class _MyHomePageState extends State<MyHomePage> {
4039

4140
@override
4241
Widget build(BuildContext context) {
43-
final ref = fb.reference();
42+
final ref = fb.ref();
4443
return Scaffold(
4544
appBar: AppBar(
4645
title: Text(widget.title!),
@@ -64,11 +63,11 @@ class _MyHomePageState extends State<MyHomePage> {
6463
),
6564
ElevatedButton(
6665
onPressed: () {
67-
ref.child("Name").once().then((DataSnapshot data){
68-
print(data.value);
69-
print(data.key);
66+
ref.child("Name").once().then((DatabaseEvent data) {
67+
print(data.snapshot.key);
68+
print(data.snapshot.value);
7069
setState(() {
71-
retrievedName = data.value;
70+
retrievedName = data.snapshot.value;
7271
});
7372
});
7473
},

0 commit comments

Comments
 (0)