so i was building some stuff and ran into issues like where i have a future function called ‘fetchAllJobs’ here is the code
`Future<List<Map<String, dynamic>>> fetchAllJobs() async {
var url = Uri.parse(
‘https://svxuhlltayxjxqrtxgxz.supabase.co/rest/v1/list_of_jobs?select=*’);
try {
var response = await http.get(url);
if (response.statusCode == 200) {
var jsonResponse = jsonDecode(response.body);
List<dynamic> jobs = jsonResponse as List<dynamic>;
// Convert List<dynamic> to List<Map<String, dynamic>>
List<Map<String, dynamic>> jobList =
jobs.map((job) => job as Map<String, dynamic>).toList();
return jobList;
} else {
throw Exception('Failed to load jobs from Supabase');
}
} catch (error) {
debugPrint('Error fetching jobs: $error');
// You can throw an exception or handle errors as needed
rethrow;
}
}`
what i am trying to do is where i navigate into the Posted Jobs it throws an error
TypeError (Null check operator used on a null value)
this is the code snipper for the FutureBuilder
FutureBuilder( future: fetchAllJobs(), builder: (context, snapshot) { List<Map<String, dynamic>> job = snapshot.data!;
what is the good way to elimitate this error? i tried putting delay and a initState still errors. thanks in advance.
MadTerrier is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.