0

This is my first time using supabase realtime, I want to access values in my table in real time and also update them with interactrions from the app. I prepopulated the database in supabase but when I tried to retrieve the data it was empty.

enter image description here I have attached a picture with the current database setup.

class _TrackerState extends State<Tracker> {
  @override
  Widget build(BuildContext context) {
    final SupabaseClient supabase = Supabase.instance.client;
    final stream = supabase.from('Counter').stream(primaryKey: ["name"]);
    return Scaffold(
      appBar: ...
      ),
      body: Center(
        child: StreamBuilder(
          stream: stream,
          builder: (context, snapshot) {
            switch (snapshot.connectionState) {
              case ConnectionState.active:
                if (snapshot.hasError) log(snapshot.error.toString());
                log(snapshot.data.toString());

                final data = snapshot.data as List<dynamic>;

                return ...
              default:
                return const Scaffold(
                    body: Center(
                  child: SizedBox(
                    child: CircularProgressIndicator(),
                  ),
                ));
            }
          },
        ),
      ),
    );
  }
}

console output: [log] []

2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.