diff --git a/analysis_options.yaml b/analysis_options.yaml index 2156d3804df6..d384eac0e616 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -6,7 +6,6 @@ include: all_lint_rules.yaml analyzer: # TODO(rrousselGit): disable implicit-cast/implicit-dynamic errors: - import_of_legacy_library_into_null_safe: ignore # Otherwise cause the import of all_lint_rules to warn because of some rules conflicts. # We explicitly enabled even conflicting rules and are fixing the conflict # in this file @@ -43,6 +42,8 @@ linter: prefer_mixin: false public_member_api_docs: false + invalid_runtime_check_with_js_interop_types: true + ############# # Far too verbose, and not that big of a deal when using parameter_assignments diff --git a/packages/cloud_firestore/cloud_firestore_web/lib/src/interop/firestore.dart b/packages/cloud_firestore/cloud_firestore_web/lib/src/interop/firestore.dart index 7f05e9e5e41c..45f787ca0206 100644 --- a/packages/cloud_firestore/cloud_firestore_web/lib/src/interop/firestore.dart +++ b/packages/cloud_firestore/cloud_firestore_web/lib/src/interop/firestore.dart @@ -257,10 +257,14 @@ class LoadBundleTaskProgress LoadBundleTaskProgress._fromJsObject( firestore_interop.LoadBundleTaskProgressJsImpl jsObject, ) : taskState = convertToTaskState(jsObject.taskState.toDart.toLowerCase()), + // Cannot be done with Dart 3.2 constraints + // ignore: invalid_runtime_check_with_js_interop_types bytesLoaded = jsObject.bytesLoaded is JSNumber ? (jsObject.bytesLoaded as JSNumber).toDartInt : int.parse((jsObject.bytesLoaded as JSString).toDart), documentsLoaded = jsObject.documentsLoaded.toDartInt, + // Cannot be done with Dart 3.2 constraints + // ignore: invalid_runtime_check_with_js_interop_types totalBytes = jsObject.totalBytes is JSNumber ? (jsObject.totalBytes as JSNumber).toDartInt : int.parse((jsObject.totalBytes as JSString).toDart), diff --git a/packages/cloud_firestore/cloud_firestore_web/lib/src/interop/utils/utils.dart b/packages/cloud_firestore/cloud_firestore_web/lib/src/interop/utils/utils.dart index 33d3a5a132de..c50b19031cc5 100644 --- a/packages/cloud_firestore/cloud_firestore_web/lib/src/interop/utils/utils.dart +++ b/packages/cloud_firestore/cloud_firestore_web/lib/src/interop/utils/utils.dart @@ -12,6 +12,8 @@ import '../firestore.dart'; /// Returns Dart representation from JS Object. dynamic dartify(dynamic object) { // Convert JSObject to Dart equivalents directly + // Cannot be done with Dart 3.2 constraints + // ignore: invalid_runtime_check_with_js_interop_types if (object is! JSObject) { return object; } @@ -85,11 +87,14 @@ JSAny? jsify(Object? dartObject) { return jsifyFieldValue(dartObject); } + // Cannot be done with Dart 3.2 constraints + // ignore: invalid_runtime_check_with_js_interop_types if (dartObject is BytesJsImpl) { return dartObject as JSAny; } - // NOTE: if the firestore JS lib is not imported, we'll get a DDC warning here + // Cannot be done with Dart 3.2 constraints + // ignore: invalid_runtime_check_with_js_interop_types if (dartObject is GeoPointJsImpl) { return dartObject as JSAny; } diff --git a/packages/cloud_firestore/cloud_firestore_web/lib/src/utils/decode_utility.dart b/packages/cloud_firestore/cloud_firestore_web/lib/src/utils/decode_utility.dart index d434466cc64e..02ac06208251 100644 --- a/packages/cloud_firestore/cloud_firestore_web/lib/src/utils/decode_utility.dart +++ b/packages/cloud_firestore/cloud_firestore_web/lib/src/utils/decode_utility.dart @@ -35,12 +35,16 @@ class DecodeUtility { /// Decodes an incoming value to its proper type. static dynamic valueDecode( dynamic value, FirebaseFirestorePlatform firestore) { + // Cannot be done with Dart 3.2 constraints + // ignore: invalid_runtime_check_with_js_interop_types if (value is JSObject && value.instanceof(GeoPointConstructor as JSFunction)) { return GeoPoint((value as GeoPointJsImpl).latitude.toDartDouble, (value as GeoPointJsImpl).longitude.toDartDouble); } else if (value is DateTime) { return Timestamp.fromDate(value); + // Cannot be done with Dart 3.2 constraints + // ignore: invalid_runtime_check_with_js_interop_types } else if (value is JSObject && value.instanceof(BytesConstructor as JSFunction)) { return Blob((value as BytesJsImpl).toUint8Array().toDart); diff --git a/packages/cloud_functions/cloud_functions_web/lib/interop/functions.dart b/packages/cloud_functions/cloud_functions_web/lib/interop/functions.dart index a5af9f909b04..30319f68f5cb 100644 --- a/packages/cloud_functions/cloud_functions_web/lib/interop/functions.dart +++ b/packages/cloud_functions/cloud_functions_web/lib/interop/functions.dart @@ -89,6 +89,8 @@ class HttpsCallable extends JsObjectWrapper { /// Returns Dart representation from JS Object. dynamic _dartify(dynamic object) { // Convert JSObject to Dart equivalents directly + // Cannot be done with Dart 3.2 constraints + // ignore: invalid_runtime_check_with_js_interop_types if (object is! JSObject) { return object; } diff --git a/packages/firebase_analytics/firebase_analytics_web/lib/interop/analytics.dart b/packages/firebase_analytics/firebase_analytics_web/lib/interop/analytics.dart index a178e700c712..37fcbc24def4 100644 --- a/packages/firebase_analytics/firebase_analytics_web/lib/interop/analytics.dart +++ b/packages/firebase_analytics/firebase_analytics_web/lib/interop/analytics.dart @@ -34,7 +34,7 @@ class Analytics extends JsObjectWrapper { static Future isSupported() async { final result = await analytics_interop.isSupported().toDart; - return result! as bool; + return (result! as JSBoolean).toDart; } /// Non-null App for this instance of analytics service. diff --git a/packages/firebase_auth/firebase_auth_web/lib/firebase_auth_web.dart b/packages/firebase_auth/firebase_auth_web/lib/firebase_auth_web.dart index 257e866244cb..0e3eced01aa0 100644 --- a/packages/firebase_auth/firebase_auth_web/lib/firebase_auth_web.dart +++ b/packages/firebase_auth/firebase_auth_web/lib/firebase_auth_web.dart @@ -489,6 +489,8 @@ class FirebaseAuthWeb extends FirebaseAuthPlatform { .setItem(getOriginName(delegate.app.name), origin); } } catch (e) { + // Cannot be done with 3.2 constraints + // ignore: invalid_runtime_check_with_js_interop_types if (e is auth_interop.AuthError) { final String code = e.code.toDart; // this catches Firebase Error from web that occurs after hot reloading & hot restarting diff --git a/packages/firebase_auth/firebase_auth_web/lib/src/firebase_auth_web_recaptcha_verifier_factory.dart b/packages/firebase_auth/firebase_auth_web/lib/src/firebase_auth_web_recaptcha_verifier_factory.dart index 90ea2f89a109..116ba413b75e 100644 --- a/packages/firebase_auth/firebase_auth_web/lib/src/firebase_auth_web_recaptcha_verifier_factory.dart +++ b/packages/firebase_auth/firebase_auth_web/lib/src/firebase_auth_web_recaptcha_verifier_factory.dart @@ -154,7 +154,7 @@ class RecaptchaVerifierFactoryWeb extends RecaptchaVerifierFactoryPlatform { @override Future render() async { try { - return (await _delegate.render()).toInt(); + return await _delegate.render(); } catch (e) { throw getFirebaseAuthException(e); } diff --git a/packages/firebase_auth/firebase_auth_web/lib/src/interop/auth.dart b/packages/firebase_auth/firebase_auth_web/lib/src/interop/auth.dart index 2a4ba442da89..5acfc406fdac 100644 --- a/packages/firebase_auth/firebase_auth_web/lib/src/interop/auth.dart +++ b/packages/firebase_auth/firebase_auth_web/lib/src/interop/auth.dart @@ -127,7 +127,7 @@ class User extends UserInfo { Future getIdToken([bool forceRefresh = false]) => jsObject .getIdToken(forceRefresh.toJS) .toDart - .then((value) => value! as String); + .then((value) => (value! as JSString).toDart); /// Links the user account with the given credentials, and returns any /// available additional user information, such as user name. @@ -526,7 +526,7 @@ class Auth extends JsObjectWrapper { Future> fetchSignInMethodsForEmail(String email) => auth_interop .fetchSignInMethodsForEmail(jsObject, email.toJS) .toDart - .then((value) => List.from(value! as List)); + .then((value) => List.from((value! as JSArray).toDart)); /// Checks if an incoming link is a sign-in with email link. bool isSignInWithEmailLink(String emailLink) => @@ -753,7 +753,7 @@ class Auth extends JsObjectWrapper { Future verifyPasswordResetCode(String code) => auth_interop .verifyPasswordResetCode(jsObject, code.toJS) .toDart - .then((value) => value! as String); + .then((value) => (value! as JSString).toDart); } /// Represents an auth provider. @@ -1054,7 +1054,7 @@ class PhoneAuthProvider jsObject .verifyPhoneNumber(phoneOptions, applicationVerifier.jsObject) .toDart - .then((value) => value! as String); + .then((value) => (value! as JSString).toDart); /// Creates a phone auth credential given the verification ID /// from [verifyPhoneNumber] and the [verificationCode] that was sent to the @@ -1081,7 +1081,7 @@ abstract class ApplicationVerifier< /// Returns a Future containing string for a token that can be used to /// assert the validity of a request. Future verify() => - jsObject.verify().toDart.then((value) => value! as String); + jsObject.verify().toDart.then((value) => (value! as JSString).toDart); } /// reCAPTCHA verifier. @@ -1137,8 +1137,8 @@ class RecaptchaVerifier /// Renders the reCAPTCHA widget on the page. /// Returns a Future that resolves with the reCAPTCHA widget ID. - Future render() => - jsObject.render().toDart.then((value) => value! as num); + Future render() => + jsObject.render().toDart.then((value) => (value! as JSNumber).toDartInt); } /// A result from a phone number sign-in, link, or reauthenticate call. diff --git a/packages/firebase_core/firebase_core_web/lib/src/firebase_core_web.dart b/packages/firebase_core/firebase_core_web/lib/src/firebase_core_web.dart index bca05f6a6b25..d9c96702d286 100644 --- a/packages/firebase_core/firebase_core_web/lib/src/firebase_core_web.dart +++ b/packages/firebase_core/firebase_core_web/lib/src/firebase_core_web.dart @@ -87,7 +87,10 @@ class FirebaseCoreWeb extends FirebasePlatform { JSObject? ignored = globalContext.getProperty('flutterfire_ignore_scripts'.toJS); + // Cannot be done with Dart 3.2 constraints + // ignore: invalid_runtime_check_with_js_interop_types if (ignored is Iterable) { + // ignore: invalid_runtime_check_with_js_interop_types return (ignored! as Iterable) .map((e) => e.toString()) .toList(growable: false); diff --git a/packages/firebase_messaging/firebase_messaging_web/lib/firebase_messaging_web.dart b/packages/firebase_messaging/firebase_messaging_web/lib/firebase_messaging_web.dart index 8f9d2750cf6b..9c22d84524ea 100644 --- a/packages/firebase_messaging/firebase_messaging_web/lib/firebase_messaging_web.dart +++ b/packages/firebase_messaging/firebase_messaging_web/lib/firebase_messaging_web.dart @@ -145,7 +145,7 @@ class FirebaseMessagingWeb extends FirebaseMessagingPlatform { }) { return convertWebExceptions(() async { String status = - (await web.Notification.requestPermission().toDart) as String; + (await web.Notification.requestPermission().toDart).toDart; return utils.getNotificationSettings(status); }); } diff --git a/packages/firebase_messaging/firebase_messaging_web/lib/src/interop/messaging.dart b/packages/firebase_messaging/firebase_messaging_web/lib/src/interop/messaging.dart index a9d199a5c589..5e8de3c68ad7 100644 --- a/packages/firebase_messaging/firebase_messaging_web/lib/src/interop/messaging.dart +++ b/packages/firebase_messaging/firebase_messaging_web/lib/src/interop/messaging.dart @@ -31,8 +31,10 @@ class Messaging extends JsObjectWrapper { return _expando[jsObject] ??= Messaging._fromJsObject(jsObject); } - static Future isSupported() => - messaging_interop.isSupported().toDart.then((value) => value! as bool); + static Future isSupported() => messaging_interop + .isSupported() + .toDart + .then((value) => (value! as JSBoolean).toDart); Messaging._fromJsObject(messaging_interop.MessagingJsImpl jsObject) : super.fromJsObject(jsObject); @@ -45,13 +47,15 @@ class Messaging extends JsObjectWrapper { /// that can be used to send push messages to this user. Future getToken({String? vapidKey}) async { try { - final token = (await messaging_interop - .getToken( - jsObject, - vapidKey == null - ? null - : messaging_interop.GetTokenOptions(vapidKey: vapidKey.toJS)) - .toDart)! as String; + final token = ((await messaging_interop + .getToken( + jsObject, + vapidKey == null + ? null + : messaging_interop.GetTokenOptions( + vapidKey: vapidKey.toJS)) + .toDart)! as JSString) + .toDart; return token; } catch (err) { // A race condition can happen in which the service worker get registered diff --git a/packages/firebase_remote_config/firebase_remote_config_web/lib/src/interop/firebase_remote_config.dart b/packages/firebase_remote_config/firebase_remote_config_web/lib/src/interop/firebase_remote_config.dart index 569be577a9be..156ef59dc6a3 100644 --- a/packages/firebase_remote_config/firebase_remote_config_web/lib/src/interop/firebase_remote_config.dart +++ b/packages/firebase_remote_config/firebase_remote_config_web/lib/src/interop/firebase_remote_config.dart @@ -86,7 +86,7 @@ class RemoteConfig Future activate() async => remote_config_interop .activate(jsObject) .toDart - .then((value) => value! as bool); + .then((value) => (value! as JSBoolean).toDart); /// Ensures the last activated config are available to the getters. Future ensureInitialized() async => @@ -101,7 +101,7 @@ class RemoteConfig /// If the fetched configs were already activated, the promise will resolve to false. Future fetchAndActivate() async => remote_config_interop.fetchAndActivate(jsObject).toDart.then( - (value) => value! as bool, + (value) => (value! as JSBoolean).toDart, ); /// Returns all config values.