add sdk
This commit is contained in:
parent
7fb3f2582e
commit
3e66f24c74
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_service/model/CategoryResponse.dart';
|
||||
import 'package:flutter_service/provider/CategoryProvider.dart';
|
||||
import 'package:flutter_service/sdk/ClientSDK.dart';
|
||||
import 'package:flutter_service/sdk/ClientSDK.dart';
|
||||
import 'package:flutter_service/wrapper/ProviderWrapper.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
@ -39,7 +40,7 @@ class MyHomePage extends StatefulWidget {
|
||||
_MyHomePageState createState() => _MyHomePageState();
|
||||
}
|
||||
|
||||
ClientSDK client = ClientSDK();
|
||||
ClientSDK sdk = ClientSDK.instance;
|
||||
|
||||
class _MyHomePageState extends State<MyHomePage> {
|
||||
|
||||
@ -73,13 +74,13 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
super.didChangeDependencies();
|
||||
categories = Provider.of<CategoryProvider>(context, listen: true)
|
||||
.getCategories();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void init(BuildContext context) async {
|
||||
List<CategoryResponse> result = await client.clientGetAllCategoryService();
|
||||
List<CategoryResponse> result = await sdk.clientGetAllCategoryService();
|
||||
Provider.of<CategoryProvider>(context, listen: false).setCategories(result);
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -5,6 +5,14 @@ import 'package:flutter_service/service/CategoryService.dart';
|
||||
|
||||
class ClientSDK {
|
||||
|
||||
ClientSDK._privateConstructor();
|
||||
|
||||
static final ClientSDK _instance = ClientSDK._privateConstructor();
|
||||
|
||||
static ClientSDK get instance => _instance;
|
||||
|
||||
|
||||
|
||||
Future<List<CategoryResponse>> clientGetAllCategoryService() async {
|
||||
return await getAllCategoryService();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user