|
- import 'dart:async';
-
- import 'package:zhiying_comm/zhiying_comm.dart';
- import 'package:zhiying_comm/util/base_bloc.dart';
-
- class MainPageBloc extends BlocBase {
- List<List<Map<String, dynamic>>> _mains = List();
-
- StreamController<List<List<Map<String, dynamic>>>> _mainController =
- StreamController<List<List<Map<String, dynamic>>>>();
- Stream<List<List<Map<String, dynamic>>>> get outData =>
- _mainController.stream;
-
- @override
- void dispose() {
- _mainController.close();
- _mainController = null;
- }
-
- void loadData(List<int> ids) {
- NetUtil.request('/api/v1/mod',
- method: NetMethod.POST,
- params: Map<String, dynamic>.from({'ids': ids}), onSuccess: (data) {
- Map<String, dynamic> datas = data;
- List<List<Map<String, dynamic>>> result = List();
- for (int id in ids) {
- if (datas.containsKey(id.toString())) {
- result.add(List<Map<String, dynamic>>.from(datas[id.toString()]));
- } else {
- result.add(List<Map<String, dynamic>>());
- }
- }
- _mains = result;
- _mainController.add(_mains);
- });
- }
- }
|