Skip to content

Commit

Permalink
fix: Remove dart:io imports for analytics, auth and app check (#16827)
Browse files Browse the repository at this point in the history
Allows these packages to be detected as wasm-compatible

Packages:
- firebase_analytics
- firebase_app_check
- firebase_auth

Co-authored-by: Russell Wheatley <russellwheatley85@gmail.com>
  • Loading branch information
kevmoo and russellwheatley authored Dec 9, 2024
1 parent 165d2ab commit 8c7f57c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
// found in the LICENSE file.

import 'dart:async';
import 'dart:io';

import 'package:firebase_analytics_platform_interface/firebase_analytics_platform_interface.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';

import 'utils/exception.dart';
Expand Down Expand Up @@ -202,7 +202,7 @@ class MethodChannelFirebaseAnalytics extends FirebaseAnalyticsPlatform {
@override
Future<void> setSessionTimeoutDuration(Duration timeout) async {
try {
if (Platform.isAndroid) {
if (!kIsWeb && defaultTargetPlatform == TargetPlatform.android) {
return channel.invokeMethod<void>(
'Analytics#setSessionTimeoutDuration', <String, int>{
'milliseconds': timeout.inMilliseconds,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// found in the LICENSE file.

import 'dart:async';
import 'dart:io';

import 'package:_flutterfire_internals/_flutterfire_internals.dart';
import 'package:firebase_core/firebase_core.dart';
Expand Down Expand Up @@ -84,9 +83,11 @@ class MethodChannelFirebaseAppCheck extends FirebaseAppCheckPlatform {
await channel.invokeMethod<void>('FirebaseAppCheck#activate', {
'appName': app.name,
// Allow value to pass for debug mode for unit testing
if (Platform.isAndroid || kDebugMode)
if (defaultTargetPlatform == TargetPlatform.android || kDebugMode)
'androidProvider': getAndroidProviderString(androidProvider),
if (Platform.isIOS || Platform.isMacOS || kDebugMode)
if (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform == TargetPlatform.macOS ||
kDebugMode)
'appleProvider': getAppleProviderString(appleProvider),
});
} on PlatformException catch (e, s) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// found in the LICENSE file.

import 'dart:async';
import 'dart:io';

import 'package:firebase_auth_platform_interface/firebase_auth_platform_interface.dart';
import 'package:firebase_core/firebase_core.dart';
Expand Down
4 changes: 3 additions & 1 deletion packages/firebase_auth/firebase_auth/lib/src/user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,9 @@ class User {
}

MultiFactor get multiFactor {
if (!kIsWeb && (Platform.isMacOS || Platform.isWindows)) {
if (!kIsWeb &&
(defaultTargetPlatform == TargetPlatform.macOS ||
defaultTargetPlatform == TargetPlatform.windows)) {
throw UnimplementedError(
'MultiFactor Authentication is only supported on web, Android and iOS.',
);
Expand Down

0 comments on commit 8c7f57c

Please sign in to comment.