supabase_hooks 0.0.4 copy "supabase_hooks: ^0.0.4" to clipboard
supabase_hooks: ^0.0.4 copied to clipboard

outdated

Unofficial Flutter Supabase life cycle adaptation for flutter_hooks.

Unofficial Supabase life cycle adaptation for flutter_hooks. See more in the original package: https://github.com/supabase/supabase-flutter

Note: This library is completely experimental and not recommended for production usage.

The idea is the same as in LifeHook, except that you can override more methods, specific to Supabase Auth life cycle

AuthRequiredState useAuthRequiredState() => use(
      ContextfulLifeHook(
        debugLabel: 'AuthRequiredState',
        state: AuthRequiredState(),
      ),
    );

class AuthRequiredState extends SupabaseAuthRequiredLifeState {
  @override
  void onUnauthenticated() {
    /// Users will be sent back to the LoginPage if they sign out.
    if (mounted) {
      /// Users will be sent back to the LoginPage if they sign out.
      Navigator.of(context)
          .pushNamedAndRemoveUntil('/login', (final route) => false);
    }
  }
}
copied to clipboard

or use

AuthState useAuthState() => use(
      ContextfulLifeHook(
        debugLabel: 'AuthState',
        state: AuthState(),
      ),
    );

class AuthState extends SupabaseAuthLifeState {
  @override
  void onUnauthenticated() {
    if (mounted) {
      Navigator.of(context)
          .pushNamedAndRemoveUntil('/', (final route) => false);
    }
  }

  @override
  void onAuthenticated(final Session session) {
    if (mounted) {
      Navigator.of(context)
          .pushNamedAndRemoveUntil('/', (final route) => false);
    }
  }

  @override
  void onPasswordRecovery(final Session session) {}

  @override
  void onErrorAuthenticating(final String message) {
    context.showErrorSnackBar(message: message);
  }
}
copied to clipboard
2
likes
0
points
54
downloads

Publisher

verified publisherxsoulspace.dev

Weekly Downloads

2024.09.20 - 2025.04.04

Unofficial Flutter Supabase life cycle adaptation for flutter_hooks.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, flutter_hooks, hive, hive_flutter, life_hooks, supabase, supabase_flutter, uni_links, url_launcher

More

Packages that depend on supabase_hooks