mirror of
https://github.com/supabase/supabase.git
synced 2026-10-11 04:15:04 +03:00
This PR moves several components which rely on `next` out of the `ui` package to the `ui-patterns` package. `ui-patterns` package is intented to be imported with specific imports so it's ok if there are components reliant on `next` in there. The `SonnerToaster` component has removed its dependency by requiring a prop for `theme`.
94 lines
2.4 KiB
TypeScript
94 lines
2.4 KiB
TypeScript
import { SimpleCodeBlock } from 'ui-patterns/SimpleCodeBlock'
|
|
|
|
import type { ContentFileProps } from '@/components/interfaces/Connect/Connect.types'
|
|
import {
|
|
ConnectTabContent,
|
|
ConnectTabs,
|
|
ConnectTabTrigger,
|
|
ConnectTabTriggers,
|
|
} from '@/components/interfaces/Connect/ConnectTabs'
|
|
|
|
const ContentFile = ({ projectKeys }: ContentFileProps) => {
|
|
return (
|
|
<ConnectTabs>
|
|
<ConnectTabTriggers>
|
|
<ConnectTabTrigger value="lib/main.dart" />
|
|
<ConnectTabTrigger value="lib/main.dart (app)" />
|
|
</ConnectTabTriggers>
|
|
|
|
<ConnectTabContent value="lib/main.dart">
|
|
<SimpleCodeBlock className="dart" parentClassName="min-h-72">
|
|
{`
|
|
import 'package:supabase_flutter/supabase_flutter.dart';
|
|
|
|
Future<void> main() async {
|
|
await Supabase.initialize(
|
|
url: '${projectKeys.apiUrl ?? 'your-project-url'}',
|
|
anonKey: '${projectKeys.publishableKey ?? '<prefer publishable key instead of anon key for mobile and desktop apps>'}',
|
|
);
|
|
runApp(MyApp());
|
|
}
|
|
`}
|
|
</SimpleCodeBlock>
|
|
</ConnectTabContent>
|
|
|
|
<ConnectTabContent value="lib/main.dart (app)">
|
|
<SimpleCodeBlock className="dart" parentClassName="min-h-72">
|
|
{`
|
|
class MyApp extends StatelessWidget {
|
|
const MyApp({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return const MaterialApp(
|
|
title: 'Todos',
|
|
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('todos')
|
|
.select();
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: FutureBuilder(
|
|
future: _future,
|
|
builder: (context, snapshot) {
|
|
if (!snapshot.hasData) {
|
|
return const Center(child: CircularProgressIndicator());
|
|
}
|
|
final todos = snapshot.data!;
|
|
return ListView.builder(
|
|
itemCount: todos.length,
|
|
itemBuilder: ((context, index) {
|
|
final todo = todos[index];
|
|
return ListTile(
|
|
title: Text(todo['name']),
|
|
);
|
|
}),
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|
|
`}
|
|
</SimpleCodeBlock>
|
|
</ConnectTabContent>
|
|
</ConnectTabs>
|
|
)
|
|
}
|
|
|
|
export default ContentFile
|