基础组件库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

38 lines
1.1 KiB

  1. import 'dart:async';
  2. import 'package:zhiying_comm/zhiying_comm.dart';
  3. import 'package:zhiying_comm/util/base_bloc.dart';
  4. class MainPageBloc extends BlocBase {
  5. List<List<Map<String, dynamic>>> _mains = List();
  6. StreamController<List<List<Map<String, dynamic>>>> _mainController =
  7. StreamController<List<List<Map<String, dynamic>>>>();
  8. Stream<List<List<Map<String, dynamic>>>> get outData =>
  9. _mainController.stream;
  10. @override
  11. void dispose() {
  12. _mainController.close();
  13. _mainController = null;
  14. }
  15. void loadData(List<int> ids) {
  16. NetUtil.request('/api/v1/mod',
  17. method: NetMethod.POST,
  18. params: Map<String, dynamic>.from({'ids': ids}), onSuccess: (data) {
  19. Map<String, dynamic> datas = data;
  20. List<List<Map<String, dynamic>>> result = List();
  21. for (int id in ids) {
  22. if (datas.containsKey(id.toString())) {
  23. result.add(List<Map<String, dynamic>>.from(datas[id.toString()]));
  24. } else {
  25. result.add(List<Map<String, dynamic>>());
  26. }
  27. }
  28. _mains = result;
  29. _mainController.add(_mains);
  30. });
  31. }
  32. }