Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

adds contents for flutter quick starter guide

dshukertjraee1f7422d81
diff --git a/apps/docs/pages/guides/getting-started/quickstarts/flutter.mdx b/apps/docs/pages/guides/getting-started/quickstarts/flutter.mdx
index 413c43dab44..173b08ea8d2 100644
--- a/apps/docs/pages/guides/getting-started/quickstarts/flutter.mdx
+++ b/apps/docs/pages/guides/getting-started/quickstarts/flutter.mdx
@@ -39,16 +39,16 @@ export const meta = {
<StepHikeCompact.Step step={2}>
- <StepHikeCompact.Details title="Step 2 title">
+ <StepHikeCompact.Details title="Create a Flutter app">
- Step 2 details
+ Create a Flutter app using the `flutter create` command.
</StepHikeCompact.Details>
<StepHikeCompact.Code>
```bash Terminal
- code example
+ flutter create my_app
```
</StepHikeCompact.Code>
@@ -57,16 +57,18 @@ export const meta = {
<StepHikeCompact.Step step={3}>
- <StepHikeCompact.Details title="Step 3 title">
+ <StepHikeCompact.Details title="Install the Supabase client library">
- Step 3 details
+ The fastest way to get started is to use the [`supabase_flutter`](https://pub.dev/packages/supabase_flutter) client library which provides a convenient interface for working with Supabase from a Flutter app.
+
+ Open the `pubspec.yaml` file inside your Flutter app and add `supabase_flutter`.
</StepHikeCompact.Details>
<StepHikeCompact.Code>
- ```bash Terminal
- code example
+ ```yaml pubspec.yaml
+ supabase_flutter: ^1.2.2
```
</StepHikeCompact.Code>
@@ -75,16 +77,24 @@ export const meta = {
<StepHikeCompact.Step step={4}>
- <StepHikeCompact.Details title="Step 4 title">
+ <StepHikeCompact.Details title="Initialize the Supabase client">
- Step 4 details
+ Open `main.dart` edit the main function to include the initialization code for Supabase using your [project URL and public API (anon) key](https://app.supabase.com/project/_/settings/api).
</StepHikeCompact.Details>
<StepHikeCompact.Code>
- ```bash Terminal
- code example
+ ```dart lib/main.dart
+ Future<void> main() async {
+ WidgetsFlutterBinding.ensureInitialized();
+
+ await Supabase.initialize(
+ url: 'YOUR_SUPABASE_URL',
+ anonKey: 'YOUR_SUPABASE_ANON_KEY',
+ );
+ runApp(MyApp());
+ }
```
</StepHikeCompact.Code>
@@ -93,16 +103,85 @@ export const meta = {
<StepHikeCompact.Step step={5}>
- <StepHikeCompact.Details title="Step 5 title">
+ <StepHikeCompact.Details title="Query data from the app">
+
+ Use a `FutureBuilder` to fetch the data when the home page loads and display the query result in a `ListView`.
+
+ Replace the default `MyApp` and `HomePage` classes with the following code.
+
+ </StepHikeCompact.Details>
+
+ <StepHikeCompact.Code>
+
+ ```dart lib/main.dart
+ class MyApp extends StatelessWidget {
+ const MyApp({Key? key}) : super(key: key);
+
+ @override
+ Widget build(BuildContext context) {
+ return const MaterialApp(
+ title: 'Countries',
+ home: HomePage(),
+ );
+ }
+ }
+
+ class HomePage extends StatefulWidget {
+ const HomePage({super.key});
+
+ @override
+ State<HomePage> createState() => _HomePageState();
+ }
+
+ class _HomePageState extends State<HomePage> {
+ final _future = Supabase.instance.client
+ .from('countries')
+ .select<List<Map<String, dynamic>>>();
+
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ body: FutureBuilder<List<Map<String, dynamic>>>(
+ future: _future,
+ builder: (context, snapshot) {
+ if (!snapshot.hasData) {
+ return const Center(child: CircularProgressIndicator());
+ }
+ final countries = snapshot.data!;
+ return ListView.builder(
+ itemCount: items.length,
+ itemBuilder: ((context, index) {
+ final country = items[index];
+ return ListTile(
+ title: Text(item['name']),
+ );
+ }),
+ );
+ },
+ ),
+ );
+ }
+ }
+ ```
+
+ </StepHikeCompact.Code>
+
+ </StepHikeCompact.Step>
+
+
+ <StepHikeCompact.Step step={6}>
+ <StepHikeCompact.Details title="Start the app">
- Step 5 details
+ Run your app on a platform of your choosing! By default an app should launch in your web browser.
+
+ Note that `supabase_flutter` is compatible with web, iOS, Android, macOS, and Windows apps.
</StepHikeCompact.Details>
<StepHikeCompact.Code>
```bash Terminal
- code example
+ flutter run
```
</StepHikeCompact.Code>