mirror of
https://github.com/Uuttssaavv/flutter-clean-architecture-riverpod.git
synced 2025-08-06 16:19:42 +08:00
27 lines
583 B
Dart
27 lines
583 B
Dart
// To parse this JSON data, do
|
|
//
|
|
// final parseResponse = parseResponseFromMap(jsonString);
|
|
|
|
class ParseResponse<T> {
|
|
ParseResponse({
|
|
this.status,
|
|
this.message,
|
|
this.data,
|
|
this.success = false,
|
|
});
|
|
final bool success;
|
|
final String? status;
|
|
final String? message;
|
|
final T? data;
|
|
|
|
factory ParseResponse.fromMap(dynamic json,
|
|
{required T Function(dynamic) modifier}) {
|
|
return ParseResponse<T>(
|
|
success: json['status'] == 'success',
|
|
status: json['status'],
|
|
message: json['message'],
|
|
data: modifier(json),
|
|
);
|
|
}
|
|
}
|