Skip to content

Commit b1645f6

Browse files
authored
chore: merge next (supabase#757)
2 parents d25b61a + 68ad3ff commit b1645f6

File tree

113 files changed

+3862
-2770
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+3862
-2770
lines changed

.github/workflows/functions_client_ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
fail-fast: false
2424
matrix:
2525
os: [ubuntu-latest]
26-
sdk: [2.17.0, stable, beta, dev]
26+
sdk: [stable, beta, dev]
2727

2828
defaults:
2929
run:

.github/workflows/gotrue_ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
fail-fast: false
2121
matrix:
2222
os: [ubuntu-latest]
23-
sdk: [2.17.0, stable, beta, dev]
23+
sdk: [stable, beta, dev]
2424

2525
defaults:
2626
run:
@@ -62,4 +62,4 @@ jobs:
6262
time: '5s'
6363

6464
- name: Run tests
65-
run: dart test
65+
run: dart test --concurrency=1

.github/workflows/postgrest_ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
fail-fast: false
2323
matrix:
2424
os: [ubuntu-latest]
25-
sdk: [2.17.0, stable, beta, dev]
25+
sdk: [stable, beta, dev]
2626

2727
defaults:
2828
run:
@@ -64,4 +64,4 @@ jobs:
6464
time: '5s'
6565

6666
- name: Run tests
67-
run: dart test
67+
run: dart test --concurrency=1

.github/workflows/realtime_client_ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
fail-fast: false
2121
matrix:
2222
os: [ubuntu-latest]
23-
sdk: [2.17.0, stable, beta, dev]
23+
sdk: [stable, beta, dev]
2424

2525
defaults:
2626
run:

.github/workflows/storage_client_ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
fail-fast: false
2020
matrix:
2121
os: [ubuntu-latest]
22-
sdk: [2.17.0, stable, beta, dev]
22+
sdk: [stable, beta, dev]
2323

2424
defaults:
2525
run:

.github/workflows/supabase_ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
fail-fast: false
3131
matrix:
3232
os: [ubuntu-latest]
33-
sdk: [2.17.0, stable, beta, dev]
33+
sdk: [stable, beta, dev]
3434

3535
defaults:
3636
run:
@@ -61,4 +61,4 @@ jobs:
6161
run: dart analyze --fatal-warnings --fatal-infos .
6262

6363
- name: Run tests
64-
run: dart test
64+
run: dart test --concurrency=1

.github/workflows/supabase_flutter_ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
fail-fast: false
3333
matrix:
3434
os: [ubuntu-latest]
35-
flutter-version: ['3.0.0', '3.x']
35+
flutter-version: ['3.10.x', '3.x']
3636

3737
defaults:
3838
run:
@@ -60,11 +60,11 @@ jobs:
6060
melos bootstrap
6161
6262
- name: flutterfmt
63-
if: ${{ matrix.sdk == '3.x'}}
63+
if: ${{ matrix.sdk == '3.x'}}
6464
run: dart format lib test -l 80 --set-exit-if-changed
6565

6666
- name: analyzer
6767
run: flutter analyze --fatal-warnings --fatal-infos .
6868

6969
- name: Run tests
70-
run: flutter test
70+
run: flutter test --concurrency=1

.github/workflows/yet_another_json_isolate_ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
fail-fast: false
2121
matrix:
2222
os: [ubuntu-latest]
23-
sdk: [2.17.0, stable, beta, dev]
23+
sdk: [stable, beta, dev]
2424

2525
defaults:
2626
run:

CHANGELOG.md

Lines changed: 477 additions & 282 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 48 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ void main() async {
4747
final supabase = Supabase.instance.client;
4848
```
4949

50-
> `authCallbackUrlHostname` is optional. It will be used to filter Supabase authentication redirect deeplink. You need to provide this param if you use deeplink for other features on the app.
51-
5250
> `debug` is optional. It's enabled by default if you're running the app in debug mode (`flutter run --debug`).
5351
5452
## Usage example
@@ -173,12 +171,12 @@ class MyWidget extends StatefulWidget {
173171
174172
class _MyWidgetState extends State<MyWidget> {
175173
// Persisting the future as local variable to prevent refetching upon rebuilds.
176-
final List<Map<String, dynamic>> _stream = supabase.from('countries').stream(primaryKey: ['id']);
174+
final stream = supabase.from('countries').stream(primaryKey: ['id']);
177175
178176
@override
179177
Widget build(BuildContext context) {
180178
return StreamBuilder<List<Map<String, dynamic>>>(
181-
stream: _stream,
179+
stream: stream,
182180
builder: (context, snapshot) {
183181
// return your widget with the data from snapshot
184182
},
@@ -213,11 +211,13 @@ Broadcast lets you send and receive low latency messages between connected clien
213211
final myChannel = supabase.channel('my_channel');
214212
215213
// Subscribe to `cursor-pos` broadcast event
216-
myChannel.on(RealtimeListenTypes.broadcast,
217-
ChannelFilter(event: 'cursor-pos'), (payload, [ref]) {
218-
// Do something fun or interesting when there is an change on the database
219-
}).subscribe();
220-
214+
myChannel.on(
215+
RealtimeListenTypes.broadcast,
216+
ChannelFilter(event: 'cursor-pos'),
217+
(payload, [ref]) {
218+
// Do something fun or interesting when there is an change on the database
219+
},
220+
).subscribe();
221221
// Send a broadcast message to other connected clients
222222
await myChannel.send(
223223
type: RealtimeListenTypes.broadcast,
@@ -245,13 +245,13 @@ myChannel.on(
245245
}).on(RealtimeListenTypes.presence, ChannelFilter(event: 'leave'),
246246
(payload, [ref]) {
247247
// Users have left
248-
}).subscribe(((status, [_]) async {
249-
if (status == 'SUBSCRIBED') {
248+
}).subscribe((status, error) async {
249+
if (status == RealtimeSubscribeStatus.subscribed) {
250250
// Send the current user's state upon subscribing
251251
final status = await myChannel
252252
.track({'online_at': DateTime.now().toIso8601String()});
253253
}
254-
}));
254+
});
255255
```
256256

257257
### [Storage](https://supabase.com/docs/guides/storage)
@@ -283,7 +283,7 @@ class MyWidget extends StatelessWidget {
283283
```dart
284284
import 'package:supabase_flutter/supabase_flutter.dart';
285285
286-
final client = Supabase.instance.client;
286+
final supabase = Supabase.instance.client;
287287
288288
class MyWidget extends StatefulWidget {
289289
const MyWidget({Key? key}) : super(key: key);
@@ -294,12 +294,12 @@ class MyWidget extends StatefulWidget {
294294
295295
class _MyWidgetState extends State<MyWidget> {
296296
// Persisting the future as local variable to prevent refetching upon rebuilds.
297-
final _future = client.functions.invoke('get_countries');
297+
final future = supabase.functions.invoke('get_countries');
298298
299299
@override
300300
Widget build(BuildContext context) {
301301
return FutureBuilder(
302-
future: _future,
302+
future: future,
303303
builder: (context, snapshot) {
304304
// return your widget with the data from snapshot
305305
},
@@ -338,45 +338,46 @@ supabase.auth.signInWithOAuth(
338338

339339
### Custom LocalStorage
340340

341-
As default, `supabase_flutter` uses [`hive`](https://pub.dev/packages/hive) to persist the user session. Encryption is disabled by default, since an unique encryption key is necessary, and we can not define it. To set an `encryptionKey`, do the following:
341+
As default, `supabase_flutter` uses [`Shared preferences`](https://pub.dev/packages/shared_preferences) to persist the user session.
342+
343+
However, you can use any other methods by creating a `LocalStorage` implementation. For example, we can use [`flutter_secure_storage`](https://pub.dev/packages/flutter_secure_storage) plugin to store the user session in a secure storage.
342344

343345
```dart
344-
Future<void> main() async {
345-
// set it before initializing
346-
HiveLocalStorage.encryptionKey = 'my_secure_key';
347-
await Supabase.initialize(...);
348-
}
349-
```
346+
// Define the custom LocalStorage implementation
347+
class MockLocalStorage extends LocalStorage {
350348
351-
**Note** the key must be the same. There is no check if the encryption key is correct. If it isn't, there may be unexpected behavior. [Learn more](https://docs.hivedb.dev/#/advanced/encrypted_box) about encryption in hive.
349+
final storage = FlutterSecureStorage();
352350
353-
However you can use any other methods by creating a `LocalStorage` implementation. For example, we can use [`flutter_secure_storage`](https://pub.dev/packages/flutter_secure_storage) plugin to store the user session in a secure storage.
351+
@override
352+
Future<void> initialize() async {}
354353
355-
```dart
356-
// Define the custom LocalStorage implementation
357-
class SecureLocalStorage extends LocalStorage {
358-
SecureLocalStorage() : super(
359-
initialize: () async {},
360-
hasAccessToken: () {
361-
const storage = FlutterSecureStorage();
362-
return storage.containsKey(key: supabasePersistSessionKey);
363-
}, accessToken: () {
364-
const storage = FlutterSecureStorage();
365-
return storage.read(key: supabasePersistSessionKey);
366-
}, removePersistedSession: () {
367-
const storage = FlutterSecureStorage();
368-
return storage.delete(key: supabasePersistSessionKey);
369-
}, persistSession: (String value) {
370-
const storage = FlutterSecureStorage();
371-
return storage.write(key: supabasePersistSessionKey, value: value);
372-
},
373-
);
354+
@override
355+
Future<String?> accessToken() async {
356+
return storage.containsKey(key: supabasePersistSessionKey);
357+
}
358+
359+
@override
360+
Future<bool> hasAccessToken() async {
361+
return storage.read(key: supabasePersistSessionKey);
362+
}
363+
364+
@override
365+
Future<void> persistSession(String persistSessionString) async {
366+
return storage.write(key: supabasePersistSessionKey, value: persistSessionString);
367+
}
368+
369+
@override
370+
Future<void> removePersistedSession() async {
371+
return storage.delete(key: supabasePersistSessionKey);
372+
}
374373
}
375374
376375
// use it when initializing
377376
Supabase.initialize(
378377
...
379-
localStorage: SecureLocalStorage(),
378+
authOptions: FlutterAuthClientOptions(
379+
localStorage: const EmptyLocalStorage(),
380+
),
380381
);
381382
```
382383

@@ -385,7 +386,9 @@ You can also use `EmptyLocalStorage` to disable session persistence:
385386
```dart
386387
Supabase.initialize(
387388
// ...
388-
localStorage: const EmptyLocalStorage(),
389+
authOptions: FlutterAuthClientOptions(
390+
localStorage: const EmptyLocalStorage(),
391+
),
389392
);
390393
```
391394

0 commit comments

Comments
 (0)