Skip to content
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

feat(firebase_remote_config)!: migrate to nullsafety #5686

Merged
merged 9 commits into from
Apr 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package io.flutter.plugins.firebase.firebaseremoteconfigexample;

import android.os.Bundle;
import dev.flutter.plugins.e2e.E2EPlugin;
import io.flutter.app.FlutterActivity;
import io.flutter.plugins.firebase.core.FlutterFirebaseCorePlugin;
import io.flutter.plugins.firebase.firebaseremoteconfig.FirebaseRemoteConfigPlugin;
Expand All @@ -19,6 +18,5 @@ protected void onCreate(Bundle savedInstanceState) {
FirebaseRemoteConfigPlugin.registerWith(
registrarFor(
"io.flutter.plugins.firebase.firebaseremoteconfig.FirebaseRemoteConfigPlugin"));
E2EPlugin.registerWith(registrarFor("dev.flutter.plugins.e2e.E2EPlugin"));
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart=2.9

import 'dart:async';

import 'package:firebase_core/firebase_core.dart';
Expand All @@ -19,14 +17,16 @@ void main() {
future: setupRemoteConfig(),
builder: (BuildContext context, AsyncSnapshot<RemoteConfig> snapshot) {
return snapshot.hasData
? WelcomeWidget(remoteConfig: snapshot.data)
? WelcomeWidget(remoteConfig: snapshot.requireData)
: Container();
},
)));
}

class WelcomeWidget extends AnimatedWidget {
WelcomeWidget({this.remoteConfig}) : super(listenable: remoteConfig);
WelcomeWidget({
required this.remoteConfig,
}) : super(listenable: remoteConfig);

final RemoteConfig remoteConfig;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ dependency_overrides:
path: ../../firebase_remote_config_platform_interface

dev_dependencies:
pedantic: ^1.8.0
integration_test:
sdk: flutter
flutter_test:
sdk: flutter
flutter_driver:
sdk: flutter
pedantic: ^1.8.0
test: any
e2e: ^0.6.1

flutter:
uses-material-design: true
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
// @dart=2.9

import 'package:flutter_test/flutter_test.dart';
import 'package:e2e/e2e.dart';
import 'package:integration_test/integration_test.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_remote_config/firebase_remote_config.dart';

void main() {
E2EWidgetsFlutterBinding.ensureInitialized();
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

group('$RemoteConfig', () {
RemoteConfig remoteConfig;
late RemoteConfig remoteConfig;

setUp(() async {
await Firebase.initializeApp();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// @dart=2.9
import 'package:integration_test/integration_test_driver.dart';

import 'package:e2e/e2e_driver.dart' as e2e;

void main() => e2e.main();
Future<void> main() => integrationDriver();
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,11 @@ - (void)fetchAndActivate:(id)arguments withMethodCallResult:(FLTFirebaseMethodCa
if (error != nil) {
result.error(nil, nil, nil, error);
} else {
result.success(nil);
if (status == FIRRemoteConfigFetchAndActivateStatusSuccessFetchedFromRemote) {
result.success(@(YES));
} else {
result.success(@(NO));
}
}
}];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart=2.9

library firebase_remote_config;

import 'dart:async';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart=2.9

part of firebase_remote_config;

/// The entry point for accessing Remote Config.
Expand All @@ -12,29 +10,20 @@ part of firebase_remote_config;
/// [RemoteConfig.instance] is async.
// ignore: prefer_mixin
class RemoteConfig extends FirebasePluginPlatform with ChangeNotifier {
RemoteConfig._({this.app})
RemoteConfig._({required this.app})
: super(app.name, 'plugins.flutter.io/firebase_remote_config');

// Cached instances of [FirebaseRemoteConfig].
static final Map<String, RemoteConfig> _firebaseRemoteConfigInstances = {};

// Cached and lazily loaded instance of [FirebaseRemoteConfigPlatform]
// to avoid creating a [MethodChannelFirebaseRemoteConfig] when not needed
// or creating an instance with the default app before a user specifies an
// app.
FirebaseRemoteConfigPlatform _delegatePackingProperty;

/// Returns the underlying delegate implementation.
///
/// If called and no [_delegatePackingProperty] exists, it will first be
/// created and assigned before returning the delegate.
FirebaseRemoteConfigPlatform get _delegate {
return _delegatePackingProperty ??=
FirebaseRemoteConfigPlatform.instanceFor(
app: app,
pluginConstants: pluginConstants,
);
}
late final _delegate = FirebaseRemoteConfigPlatform.instanceFor(
app: app,
pluginConstants: pluginConstants,
);

/// The [FirebaseApp] this instance was initialized with.
final FirebaseApp app;
Expand All @@ -45,17 +34,10 @@ class RemoteConfig extends FirebasePluginPlatform with ChangeNotifier {
}

/// Returns an instance using the specified [FirebaseApp].
static RemoteConfig instanceFor({@required FirebaseApp app}) {
assert(app != null);

if (_firebaseRemoteConfigInstances.containsKey(app.name)) {
return _firebaseRemoteConfigInstances[app.name];
}

RemoteConfig newInstance = RemoteConfig._(app: app);
_firebaseRemoteConfigInstances[app.name] = newInstance;

return newInstance;
static RemoteConfig instanceFor({required FirebaseApp app}) {
return _firebaseRemoteConfigInstances.putIfAbsent(app.name, () {
return RemoteConfig._(app: app);
});
}

/// Returns the [DateTime] of the last successful fetch.
Expand Down Expand Up @@ -113,39 +95,31 @@ class RemoteConfig extends FirebasePluginPlatform with ChangeNotifier {

/// Gets the value for a given key as a bool.
bool getBool(String key) {
assert(key != null);
return _delegate.getBool(key);
}

/// Gets the value for a given key as an int.
int getInt(String key) {
assert(key != null);
return _delegate.getInt(key);
}

/// Gets the value for a given key as a double.
double getDouble(String key) {
assert(key != null);
return _delegate.getDouble(key);
}

/// Gets the value for a given key as a String.
String getString(String key) {
assert(key != null);
return _delegate.getString(key);
}

/// Gets the [RemoteConfigValue] for a given key.
RemoteConfigValue getValue(String key) {
assert(key != null);
return _delegate.getValue(key);
}

/// Sets the [RemoteConfigSettings] for the current instance.
Future<void> setConfigSettings(RemoteConfigSettings remoteConfigSettings) {
assert(remoteConfigSettings != null);
assert(remoteConfigSettings.fetchTimeout != null);
assert(remoteConfigSettings.minimumFetchInterval != null);
assert(!remoteConfigSettings.fetchTimeout.isNegative);
assert(!remoteConfigSettings.minimumFetchInterval.isNegative);
// To be consistent with iOS fetchTimeout is set to the default
Expand All @@ -158,7 +132,6 @@ class RemoteConfig extends FirebasePluginPlatform with ChangeNotifier {

/// Sets the default parameter values for the current instance.
Future<void> setDefaults(Map<String, dynamic> defaultParameters) {
assert(defaultParameters != null);
return _delegate.setDefaults(defaultParameters);
}
}
Loading