clear_response

Creator: coderz1093

Last updated:

0 purchases

clear_response Image
clear_response Images

Languages

Categories

Add to Cart

Description:

clear response

Clear response #
A simple response handler for Dart and Flutter.
Example #
Use this package to handle errors and return type in methods.
Usage #
import 'package:clear_response/clear_response.dart';

Future<ClearResponse<String?, ClearErrorResponse?>> genericMethod() async {
try {
final response = await Future.delayed(
Duration(seconds: 1),
() => 'Hello world',
);
return ClearResponse(
data: response
error: null,
);
} catch (e) {
return ClearResponse(
data: null,
error: ClearErrorResponse(
message: e.toString(),
code: 500,
),
);
}
}

Future<void> main() async {
final response = await genericMethod();
if (response.error != null) {
print('Error, code: ${response.error?.code}, message: ${response.error?.message}');
} else {
print(response.data);
}
}
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.