35 lines
781 B
Dart
35 lines
781 B
Dart
import 'package:json_annotation/json_annotation.dart';
|
|
|
|
part 'coins_dto.g.dart';
|
|
|
|
class CoinsDto {
|
|
final List<CoinDataDto>? coins;
|
|
|
|
CoinsDto({this.coins});
|
|
|
|
factory CoinsDto.fromJson(List<dynamic> json) => CoinsDto(
|
|
coins: json.map((e) => CoinDataDto.fromJson(e as Map<String, dynamic>)).toList(),
|
|
);
|
|
}
|
|
|
|
@JsonSerializable(createToJson: false)
|
|
class CoinDataDto {
|
|
final String? id;
|
|
final String? name;
|
|
final String? image;
|
|
@JsonKey(name: 'current_price')
|
|
final double? currentPrice;
|
|
@JsonKey(name: 'price_change_24h')
|
|
final double? priceChange24h;
|
|
|
|
CoinDataDto({
|
|
this.id,
|
|
this.name,
|
|
this.image,
|
|
this.currentPrice,
|
|
this.priceChange24h,
|
|
});
|
|
|
|
factory CoinDataDto.fromJson(Map<String, dynamic> json) => _$CoinDataDtoFromJson(json);
|
|
}
|