import 'package:flutter/material.dart';
import 'package:supabase_flutter/supabase_flutter.dart';
Future<void> main() async{
Supabase.initialize(
url: "https://frouspwowclieepzubsn.supabase.co",
anonKey:
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImZyb3VzcHdvd2NsaWVlcHp1YnNuIiwicm9sZSI6ImFub24iLCJpYXQiOjE2ODA1NzIyMTcsImV4cCI6MTk5NjE0ODIxN30.OHrbR7NwzJmKiCN1c2zhCSLcH5zmCKqZgMYj3FNZwic"
);
runApp(MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
//select문
Supabase.instance.client.from("todo").select().then((value){
print(value);
});
return const Placeholder();
}
}
import 'package:flutter/material.dart';
import 'package:supabase_flutter/supabase_flutter.dart';
Future<void> main() async{
Supabase.initialize(
url: "https://frouspwowclieepzubsn.supabase.co",
anonKey:
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImZyb3VzcHdvd2NsaWVlcHp1YnNuIiwicm9sZSI6ImFub24iLCJpYXQiOjE2ODA1NzIyMTcsImV4cCI6MTk5NjE0ODIxN30.OHrbR7NwzJmKiCN1c2zhCSLcH5zmCKqZgMYj3FNZwic"
);
runApp(MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
//select문 정적으로 가져오기
/*Supabase.instance.client.from("todo").select().then((value){
print(value);
});*/
// 실시간으로 가져오기 - stream.listen
Supabase.instance.client.from("todo").stream(primaryKey: ["idx"]).listen((event) {
print(event);
});
return const Placeholder();
}
}
ㅇㅇㅇ
return MaterialApp(
home: Scaffold(
body: SafeArea(
child: StreamBuilder<List<Map<String, dynamic>>>(
stream: Supabase.instance.client.from("todo").stream(primaryKey: ["idx"]),
builder: (context, snapshot) {
return ListView(
children: snapshot.data?.map((e) => Text(e["content"])).toList() ?? [],
);
}
),
),
),
);