glp-companion/lib/core/network/supabase_status.dart

17 lines
633 B
Dart

import 'package:supabase_flutter/supabase_flutter.dart';
/// Whether the global [Supabase] SDK has been initialized.
///
/// [Supabase.instance] throws an [AssertionError] in debug builds when
/// [Supabase.initialize] has not run (for example when the `.env` file is
/// missing or incomplete during local development). Routing guards and the
/// provider graph must not depend on the SDK being configured, so this helper
/// probes the singleton defensively and reports `false` instead of throwing.
bool get isSupabaseAvailable {
try {
return Supabase.instance.isInitialized;
} on AssertionError {
return false;
}
}