YSPriceView.dart 999 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import 'package:flutter/material.dart';
  2. import '../../tools/YSColors.dart';
  3. import '../../tools/YSNetWork.dart';
  4. import '../../tools/YSTools.dart';
  5. class YSPriceView extends StatefulWidget {
  6. final Map item;
  7. const YSPriceView({Key? key, required this.item}) : super(key: key);
  8. @override
  9. YSPriceViewState createState() => YSPriceViewState();
  10. }
  11. class YSPriceViewState extends State<YSPriceView> {
  12. Map _info = {};
  13. @override
  14. void initState() {
  15. networkDelay((){
  16. _getInfoData();
  17. });
  18. super.initState();
  19. }
  20. _getInfoData() async{
  21. YSNetWork.ysRequestHttp(context, type: RequestType.get, api: 'market24hr', parameter: {'symbol':widget.item['symbol']}, successSetter: (dict){
  22. List list = dict['data']['list']??[];
  23. if(list.isNotEmpty){
  24. _info = list.first;
  25. setState(() {});
  26. }
  27. });
  28. }
  29. @override
  30. Widget build(BuildContext context) {
  31. return Text(_info.isNotEmpty?_info['lastPrice']:'',style: YSColors.subStyle(context),);
  32. }
  33. }