import 'dart:async'; import 'package:zhiying_comm/util/base_bloc.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; class MainPageBloc extends BlocBase { List> _pageData = List(); StreamController>> _mainController = StreamController>>(); Stream>> get outData => _mainController.stream; @override void dispose() { _mainController.close(); _mainController = null; } void loadData(String skipIdentifier) { NetUtil.request('/api/v1/mod/${skipIdentifier}', method: NetMethod.GET, onCache: (data) { _loadData(data); }, onSuccess: (data) { _loadData(data); }); } void _loadData(dynamic data) { Map json = Map.from(data); List list = json['mod_list']; _pageData = list.map((item) { return Map.from(item); }).toList(); _mainController.add(_pageData); } }