fix(config): use dart-define supabase settings and default to PKCE auth flow
This commit is contained in:
parent
34597b9909
commit
f41708c662
2 changed files with 24 additions and 5 deletions
|
|
@ -14,7 +14,14 @@ car64 is a Flutter + Supabase Hot Wheels collector app with a fast scanning work
|
||||||
## Local Development
|
## Local Development
|
||||||
|
|
||||||
1. Install Flutter (stable) and run `flutter doctor`.
|
1. Install Flutter (stable) and run `flutter doctor`.
|
||||||
2. Configure Supabase keys in app configuration.
|
2. Configure Supabase values via build-time variables (`--dart-define`), for example:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
flutter run \
|
||||||
|
--dart-define=SUPABASE_URL=https://your-project.supabase.co \
|
||||||
|
--dart-define=SUPABASE_ANON_KEY=your_anon_key \
|
||||||
|
--dart-define=SUPABASE_USE_PKCE=true
|
||||||
|
```
|
||||||
3. Install dependencies:
|
3. Install dependencies:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,18 @@ export 'package:supabase_flutter/supabase_flutter.dart'
|
||||||
show AuthException, UserAttributes;
|
show AuthException, UserAttributes;
|
||||||
|
|
||||||
// ── Supabase credentials ──────────────────────────────────────────────
|
// ── Supabase credentials ──────────────────────────────────────────────
|
||||||
const _supabaseUrl = 'https://yaopcyubateifnicpywp.supabase.co';
|
const _supabaseUrl = String.fromEnvironment(
|
||||||
const _supabaseAnonKey = 'sb_publishable_a7czIl7-TGeBJvid9z2XZA_3ElImliL';
|
'SUPABASE_URL',
|
||||||
|
defaultValue: 'https://yaopcyubateifnicpywp.supabase.co',
|
||||||
|
);
|
||||||
|
const _supabaseAnonKey = String.fromEnvironment(
|
||||||
|
'SUPABASE_ANON_KEY',
|
||||||
|
defaultValue: 'sb_publishable_a7czIl7-TGeBJvid9z2XZA_3ElImliL',
|
||||||
|
);
|
||||||
|
const _usePkceAuthFlow = bool.fromEnvironment(
|
||||||
|
'SUPABASE_USE_PKCE',
|
||||||
|
defaultValue: true,
|
||||||
|
);
|
||||||
|
|
||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
@ -21,8 +31,10 @@ Future<void> main() async {
|
||||||
await Supabase.initialize(
|
await Supabase.initialize(
|
||||||
url: _supabaseUrl,
|
url: _supabaseUrl,
|
||||||
anonKey: _supabaseAnonKey,
|
anonKey: _supabaseAnonKey,
|
||||||
authOptions: const FlutterAuthClientOptions(
|
authOptions: FlutterAuthClientOptions(
|
||||||
authFlowType: AuthFlowType.implicit,
|
authFlowType: _usePkceAuthFlow
|
||||||
|
? AuthFlowType.pkce
|
||||||
|
: AuthFlowType.implicit,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue