Blog post

supabase-flutter v1 Released

2022-10-21

3 minute read

supabase-flutter v1 Released

A few months ago, we announced a developer preview version of supabase-flutter SDK. Since then, we have heard a lot of amazing feedback from the community, and have been improving it. Today, we are happy to announce the stable v1 of supabase-flutter. You can also find the updated quick start guide, documentation and a migration guide from v0.

What is new in v1?

supabase-flutter v1 focuses on improved developer experience. The new version requires far less boiler plate code as well as it provides more intuitive APIs. Here are some highlights of the update.

No more .execute()

Previously, for .select(), .insert(), .update(), .delete() and .stream() required execute() to be called at the end. On top of that, errors are thrown, not returned, so you can be sure that you have the query results in the returned value.

// Before
final response = await supabase.from('messages').select().execute();
final data = response.data;

// After
final data = await supabase.from('messages').select();

More predictable auth methods

Names of the auth methods are more descriptive about what they do. Here are some examples of the new methods:

await supabase.auth.signInWithPassword(email: email, password: password);

await supabase.auth.signInWithOAuth(Provider.github)

Also, onAuthStateChange returns stream, which feels more natural for anyone coding in Dart.

supabase.auth.onAuthStateChange.listen((data) {
  final AuthChangeEvent event = data.event;
  final Session? session = data.session;
});

Realtime Multiplayer edition support

During the last launch week, we announced the general availability of Realtime Multiplayer. supabase-flutter now has first class support for the two newly introduced realtime methods, broadcast and presence. Broadcast can be used to share realtime data to all connected clients with low latency. Presence is a way to let other connected clients know the status of the client. You can visit multiplayer.dev to see a quick demo of the feature.

final channel = Supabase.instance.client.channel('my_channel');

// listen to `location` broadcast events
channel.on(
    RealtimeListenTypes.broadcast,
    ChannelFilter(
      event: 'location',
    ), (payload, [ref]) {
	// Do something exciting with the broadcast event
});

// send `location` broadcast events
channel.send(
  type: RealtimeListenTypes.broadcast,
  event: 'location',
  payload: {'lat': 1.3521, 'lng': 103.8198},
);

// listen to presence states
channel.on(RealtimeListenTypes.presence, ChannelFilter(event: 'sync'),
    (payload, [ref]) {
	// Do something exciting with the presence state
});

// subscribe to the above changes
channel.subscribe((status) async {
  if (status == 'SUBSCRIBED') {
    // if subscribed successfully, send presence event
    final status = await channel.track({'user_id': myUserId});
  }
});

These are just tip of the iceberg of all the updates that we shipped in v1. Check out the documentation to see the full list.

Acknowledgements

It required massive support from the community to bring the supabase-flutter to where it is today. I would like to thank everyone who has contributed to the library, and a special thanks to Bruno and Vinzent, who have been key for this release. We really could not have done it without you!

Resources

Share this article

Last post

What is PostgreSQL commitfest and how to contribute

27 October 2022

Next post

supabase-js v2 Released

20 October 2022

Related articles

Supabase Beta February 2023

Geo Queries with PostGIS in Ionic Angular

Type Constraints in 65 lines of SQL

HappyTeams unlocks better performance and reduces cost with Supabase

How to build a real-time multiplayer game with Flutter Flame

Build in a weekend, scale to millions