fetchCategories method Null safety
API call to get the categories.
Implementation
static Future<Categories> fetchCategories() async {
final response = await http.get(Uri.parse('https://opentdb.com/api_category.php'));
if (response.statusCode == 200) {
return Categories.fromJson(jsonDecode(response.body));
} else {
throw Exception('Failed to load questions');
}
}