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!: migrate firebase_remote_config nullsafety #5397

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from 9 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 @@ -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,7 +10,7 @@ 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})
daniloadorno marked this conversation as resolved.
Show resolved Hide resolved
: super(app.name, 'plugins.flutter.io/firebase_remote_config');

// Cached instances of [FirebaseRemoteConfig].
Expand All @@ -22,18 +20,18 @@ class RemoteConfig extends FirebasePluginPlatform with ChangeNotifier {
// to avoid creating a [MethodChannelFirebaseRemoteConfig] when not needed
// or creating an instance with the default app before a user specifies an
// app.
FirebaseRemoteConfigPlatform _delegatePackingProperty;
late final FirebaseRemoteConfigPlatform _delegatePackingProperty =
daniloadorno marked this conversation as resolved.
Show resolved Hide resolved
FirebaseRemoteConfigPlatform.instanceFor(
app: app,
pluginConstants: pluginConstants,
);

/// 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,
);
return _delegatePackingProperty;
}

/// The [FirebaseApp] this instance was initialized with.
Expand All @@ -45,11 +43,9 @@ class RemoteConfig extends FirebasePluginPlatform with ChangeNotifier {
}

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

static RemoteConfig instanceFor({required FirebaseApp app}) {
if (_firebaseRemoteConfigInstances.containsKey(app.name)) {
daniloadorno marked this conversation as resolved.
Show resolved Hide resolved
return _firebaseRemoteConfigInstances[app.name];
return _firebaseRemoteConfigInstances[app.name]!;
}

RemoteConfig newInstance = RemoteConfig._(app: app);
Expand All @@ -63,17 +59,17 @@ class RemoteConfig extends FirebasePluginPlatform with ChangeNotifier {
/// If no successful fetch has been made a [DateTime] representing
/// the epoch (1970-01-01 UTC) is returned.
DateTime get lastFetchTime {
return _delegate.lastFetchTime;
return _delegate.lastFetchTime!;
daniloadorno marked this conversation as resolved.
Show resolved Hide resolved
}

/// Returns the status of the last fetch attempt.
RemoteConfigFetchStatus get lastFetchStatus {
return _delegate.lastFetchStatus;
return _delegate.lastFetchStatus!;
}

/// Returns the [RemoteConfigSettings] of the current instance.
RemoteConfigSettings get settings {
return _delegate.settings;
return _delegate.settings!;
}

/// Makes the last fetched config available to getters.
Expand Down Expand Up @@ -113,39 +109,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 +146,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