Skip to content

Commit

Permalink
export auth web helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
alextekartik committed Mar 20, 2024
1 parent 9da5bae commit 5ea7894
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions auth_flutter/lib/auth_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:tekartik_firebase_auth/auth.dart';
import 'src/auth_flutter.dart' as auth_flutter;

export 'auth_flutter_api.dart';
export 'src/auth_flutter.dart' show FirebaseAuthFlutterExtension;
export 'src/google_auth.dart' show GoogleAuthProvider;

/// The flutter auth service
Expand Down
14 changes: 14 additions & 0 deletions auth_flutter/lib/src/auth_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -245,3 +245,17 @@ class AuthSignInResultFlutter implements AuthSignInResult {
@override
bool get hasInfo => true;
}

/// Helpers
extension FirebaseAuthFlutterExtension on Auth {
/// Web only
void webSetIndexedDbPersistence() {
if (kIsWeb && this is AuthFlutterImpl) {
(this as AuthFlutterImpl)
.nativeAuth
.setPersistence(native.Persistence.LOCAL); // indexedDB
}
}

AuthFlutter get flutter => this as AuthFlutter;
}
2 changes: 1 addition & 1 deletion auth_flutter/lib/src/auth_flutter_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AuthSignInOptionsWeb implements AuthSignInOptions {
}
}

abstract class AuthFlutter {
abstract class AuthFlutter implements Auth {
Future<User?> googleSignIn();
}

Expand Down
2 changes: 1 addition & 1 deletion auth_flutter/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: tekartik_firebase_auth_flutter
description: Firebase auth flutter
version: 0.10.0
version: 0.10.1
publish_to: none
environment:
sdk: '>=3.0.0 <4.0.0'
Expand Down
3 changes: 3 additions & 0 deletions auth_flutter/test/auth_flutter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ void main() async {
test('factory', () {
expect(authServiceFlutter.supportsListUsers, isFalse);
expect(authServiceFlutter.supportsCurrentUser, isTrue);
AuthFlutter? authFlutter;
// ignore: dead_code
authFlutter?.webSetIndexedDbPersistence();
});
});
}

0 comments on commit 5ea7894

Please sign in to comment.