achievement_info_model.dart 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import 'package:flutter/material.dart';
  2. import 'package:fluttertoast/fluttertoast.dart';
  3. import 'package:sport/bean/achievement_detail_info.dart';
  4. import 'package:sport/bean/achievement_info.dart';
  5. import 'package:sport/provider/lib/view_state_list_model.dart';
  6. import 'package:sport/services/api/inject_api.dart';
  7. class AchievementInfoModel extends ViewStateListModel with InjectLoginApi {
  8. final int id;
  9. AchievementInfoModel( this.id);
  10. AchievementInfo? data;
  11. AchieveDetailInfo? detailData;
  12. Future<AchievementInfo> getAchievementInfo() async {
  13. AchievementInfo _achievementInfo = await loginApi.getAchievementInfo();
  14. if (_achievementInfo.code != 0) {
  15. // Fluttertoast.showToast(
  16. // msg: "${_achievementInfo.msg}",
  17. // toastLength: Toast.LENGTH_SHORT,
  18. // gravity: ToastGravity.CENTER,
  19. // backgroundColor: Colors.white,
  20. // textColor: Colors.black,
  21. // fontSize: 13.0);
  22. }
  23. data = _achievementInfo;
  24. notifyListeners();
  25. return _achievementInfo;
  26. }
  27. Future<AchieveDetailInfo> getAchieveDetailInfo(int id) async {
  28. AchieveDetailInfo _achieveDetailInfo =
  29. await loginApi.getAchieveDetailInfo(id);
  30. if (_achieveDetailInfo.code != 0) {
  31. Fluttertoast.showToast(
  32. msg: "${_achieveDetailInfo.msg}",
  33. toastLength: Toast.LENGTH_SHORT,
  34. gravity: ToastGravity.CENTER,
  35. backgroundColor: Colors.white,
  36. textColor: Colors.black,
  37. fontSize: 13.0);
  38. }
  39. detailData = _achieveDetailInfo;
  40. notifyListeners();
  41. return _achieveDetailInfo;
  42. }
  43. @override
  44. Future<List> loadData() async {
  45. AchieveDetailInfo _achieveDetailInfo =
  46. await loginApi.getAchieveDetailInfo(id);
  47. return [_achieveDetailInfo];
  48. }
  49. }