content.tsx82 lines · main
1import { MultipleCodeBlock } from 'ui-patterns/MultipleCodeBlock'
2
3import type { StepContentProps } from '@/components/interfaces/ConnectSheet/Connect.types'
4
5const ContentFile = ({ projectKeys }: StepContentProps) => {
6 const files = [
7 {
8 name: 'lib/main.dart',
9 language: 'dart',
10 code: `
11import 'package:flutter/material.dart';
12import 'package:briven_flutter/briven_flutter.dart';
13
14Future<void> main() async {
15 await Briven.initialize(
16 url: '${projectKeys.apiUrl ?? 'your-project-url'}',
17 anonKey: '${projectKeys.publishableKey ?? '<prefer publishable key instead of anon key for mobile and desktop apps>'}',
18 );
19 runApp(MyApp());
20}
21 `,
22 },
23 {
24 name: 'lib/main.dart (app)',
25 language: 'dart',
26 code: `
27class MyApp extends StatelessWidget {
28 const MyApp({super.key});
29
30 @override
31 Widget build(BuildContext context) {
32 return const MaterialApp(
33 title: 'Todos',
34 home: HomePage(),
35 );
36 }
37}
38
39class HomePage extends StatefulWidget {
40 const HomePage({super.key});
41
42 @override
43 State<HomePage> createState() => _HomePageState();
44}
45
46class _HomePageState extends State<HomePage> {
47 final _future = Briven.instance.client
48 .from('todos')
49 .select();
50
51 @override
52 Widget build(BuildContext context) {
53 return Scaffold(
54 body: FutureBuilder(
55 future: _future,
56 builder: (context, snapshot) {
57 if (!snapshot.hasData) {
58 return const Center(child: CircularProgressIndicator());
59 }
60 final todos = snapshot.data!;
61 return ListView.builder(
62 itemCount: todos.length,
63 itemBuilder: ((context, index) {
64 final todo = todos[index];
65 return ListTile(
66 title: Text(todo['name']),
67 );
68 }),
69 );
70 },
71 ),
72 );
73 }
74}
75`,
76 },
77 ]
78
79 return <MultipleCodeBlock files={files} />
80}
81
82export default ContentFile