Skip to content

feat(web): Update _web constraints to Dart 3.4 #12851

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

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 2 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/_flutterfire_internals/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repository: https://github.com/firebase/flutterfire/tree/master/packages/_flutte
version: 1.3.35

environment:
sdk: '>=3.2.0 <4.0.0'
sdk: ^3.4.0
flutter: '>=3.3.0'

dependencies:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,11 @@ class LoadBundleTaskProgress
LoadBundleTaskProgress._fromJsObject(
firestore_interop.LoadBundleTaskProgressJsImpl jsObject,
) : taskState = convertToTaskState(jsObject.taskState.toDart.toLowerCase()),
bytesLoaded = jsObject.bytesLoaded is JSNumber
bytesLoaded = jsObject.bytesLoaded.isA<JSNumber>()
? (jsObject.bytesLoaded as JSNumber).toDartInt
: int.parse((jsObject.bytesLoaded as JSString).toDart),
documentsLoaded = jsObject.documentsLoaded.toDartInt,
totalBytes = jsObject.totalBytes is JSNumber
totalBytes = jsObject.totalBytes.isA<JSNumber>()
? (jsObject.totalBytes as JSNumber).toDartInt
: int.parse((jsObject.totalBytes as JSString).toDart),
totalDocuments = jsObject.totalDocuments.toDartInt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,16 +396,9 @@ extension FieldPathExtension on FieldPath {
}

@JS('GeoPoint')
@staticInterop
external GeoPointJsImpl get GeoPointConstructor;

