import 'dart:async'; import 'package:zhiying_comm/util/base_bloc.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; class HotRankingBloc extends BlocBase { List> _pageData = List(); StreamController>> _dataController = StreamController>>(); Stream>> get outData => _dataController.stream; @override void dispose() { _dataController.close(); _dataController = null; } void loadData(int id) { NetUtil.request('/api/v1/mod', method: NetMethod.POST, params: Map.from({ 'ids': [id] }), onCache: (data) { _loadData(id, data); }, onSuccess: (data) { _loadData(id, data); }); } void _loadData(int id, dynamic data) { String key = id.toString(); Map json = Map.from(data); if (json.containsKey(key)) { List list = json[key]; _pageData = list.map((item) { return Map.from(item); }).toList(); } _dataController.add(_pageData); } }