custom_dio_fix 1.0.0 copy "custom_dio_fix: ^1.0.0" to clipboard
custom_dio_fix: ^1.0.0 copied to clipboard

基于custom_dio适配新版 Flutter 的网络请求插件

custom_dio_fix #

基于custom_dio适配新版 Flutter 的网络请求插件

Getting Started #

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: RequestMethod.post, path: "user/login", body: {"email": "email"});
  } catch (err) {
    print(err.toString());
  }

GET #

  try {
   final data = await CustomDio()
        .send(reqMethod: RequestMethod.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: RequestMethod.delete, path: "dio-test/1");
      dLog(data.data.toString());
    } catch (err) {
      
    }
  }

getOne #

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

patch #

  Future update() async {
    try {
      final data = await CustomDio().send(
          reqMethod: RequestMethod.patch,
          path: "dio-test",
          body: {"content": "update content"});
      dLog(data.data.toString());
    } catch (err) {
    
    }
  }
1
likes
120
points
18
downloads

Publisher

unverified uploader

Weekly Downloads

基于custom_dio适配新版 Flutter 的网络请求插件

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

dio, flutter, flutter_pretty_dio_logger, path

More

Packages that depend on custom_dio_fix