-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.dart
80 lines (75 loc) · 2.76 KB
/
main.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import 'package:flutter/material.dart';
import 'package:supabase_flutter/supabase_flutter.dart';
import 'package:url_launcher/url_launcher.dart';
import 'otter_list.dart';
import 'otter.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
runApp(MyApp());
}
var url = 'https://eoshhzqqdhzcowuvurqc.supabase.co';
var anonKey =
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlhdCI6MTYzODI1NzExMCwiZXhwIjoxOTUzODMzMTEwfQ.rl0jjh5VOWvIYNBFg-UBbrhTAOwJ_JFfSjrsEtUjDNM';
// Initialize the supabase client
final SupabaseClient supabase = SupabaseClient(url, anonKey);
// Getter for the other files, easiest solution to avoid multiple
// instances of supabase
SupabaseClient getSupabase() => supabase;
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(primarySwatch: Colors.blueGrey),
home: OtterList(),
);
}
}
// Otter Detail Page
class OtterPage extends StatelessWidget {
final Otter otter;
OtterPage(this.otter);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text(otter.common)),
body: SingleChildScrollView(
child: Column(
children: [
Image.network(otter.imageUrl),
Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text("Details",
style: TextStyle(color: Colors.black, fontSize: 20)),
Divider(color: Colors.black),
Text(otter.detail,
style: Theme.of(context)
.primaryTextTheme
.subtitle1
?.copyWith(color: Colors.black)),
Padding(
padding: const EdgeInsets.all(10.0),
// Link to the wikipedia
child: InkWell(
child: Text('Open Wikipedia',
style: Theme.of(context)
.primaryTextTheme
.subtitle1
?.copyWith(
color: Colors.black,
decoration: TextDecoration.underline,
decorationColor: Colors.blueGrey)),
// Open the link in a browser
onTap: () => launch(otter.link)),
),
],
)),
],
),
),
);
}
}