Skip to content

refactor(firebase_database)!: Migrate to sound null-safety #5441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Apr 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
19e87a1
Migrate packages and lib to null-safety
aaqibismail Mar 23, 2021
c928a53
Update example application to null-safety
aaqibismail Mar 23, 2021
d3b4f96
Update packages in main pubspec.yaml to latest
aaqibismail Mar 23, 2021
eab756a
Update packages in example pubspec.yaml to latest
aaqibismail Mar 23, 2021
d11d866
Update version to 7.0.0 in pubspec.yaml
aaqibismail Mar 23, 2021
39b1720
Bump changelog
aaqibismail Mar 23, 2021
0678bb6
Add flutter_test package to example
aaqibismail Mar 23, 2021
01df542
Removed assert statement creating warning
aaqibismail Mar 23, 2021
593b59c
Fixed cast issue with push_id generator
aaqibismail Mar 24, 2021
ccd7dc7
Merge branch 'master' of https://github.com/FirebaseExtended/flutterf…
rrousselGit Mar 24, 2021
30944fd
Revert "Bump changelog"
aaqibismail Mar 26, 2021
5469494
Revert "Update version to 7.0.0 in pubspec.yaml"
aaqibismail Mar 26, 2021
fbe0193
Use ! instead of explicit null checks, add e2e
aaqibismail Apr 1, 2021
6efede6
Remove Pedantic
aaqibismail Apr 1, 2021
e09748d
Add e2e to example
aaqibismail Apr 1, 2021
a7dcfa4
Use dart 2.9 for e2e, fix returning null warning
aaqibismail Apr 1, 2021
c143bbd
Migrate tests to null-safety, add tests for when there are no listeners
aaqibismail Apr 1, 2021
5883c4d
migrate e2e
rrousselGit Apr 7, 2021
9c2df55
review
rrousselGit Apr 7, 2021
560aa8f
fix tests
rrousselGit Apr 7, 2021
666c430
Merge branch 'master' into firebase-database-null-safety
Salakar Apr 14, 2021
c9bd378
refactor(tests): switch integration tests over to `drive` package
Salakar Apr 14, 2021
5841cc5
refactor(database,example): upgrade example to v2 android embedding
Salakar Apr 14, 2021
7946464
ci: various tweaks for NNBD and melos bootstrap
Salakar Apr 14, 2021
bcae41a
tests: flutter driver does not yet support nnbd
Salakar Apr 14, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/firebase_database.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ on:
env:
FLUTTERFIRE_PLUGIN_SCOPE: "*firebase_database*"
FLUTTERFIRE_PLUGIN_SCOPE_EXAMPLE: "*firebase_database_example*"
# TODO(Salakar): `flutter_driver` does not yet support NNBD
FLUTTER_COMMAND_FLAGS: "--no-sound-null-safety"

jobs:
android:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/scripts/build-example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ DEFAULT_TARGET="./test_driver/MELOS_PARENT_PACKAGE_NAME_e2e.dart"
ACTION=$1
TARGET_FILE=${2:-$DEFAULT_TARGET}

melos bootstrap
melos bootstrap --scope="*firebase_core*" --scope="$FLUTTERFIRE_PLUGIN_SCOPE"

if [ "$ACTION" == "android" ]
then
melos exec -c 1 --scope="$FLUTTERFIRE_PLUGIN_SCOPE_EXAMPLE" -- \
flutter build apk --debug --target="$TARGET_FILE" --dart-define=CI=true --no-android-gradle-daemon
flutter build apk $FLUTTER_COMMAND_FLAGS --debug --target="$TARGET_FILE" --dart-define=CI=true --no-android-gradle-daemon
MELOS_EXIT_CODE=$?
pkill dart || true
pkill java || true
Expand All @@ -20,13 +20,13 @@ fi
if [ "$ACTION" == "ios" ]
then
melos exec -c 1 --scope="$FLUTTERFIRE_PLUGIN_SCOPE_EXAMPLE" -- \
flutter build ios --no-codesign --simulator --debug --target="$TARGET_FILE" --dart-define=CI=true
flutter build ios $FLUTTER_COMMAND_FLAGS --no-codesign --simulator --debug --target="$TARGET_FILE" --dart-define=CI=true
exit
fi

if [ "$ACTION" == "macos" ]
then
melos exec -c 1 --scope="$FLUTTERFIRE_PLUGIN_SCOPE_EXAMPLE" -- \
flutter build macos --debug --target="$TARGET_FILE" --device-id=macos --dart-define=CI=true
flutter build macos $FLUTTER_COMMAND_FLAGS --debug --target="$TARGET_FILE" --device-id=macos --dart-define=CI=true
exit
fi
10 changes: 5 additions & 5 deletions .github/workflows/scripts/drive-example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ then
# Sleep to allow emulator to settle.
sleep 15
melos exec -c 1 --fail-fast --scope="$FLUTTERFIRE_PLUGIN_SCOPE_EXAMPLE" --dir-exists=test_driver -- \
flutter drive --no-pub --target=./test_driver/MELOS_PARENT_PACKAGE_NAME_e2e.dart --dart-define=CI=true
flutter drive $FLUTTER_COMMAND_FLAGS --no-pub --target=./test_driver/MELOS_PARENT_PACKAGE_NAME_e2e.dart --dart-define=CI=true
exit
fi

