What's the correct way to retrieve supabase data in flutter? I'm building up my code as below but seemed not to be parsing the response body the right way.
sdk: ^3.1.1 supabase_flutter: ^2.0.0
In main.dart
void main() async{
WidgetsFlutterBinding.ensureInitialized;
await Supabase.initialize(
url: supabase_db_url
anonKey: supabase_db_key,
);
runApp(MyApp());
}
In widget build
static Future<int> GET(Map<String, dynamic> params) async{
final futureSpabaseOutput = Supabase.instance.client.from('table_name').select();
return parseSupabaseOutput(futureSpabaseOutput);
}
where
static int parseSupabaseOutput(responseBody) {
int count = 10;
if(count>=responseBody.length){
return count = responseBody.length
}
return count;
}
Got error
Error: NoSuchMethodError: 'length'
method not found
Receiver: Instance of 'PostgrestFilterBuilder<List<Map<String, dynamic>>>'
I suppose with a non-empty database with the below query response is list like but couldn't retrieve data anyways.
You didn't wait to get the completed result:
final futureSpabaseOutput = Supabase.instance.client.from('table_name').select();
final futureSpabaseOutput = await Supabase.instance.client.from('table_name').select();