This commit is contained in:
Mohamed Nouffer
2022-05-12 02:17:08 +05:30
parent 9d253fc5e2
commit 80a976baa0
37 changed files with 1159 additions and 592 deletions

View File

@ -0,0 +1,28 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
class CatService{
static Future<List<dynamic>?> loadCats() async {
List<dynamic> cats = [];
String url = 'http://localhost:8100/api/cats/';
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
);
if (response.statusCode == 200) {
cats = json.decode(utf8.decode(response.bodyBytes));
}
return cats;
}
}