dio_response_validator 0.1.0 copy "dio_response_validator: ^0.1.0" to clipboard
dio_response_validator: ^0.1.0 copied to clipboard

outdated

An extension on Dio response futures to perform validation and data transformation

example/example.dart

import 'package:dio/dio.dart';
import 'package:dio_response_validator/dio_response_validator.dart';

void main() async {
  final dio = Dio();

  final successResponse =
      await dio.get('https://vrchat.com/api/1/config').validate(
            transform: (data) => data['apiKey'],
          );

  // Prints the api key
  printResponse(successResponse);

  final errorResponse =
      await dio.get('https://vrchat.com/api/2/config').validate();

  // Prints a 404 error
  printResponse(errorResponse);
}

void printResponse(ValidatedResponse response) {
  if (response.success != null) {
    print(response.success!.data);
  } else {
    print(response.error!.validationError);
  }
}
0
likes
0
pub points
26%
popularity

Publisher

verified publisherrexios.dev

An extension on Dio response futures to perform validation and data transformation

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

dio

More

Packages that depend on dio_response_validator