dio_mini 0.0.1
dio_mini: ^0.0.1 copied to clipboard
dio_mini help you for write basic dio methods
Dio Mini #
Dio Mini have easy and simple components. You can do primitive request and response operation like get, post, put, delete, upload. Also provide you change source code so you can change all code according to your preference.
#
Getting Started Setup #
Step-1 #
When you using helper ,Be careful. Firstly you should define your model class typdef in the IDioMini class.
// !!! you must change StudentModel your ModelClass
typedef ModelClass = ' Your Model Class ' ; // !!!
// !!!
(You will got to source code fastly with pressed ctrl and click package name :) )
Step-2 #
Now ı will show you labels name and their means
baseURL: your data base web adress. You will define, when you use DioMini class. example : https://SECRET.mockapi.io/ *
mainUrl: endpoint of your data base adress. You will understand when you use the methods. example:https://SECRET.mockapi.io/users *
id: id is a descriptive for your data. example: https://SECRET.mockapi.io/users/name.json
Example #
! Don't go here without doing the first step
- Firstly define object
DioMini _helper = DioMini(baseURL: 'Your base URL');
- Use getData() method
final result =
await _helper.getData('users', '4');
print(result?.name);
- Use getDataList() method
final result =
await service.getDataList('users');
print(result?[0].name);
- Use postData() method
await service.postData(model, 'newUsers')
? print('Correct')
: print('NoCorrect');
- Use putData() method
await service.putData(model, '5', 'users')
? print('Correct')
: print('NoCorrect');
- Use deleteData() method
await service.deleteData('5', 'users')
? print('Correct')
: print('NoCorrect');