Expand All @@ -22,7 +22,7 @@ then
# Uncomment following line to have simulator logs printed out for debugging purposes.
# xcrun simctl spawn booted log stream --predicate 'eventMessage contains "flutter"' &
melos exec -c 1 --fail-fast --scope="$FLUTTERFIRE_PLUGIN_SCOPE_EXAMPLE" --dir-exists=test_driver -- \
flutter drive -d \"$SIMULATOR\" --no-pub --target=./test_driver/MELOS_PARENT_PACKAGE_NAME_e2e.dart --dart-define=CI=true
flutter drive $FLUTTER_COMMAND_FLAGS -d \"$SIMULATOR\" --no-pub --target=./test_driver/MELOS_PARENT_PACKAGE_NAME_e2e.dart --dart-define=CI=true
MELOS_EXIT_CODE=$?
xcrun simctl shutdown "$SIMULATOR"
exit $MELOS_EXIT_CODE
Expand All @@ -31,15 +31,15 @@ fi
if [ "$ACTION" == "macos" ]
then
melos exec -c 1 --fail-fast --scope="$FLUTTERFIRE_PLUGIN_SCOPE_EXAMPLE" --dir-exists=test_driver -- \
flutter drive -d macos --no-pub --target=./test_driver/MELOS_PARENT_PACKAGE_NAME_e2e.dart --dart-define=CI=true
flutter drive $FLUTTER_COMMAND_FLAGS -d macos --no-pub --target=./test_driver/MELOS_PARENT_PACKAGE_NAME_e2e.dart --dart-define=CI=true
exit
fi

if [ "$ACTION" == "web" ]
then
melos bootstrap
melos bootstrap --scope="*firebase_core*" --scope="$FLUTTERFIRE_PLUGIN_SCOPE"
chromedriver --port=4444 &
melos exec -c 1 --scope="$FLUTTERFIRE_PLUGIN_SCOPE_EXAMPLE" --dir-exists=web -- \
flutter drive --no-pub --verbose-system-logs --device-id=web-server --target=./test_driver/MELOS_PARENT_PACKAGE_NAME_e2e.dart --dart-define=CI=true
flutter drive $FLUTTER_COMMAND_FLAGS --no-pub --verbose-system-logs --device-id=web-server --target=./test_driver/MELOS_PARENT_PACKAGE_NAME_e2e.dart --dart-define=CI=true
exit
fi
62 changes: 26 additions & 36 deletions packages/firebase_database/example/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,62 +1,52 @@
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 29

lintOptions {
disable 'InvalidPackage'
}

defaultConfig {
applicationId 'io.flutter.plugins.firebasedatabaseexample'
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
compileSdkVersion 29

lintOptions {
disable 'InvalidPackage'
}

defaultConfig {
applicationId "io.flutter.plugins.firebasedatabaseexample"
minSdkVersion 16
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}

buildTypes {
release {
signingConfig signingConfigs.debug
}
}
}

flutter {
source '../..'
}

dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
source '../..'
}

apply plugin: 'com.google.gms.google-services'
Original file line number Diff line number Diff line change
@@ -1,31 +1,47 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.flutter.plugins.firebasedatabaseexample">

<uses-permission android:name="android.permission.INTERNET"/>

<application android:name="io.flutter.app.FlutterApplication" android:label="firebase_database_example" android:icon="@mipmap/ic_launcher">
<activity android:name=".EmbeddingV1Activity"
android:launchMode="singleTop"
android:theme="@android:style/Theme.Black.NoTitleBar"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection"
android:hardwareAccelerated="true"
android:exported="true"
android:windowSoftInputMode="adjustResize">
</activity>

<activity android:name="io.flutter.embedding.android.FlutterActivity"
android:theme="@android:style/Theme.Black.NoTitleBar"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<meta-data android:name="flutterEmbedding" android:value="2"/>
</application>
package="io.flutter.plugins.firebasedatabaseexample">
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="firebase_database_example"
android:icon="@mipmap/ic_launcher">
<activity
android:name="io.flutter.plugins.firebasedatabaseexample.MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package io.flutter.plugins.firebasedatabaseexample;

import io.flutter.embedding.android.FlutterActivity;

public class MainActivity extends FlutterActivity {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" />

<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
</layer-list>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting -->
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">@android:color/white</item>
</style>
</resources>
18 changes: 7 additions & 11 deletions packages/firebase_database/example/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
include ':app'

def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()

def plugins = new Properties()
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
if (pluginsFile.exists()) {
pluginsFile.withInputStream { stream -> plugins.load(stream) }
}
assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }

plugins.each { name, path ->
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
include ":$name"
project(":$name").projectDir = pluginDirectory
}
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
Loading