haveno-app/lib/providers/prices_provider.dart

27 lines
801 B
Dart
Raw Normal View History

2024-07-14 15:34:24 +00:00
import 'package:flutter/material.dart';
import 'package:haveno_flutter_app/proto/compiled/grpc.pbgrpc.dart';
import 'package:haveno_flutter_app/services/haveno_service.dart';
class PricesProvider with ChangeNotifier {
final HavenoService _havenoService;
2024-07-15 19:14:30 +00:00
List<MarketPriceInfo> _marketPrices = [];
2024-07-14 15:34:24 +00:00
PricesProvider(this._havenoService);
2024-07-15 19:14:30 +00:00
List<MarketPriceInfo> get prices => _marketPrices;
2024-07-14 15:34:24 +00:00
2024-07-15 19:14:30 +00:00
Future<void> getXmrMarketPrices() async {
2024-07-14 15:34:24 +00:00
try {
final getMarketPricesReply = await _havenoService.priceClient
.getMarketPrices(MarketPricesRequest());
_marketPrices = getMarketPricesReply.marketPrice;
2024-07-15 19:14:30 +00:00
_marketPrices.forEach((price) {
2024-07-14 15:34:24 +00:00
print("Price: $price");
});
notifyListeners();
} catch (e) {
print("Failed to get prices: $e");
}
}
}