0 purchases
custom dio
start init before you send any request
WidgetsFlutterBinding.ensureInitialized();
CustomDio.setInitData(
CustomDioOptions(
baseUrl: "http://www.google.com",
headers: {"authorization": "Bearer xxx"},
),
);
copied to clipboard
POST #
try {
final data = await CustomDio()
.send(reqMethod: "post", path: "user/login", body: {"email": "email"});
} catch (err) {
print(err.toString());
}
copied to clipboard
GET #
try {
final data = await CustomDio()
.send(reqMethod: "get", path: "user/login", query: {"search": "email"});
} catch (err) {
print(err.toString());
}
copied to clipboard
UPLOAD #
try {
final data = await CustomDio()
.uploadFile(path: "path", filePath: File("").path, body: [
{"one": "one"},
{"two": "two"},
]);
} catch (err) {
print(err.toString());
}
copied to clipboard
uploadBytes #
try {
final data = await CustomDio().uploadBytes(
path: "dio-test/file",
bytesExtension: "png",
bytes: bytes,
body: [
{"content": "sd"},
{"attachments": "attachments"},
]);
return data.data.toString();
} catch (err) {
rethrow;
}
copied to clipboard
delete #
Future delete() async {
try {
final data =
await CustomDio().send(reqMethod: "delete", path: "dio-test/1");
dLog(data.data.toString());
} catch (err) {
}
}
copied to clipboard
getOne #
try {
final data =
await CustomDio().send(reqMethod: "get", path: "dio-test/154");
dLog(data.data.toString());
} catch (err) {
}
}
copied to clipboard
patch #
Future update() async {
try {
final data = await CustomDio().send(
reqMethod: "patch",
path: "dio-test",
body: {"content": "update content"});
dLog(data.data.toString());
} catch (err) {
}
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.