Overview
🚀 djangoflow_openapi_extensions
is a Flutter package that empowers your Dio error handling in DjangoFlow OpenAPI projects with style and ease. Say goodbye to confusing error messages!
Features
🎉 Configurable Error Messages: Customize error messages according to your app's vibe.
🔮 Enhanced Error Handling: Transform Dio error messages into user-friendly and meaningful forms.
🛠️ Easy Integration: Effortlessly integrate enhanced error handling into your Dio client.
Installation
Add the following line to your pubspec.yaml
file:
dependencies:
djangoflow_openapi_extensions: <latest_version>
Usage
- Configure Error Messages:
import 'package:djangoflow_openapi_extensions/djangoflow_openapi_extensions.dart';
void main() {
// Customize error messages as needed
final customConfig = ErrorMessageConfig(
serverUnreachable: 'Cannot reach the server',
maintenance: 'Under maintenance - try again later',
// ... other custom messages
);
final transformer = ErrorMessageTransformer(config: customConfig);
final errorInterceptor = ErrorInterceptor(errorMessageTransformer: transformer);
// Use errorInterceptor with your Dio client
final dio = Dio();
dio.interceptors.add(errorInterceptor);
DjangoflowOpenapi(
dio:dio
// other properties...
);
}
- Handling Dio Errors:
try {
// Make Dio requests
} on DioException catch (error) {
// Errors will be transformed based on your configuration
print(error.message);
}
Additiona tools
generate-openapi.sh
: OpenAPI Client Generation Scriptgenerate-openapi-copywith
: Enabling CopyWith extension for Djangoflow OpenAPI client script
Contributing
🙌 Contributions are welcome! Feel free to submit issues and pull requests to enhance this package.
License
📜 This package is released under the MIT License.
If you encounter any issues or have questions, please feel free to open an issue.
Happy coding! ✨🚀