Skip to content

Commit

Permalink
fix: fix verify
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyokone committed Oct 12, 2022
1 parent 107d662 commit 8241146
Show file tree
Hide file tree
Showing 19 changed files with 32 additions and 48 deletions.
Expand Up @@ -17,9 +17,7 @@ part of cloud_firestore;
/// ```
class FirebaseFirestore extends FirebasePluginPlatform {
FirebaseFirestore._({required this.app})
: super(app.name, 'plugins.flutter.io/firebase_firestore') {
FirebasePluginPlatform.verify(instance);
}
: super(app.name, 'plugins.flutter.io/firebase_firestore');

static final Map<String, FirebaseFirestore> _cachedInstances = {};

Expand Down
Expand Up @@ -11,9 +11,7 @@ part of cloud_functions;
class FirebaseFunctions extends FirebasePluginPlatform {
FirebaseFunctions._({required this.app, String? region})
: _region = region ??= 'us-central1',
super(app.name, 'plugins.flutter.io/firebase_functions') {
FirebasePluginPlatform.verify(instance);
}
super(app.name, 'plugins.flutter.io/firebase_functions');

// Cached and lazily loaded instance of [FirebaseFunctionsPlatform] to avoid
// creating a [MethodChannelFirebaseFunctions] when not needed or creating an
Expand Down
Expand Up @@ -7,9 +7,7 @@ part of firebase_analytics;
/// Firebase Analytics API.
class FirebaseAnalytics extends FirebasePluginPlatform {
FirebaseAnalytics._({required this.app})
: super(app.name, 'plugins.flutter.io/firebase_analytics') {
FirebasePluginPlatform.verify(instance);
}
: super(app.name, 'plugins.flutter.io/firebase_analytics');

/// Namespace for analytics API available on Android only. This is deprecated in favor of
/// `FirebaseAnalytics.instance.setSessionTimeoutDuration()`.
Expand Down
Expand Up @@ -9,9 +9,7 @@ class FirebaseAppCheck extends FirebasePluginPlatform {
static Map<String, FirebaseAppCheck> _firebaseAppCheckInstances = {};

FirebaseAppCheck._({required this.app})
: super(app.name, 'plugins.flutter.io/firebase_app_check') {
FirebasePluginPlatform.verify(instance);
}
: super(app.name, 'plugins.flutter.io/firebase_app_check');

/// Cached instance of [FirebaseAppCheck];
static FirebaseAppCheck? _instance;
Expand Down
Expand Up @@ -6,9 +6,7 @@ part of firebase_app_installations;

class FirebaseInstallations extends FirebasePluginPlatform {
FirebaseInstallations._({required this.app})
: super(app.name, 'plugins.flutter.io/firebase_app_installations') {
FirebasePluginPlatform.verify(instance);
}
: super(app.name, 'plugins.flutter.io/firebase_app_installations');

// Cached and lazily loaded instance of [FirebaseAppInstallationsPlatform] to avoid
// creating a [MethodChannelFirebaseInstallations] when not needed or creating an
Expand Down
Expand Up @@ -37,9 +37,7 @@ class FirebaseAuth extends FirebasePluginPlatform {

FirebaseAuth._({required this.app, Persistence? persistence})
: _persistence = persistence,
super(app.name, 'plugins.flutter.io/firebase_auth') {
FirebasePluginPlatform.verify(instance);
}
super(app.name, 'plugins.flutter.io/firebase_auth');

/// Returns an instance using the default [FirebaseApp].
static FirebaseAuth get instance {
Expand Down
Expand Up @@ -66,7 +66,7 @@ abstract class RecaptchaVerifierFactoryPlatform extends PlatformInterface {
}

/// Ensures that a delegate class extends [RecaptchaVerifierFactoryPlatform].
static void verify(RecaptchaVerifierFactoryPlatform instance) {
static void verifyExtends(RecaptchaVerifierFactoryPlatform instance) {
PlatformInterface.verify(instance, _token);
}

Expand Down
Expand Up @@ -46,7 +46,7 @@ void main() {
group('verify()', () {
test('calls successfully', () {
try {
RecaptchaVerifierFactoryPlatform.verify(
RecaptchaVerifierFactoryPlatform.verifyExtends(
recaptchaVerifierFactoryPlatform);
return;
} catch (_) {
Expand Down
Expand Up @@ -10,9 +10,7 @@ part of firebase_crashlytics;
/// You can get an instance by calling [FirebaseCrashlytics.instance].
class FirebaseCrashlytics extends FirebasePluginPlatform {
FirebaseCrashlytics._({required this.app})
: super(app.name, 'plugins.flutter.io/firebase_crashlytics') {
FirebasePluginPlatform.verify(instance);
}
: super(app.name, 'plugins.flutter.io/firebase_crashlytics');

/// Cached instance of [FirebaseCrashlytics];
static FirebaseCrashlytics? _instance;
Expand All @@ -33,7 +31,6 @@ class FirebaseCrashlytics extends FirebasePluginPlatform {
/// Returns an instance using the default [FirebaseApp].
static FirebaseCrashlytics get instance {
_instance ??= FirebaseCrashlytics._(app: Firebase.app());

return _instance!;
}

Expand Down
Expand Up @@ -21,7 +21,6 @@ class FirebaseDatabase extends FirebasePluginPlatform {

FirebaseDatabase._({required this.app, this.databaseURL})
: super(app.name, 'plugins.flutter.io/firebase_database') {
FirebasePluginPlatform.verify(instance);
if (databaseURL != null && databaseURL!.endsWith('/')) {
databaseURL = databaseURL!.substring(0, databaseURL!.length - 1);
}
Expand Down
Expand Up @@ -7,7 +7,9 @@ part of firebase_database;
/// Represents a query over the data at a particular location.
class Query {
Query._(this._queryDelegate, [QueryModifiers? modifiers])
: _modifiers = modifiers ?? QueryModifiers([]);
: _modifiers = modifiers ?? QueryModifiers([]) {
QueryPlatform.verify(_queryDelegate);
}

final QueryPlatform _queryDelegate;

Expand Down
Expand Up @@ -12,6 +12,16 @@ abstract class QueryPlatform extends PlatformInterface {

static final Object _token = Object();

/// Throws an [AssertionError] if [instance] does not extend
/// [QueryPlatform].
///
/// This is used by the app-facing [Query] to ensure that
/// the object in which it's going to delegate calls has been
/// constructed properly.
static void verify(QueryPlatform instance) {
PlatformInterface.verify(instance, _token);
}

/// Create a [QueryPlatform] instance
QueryPlatform({
required this.database,
Expand Down
Expand Up @@ -9,9 +9,7 @@ part of firebase_dynamic_links;
/// You can get an instance by calling [FirebaseDynamicLinks.instance].
class FirebaseDynamicLinks extends FirebasePluginPlatform {
FirebaseDynamicLinks._({required this.app})
: super(app.name, 'plugins.flutter.io/firebase_dynamic_links') {
FirebasePluginPlatform.verify(instance);
}
: super(app.name, 'plugins.flutter.io/firebase_dynamic_links');

static final Map<String, FirebaseDynamicLinks> _cachedInstances = {};

Expand Down
Expand Up @@ -9,9 +9,7 @@ import 'package:firebase_in_app_messaging_platform_interface/firebase_in_app_mes

class FirebaseInAppMessaging extends FirebasePluginPlatform {
FirebaseInAppMessaging._({required this.app})
: super(app.name, 'plugins.flutter.io/firebase_in_app_messaging') {
FirebasePluginPlatform.verify(instance);
}
: super(app.name, 'plugins.flutter.io/firebase_in_app_messaging');

/// The [FirebaseApp] for this current [FirebaseAnalytics] instance.
final FirebaseApp app;
Expand Down
Expand Up @@ -25,9 +25,7 @@ class FirebaseMessaging extends FirebasePluginPlatform {
FirebaseApp app;

FirebaseMessaging._({required this.app})
: super(app.name, 'plugins.flutter.io/firebase_messaging') {
FirebasePluginPlatform.verify(instance);
}
: super(app.name, 'plugins.flutter.io/firebase_messaging');

/// Returns an instance using the default [FirebaseApp].
static FirebaseMessaging get instance {
Expand Down
Expand Up @@ -6,9 +6,7 @@ part of firebase_ml_model_downloader;

class FirebaseModelDownloader extends FirebasePluginPlatform {
FirebaseModelDownloader._({required this.app})
: super(app.name, 'plugins.flutter.io/firebase_ml_model_downloader') {
FirebasePluginPlatform.verify(instance);
}
: super(app.name, 'plugins.flutter.io/firebase_ml_model_downloader');

// Cached and lazily loaded instance of [FirebaseModelDownloaderPlatform] to avoid
// creating a [MethodChannelFirebaseFunctions] when not needed or creating an
Expand Down
Expand Up @@ -9,9 +9,7 @@ part of firebase_performance;
/// You can get an instance by calling [FirebasePerformance.instance].
class FirebasePerformance extends FirebasePluginPlatform {
FirebasePerformance._({required this.app})
: super(app.name, 'plugins.flutter.io/firebase_performance') {
FirebasePluginPlatform.verify(instance);
}
: super(app.name, 'plugins.flutter.io/firebase_performance');

// Cached and lazily loaded instance of [FirebasePerformancePlatform] to avoid
// creating a [MethodChannelFirebasePerformance] when not needed or creating an
Expand Down
Expand Up @@ -11,9 +11,7 @@ part of firebase_remote_config;
// ignore: prefer_mixin
class FirebaseRemoteConfig extends FirebasePluginPlatform with ChangeNotifier {
FirebaseRemoteConfig._({required this.app})
: super(app.name, 'plugins.flutter.io/firebase_remote_config') {
FirebasePluginPlatform.verify(instance);
}
: super(app.name, 'plugins.flutter.io/firebase_remote_config');

// Cached instances of [FirebaseRemoteConfig].
static final Map<String, FirebaseRemoteConfig>
Expand All @@ -39,7 +37,9 @@ class FirebaseRemoteConfig extends FirebasePluginPlatform with ChangeNotifier {
/// Returns an instance using the specified [FirebaseApp].
static FirebaseRemoteConfig instanceFor({required FirebaseApp app}) {
return _firebaseRemoteConfigInstances.putIfAbsent(app.name, () {
return FirebaseRemoteConfig._(app: app);
final instance = FirebaseRemoteConfig._(app: app);
FirebasePluginPlatform.verify(instance);
return instance;
});
}

Expand Down
Expand Up @@ -8,9 +8,7 @@ part of firebase_storage;
/// The entrypoint for [FirebaseStorage].
class FirebaseStorage extends FirebasePluginPlatform {
FirebaseStorage._({required this.app, required this.bucket})
: super(app.name, 'plugins.flutter.io/firebase_storage') {
FirebasePluginPlatform.verify(instance);
}
: super(app.name, 'plugins.flutter.io/firebase_storage');

// Cached and lazily loaded instance of [FirebaseStoragePlatform] to avoid
// creating a [MethodChannelStorage] when not needed or creating an
Expand Down

0 comments on commit 8241146

Please sign in to comment.