@JS('GeoPoint')
@staticInterop
class GeoPointJsImpl {
extension type GeoPointJsImpl._(JSObject _) implements JSObject {
external factory GeoPointJsImpl(JSNumber latitude, JSNumber longitude);
}

extension GeoPointJsImplExtension on GeoPointJsImpl {
/// The latitude of this GeoPoint instance.
external JSNumber get latitude;

Expand All @@ -417,19 +410,11 @@ extension GeoPointJsImplExtension on GeoPointJsImpl {
}

@JS('Bytes')
@staticInterop
external BytesJsImpl get BytesConstructor;

@JS('Bytes')
@staticInterop
@anonymous
abstract class BytesJsImpl {
extension type BytesJsImpl(JSObject _) implements JSObject {
external static BytesJsImpl fromBase64JSString(JSString base64);

external static BytesJsImpl fromUint8Array(JSUint8Array list);
}

extension BytesJsImplExtension on BytesJsImpl {
external JSString toBase64();

external JSUint8Array toUint8Array();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import '../firestore.dart';
/// Returns Dart representation from JS Object.
dynamic dartify(dynamic object) {
// Convert JSObject to Dart equivalents directly
if (object is! JSObject) {
if (object.isA<JSObject>()) {
return object;
}

Expand All @@ -21,15 +21,15 @@ dynamic dartify(dynamic object) {
if (jsObject.instanceof(DocumentReferenceJsConstructor as JSFunction)) {
return DocumentReference.getInstance(jsObject as DocumentReferenceJsImpl);
}
if (jsObject.instanceof(GeoPointConstructor as JSFunction)) {
if (jsObject.isA<GeoPointJsImpl>()) {
return jsObject;
}
if (jsObject.instanceof(TimestampJsConstructor as JSFunction)) {
final castedJSObject = jsObject as TimestampJsImpl;
return Timestamp(
castedJSObject.seconds.toDartInt, castedJSObject.nanoseconds.toDartInt);
}
if (jsObject.instanceof(BytesConstructor as JSFunction)) {
if (jsObject.isA<BytesJsImpl>()) {
return jsObject as BytesJsImpl;
}

Expand Down Expand Up @@ -85,11 +85,12 @@ JSAny? jsify(Object? dartObject) {
return jsifyFieldValue(dartObject);
}

// 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
// ignore: invalid_runtime_check_with_js_interop_types
if (dartObject is GeoPointJsImpl) {
return dartObject as JSAny;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import 'package:cloud_firestore_web/src/interop/firestore.dart';
import '../interop/firestore.dart' as firestore_interop;

/// Class containing static utility methods to decode firestore data.
class DecodeUtility {
abstract final class DecodeUtility {
/// Decodes the values on an incoming Map to their proper types.
static Map<String, dynamic>? decodeMapData(
Map<String, dynamic>? data, FirebaseFirestorePlatform firestore) {
Expand All @@ -35,14 +35,12 @@ class DecodeUtility {
/// Decodes an incoming value to its proper type.
static dynamic valueDecode(
dynamic value, FirebaseFirestorePlatform firestore) {
if (value is JSObject &&
value.instanceof(GeoPointConstructor as JSFunction)) {
return GeoPoint((value as GeoPointJsImpl).latitude.toDartDouble,
(value as GeoPointJsImpl).longitude.toDartDouble);
if (value.isA<GeoPointJsImpl>()) {
final val = value! as GeoPointJsImpl;
return GeoPoint(val.latitude.toDartDouble, val.longitude.toDartDouble);
} else if (value is DateTime) {
return Timestamp.fromDate(value);
} else if (value is JSObject &&
value.instanceof(BytesConstructor as JSFunction)) {
} else if (value.isA<BytesJsImpl>()) {
return Blob((value as BytesJsImpl).toUint8Array().toDart);
} else if (value is firestore_interop.DocumentReference) {
return (firestore as FirebaseFirestoreWeb).doc(value.path);
Expand Down
2 changes: 1 addition & 1 deletion packages/cloud_firestore/cloud_firestore_web/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repository: https://github.com/firebase/flutterfire/tree/master/packages/cloud_f
version: 3.12.5

environment:
sdk: '>=3.2.0 <4.0.0'
sdk: ^3.4.0
flutter: '>=3.3.0'

dependencies:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class HttpsCallable extends JsObjectWrapper<JSFunction> {
/// Returns Dart representation from JS Object.
dynamic _dartify(dynamic object) {
// Convert JSObject to Dart equivalents directly
if (object is! JSObject) {
if (object.isA<JSObject>()) {
return object;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/cloud_functions/cloud_functions_web/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repository: https://github.com/firebase/flutterfire/tree/master/packages/cloud_f
version: 4.9.6

environment:
sdk: '>=3.2.0 <4.0.0'
sdk: ^3.4.0
flutter: '>=3.3.0'

dependencies:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Analytics extends JsObjectWrapper<analytics_interop.AnalyticsJsImpl> {

static Future<bool> 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repository: https://github.com/firebase/flutterfire/tree/master/packages/firebas
version: 0.5.7+7

environment:
sdk: '>=3.2.0 <4.0.0'
sdk: ^3.4.0
flutter: '>=3.3.0'

dependencies:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ homepage: https://github.com/firebase/flutterfire/tree/master/packages/firebase_
version: 0.1.2+7

environment:
sdk: '>=3.2.0 <4.0.0'
sdk: ^3.4.0
flutter: '>=3.3.0'

dependencies:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ homepage: https://github.com/firebase/flutterfire/tree/master/packages/firebase_
repository: https://github.com/firebase/flutterfire/tree/master/packages/firebase_app_installations/firebase_app_installations_web

environment:
sdk: '>=3.2.0 <4.0.0'
sdk: ^3.4.0
flutter: '>=3.3.0'

dependencies:
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase_auth/firebase_auth/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ false_secrets:
- example/**

environment:
sdk: '>=3.2.0 <4.0.0'
sdk: ^3.4.0
flutter: '>=3.16.0'

dependencies:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repository: https://github.com/firebase/flutterfire/tree/master/packages/firebas
version: 7.3.0

environment:
sdk: '>=3.2.0 <4.0.0'
sdk: ^3.4.0
flutter: '>=3.16.0'

dependencies:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,8 @@ class FirebaseAuthWeb extends FirebaseAuthPlatform {
.setItem(getOriginName(delegate.app.name), origin);
}
} catch (e) {
if (e is auth_interop.AuthError) {
final String code = e.code.toDart;
if ((e as JSObject).isA<auth_interop.AuthError>()) {
final String code = (e as auth_interop.AuthError).code.toDart;
// this catches Firebase Error from web that occurs after hot reloading & hot restarting
if (code != 'auth/emulator-config-failed') {
throw getFirebaseAuthException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class RecaptchaVerifierFactoryWeb extends RecaptchaVerifierFactoryPlatform {
@override
Future<int> render() async {
try {
return (await _delegate.render()).toInt();
return await _delegate.render();
} catch (e) {
throw getFirebaseAuthException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class User extends UserInfo<auth_interop.UserJsImpl> {
Future<String> 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.
Expand Down Expand Up @@ -526,7 +526,7 @@ class Auth extends JsObjectWrapper<auth_interop.AuthJsImpl> {
Future<List<String>> fetchSignInMethodsForEmail(String email) => auth_interop
.fetchSignInMethodsForEmail(jsObject, email.toJS)
.toDart
.then((value) => List<String>.from(value! as List<dynamic>));
.then((value) => List<String>.from((value! as JSArray).toDart));

/// Checks if an incoming link is a sign-in with email link.
bool isSignInWithEmailLink(String emailLink) =>
Expand Down Expand Up @@ -753,7 +753,7 @@ class Auth extends JsObjectWrapper<auth_interop.AuthJsImpl> {
Future<String> 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.
Expand Down Expand Up @@ -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
Expand All @@ -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<String> verify() =>
jsObject.verify().toDart.then((value) => value! as String);
jsObject.verify().toDart.then((value) => (value! as JSString).toDart);
}

/// reCAPTCHA verifier.
Expand Down Expand Up @@ -1137,8 +1137,8 @@ class RecaptchaVerifier

/// Renders the reCAPTCHA widget on the page.
/// Returns a Future that resolves with the reCAPTCHA widget ID.
Future<num> render() =>
jsObject.render().toDart.then((value) => value! as num);
Future<int> render() =>
jsObject.render().toDart.then((value) => (value! as JSNumber).toDartInt);
}

/// A result from a phone number sign-in, link, or reauthenticate call.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -650,14 +650,10 @@ extension UserProfileExtension on UserProfile {
external set photoURL(JSString s);
}

@JS()
@staticInterop
abstract class AuthError {}

/// An authentication error.
///
/// See: <https://firebase.google.com/docs/reference/js/firebase.auth.Error>.
extension AuthErrorExtension on AuthError {
extension type AuthError(JSObject _) implements JSObject {
external JSString get code;
external set code(JSString s);
external JSString get message;
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase_auth/firebase_auth_web/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repository: https://github.com/firebase/flutterfire/tree/master/packages/firebas
version: 5.12.0

environment:
sdk: '>=3.2.0 <4.0.0'
sdk: ^3.4.0
flutter: '>=3.16.0'

dependencies:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ class FirebaseCoreWeb extends FirebasePlatform {
JSObject? ignored =
globalContext.getProperty('flutterfire_ignore_scripts'.toJS);

if (ignored is Iterable) {
return (ignored! as Iterable)
if (ignored.isA<JSArray>()) {
return (ignored! as JSArray)
.toDart
.map((e) => e.toString())
.toList(growable: false);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase_core/firebase_core_web/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repository: https://github.com/firebase/flutterfire/tree/master/packages/firebas
version: 2.17.0

environment:
sdk: '>=3.2.0 <4.0.0'
sdk: ^3.4.0
flutter: '>=3.3.0'

dependencies:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: 0.2.5+7
homepage: https://github.com/firebase/flutterfire/tree/master/packages/firebase_database/firebase_database_web

environment:
sdk: '>=3.2.0 <4.0.0'
sdk: ^3.4.0
flutter: '>=3.3.0'

dependencies:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
Expand Down
Loading
Loading