add project
This commit is contained in:
19
lib/service/CategoryService.dart
Normal file
19
lib/service/CategoryService.dart
Normal file
@@ -0,0 +1,19 @@
|
||||
import 'package:flutter_service/config/DiConfig.dart';
|
||||
import 'package:flutter_service/model/CategoryResponse.dart';
|
||||
|
||||
Future<List<CategoryResponse>> getAllCategoryService() async {
|
||||
String url = "http://computer-api.osa.cubetiqs.com/api/frontend/categories";
|
||||
List<CategoryResponse> r = await getDioInstance().get(url).then((value) {
|
||||
|
||||
List<dynamic> result = value.data['data'] as List<dynamic>;
|
||||
|
||||
return result.map((e) => CategoryResponse.fromResponse(e)).toList();
|
||||
|
||||
}).catchError((onError) {
|
||||
print(onError);
|
||||
return null;
|
||||
});
|
||||
|
||||
return r;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user