custom_dio 1.0.2 copy "custom_dio: ^1.0.2" to clipboard
custom_dio: ^1.0.2 copied to clipboard

custom_dio is wrapper above dio package to make send request easy

start init before you send any request

  WidgetsFlutterBinding.ensureInitialized();
  CustomDio.setInitData(
    CustomDioOptions(
      baseUrl: "http://www.google.com",
      headers: {"authorization": "Bearer xxx"},
    ),
  );

POST #

  try {
  final data =  await CustomDio()
        .send(reqMethod: "post", path: "user/login", body: {"email": "email"});
  } catch (err) {
    print(err.toString());
  }

GET #

  try {
   final data = await CustomDio()
        .send(reqMethod: "get", path: "user/login", query: {"search": "email"});
  } catch (err) {
    print(err.toString());
  }

UPLOAD #

  try {
    final data = await CustomDio()
        .uploadFile(path: "path", filePath: File("").path, body: [
      {"one": "one"},
      {"two": "two"},
    ]);
  } catch (err) {
    print(err.toString());
  }
  

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;
    }

delete #

  Future delete() async {
    try {
      final data =
      await CustomDio().send(reqMethod: "delete", path: "dio-test/1");
      dLog(data.data.toString());
    } catch (err) {
      
    }
  }

getOne #

    try {
      final data =
      await CustomDio().send(reqMethod: "get", path: "dio-test/154");
      dLog(data.data.toString());
    } catch (err) {
    
    }
  }

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) {
    
    }
  }
9
likes
110
pub points
0%
popularity

Publisher

unverified uploader

custom_dio is wrapper above dio package to make send request easy

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

dio, flutter, path, pretty_dio_logger

More

Packages that depend on custom_dio