37 lines
992 B
Dart
37 lines
992 B
Dart
import 'package:equatable/equatable.dart';
|
|
|
|
class TickerModel extends Equatable {
|
|
final String ticker;
|
|
final String? exchange;
|
|
final String? tradingCurrency;
|
|
final double? currentPrice;
|
|
|
|
const TickerModel({
|
|
required this.ticker,
|
|
this.exchange,
|
|
this.tradingCurrency,
|
|
this.currentPrice,
|
|
});
|
|
|
|
factory TickerModel.fromJson(Map<String, dynamic> json) {
|
|
return TickerModel(
|
|
ticker: json['ticker']?.toString() ?? '',
|
|
exchange: json['exchange']?.toString(),
|
|
tradingCurrency: json['tradingCurrency']?.toString(),
|
|
currentPrice: (json['currentPrice'] as num?)?.toDouble(),
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'ticker': ticker,
|
|
if (exchange != null) 'exchange': exchange,
|
|
if (tradingCurrency != null) 'tradingCurrency': tradingCurrency,
|
|
if (currentPrice != null) 'currentPrice': currentPrice,
|
|
};
|
|
}
|
|
|
|
@override
|
|
List<Object?> get props => [ticker, exchange, tradingCurrency, currentPrice];
|
|
}
|