基础组件库
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

40 lines
1012 B

  1. import 'dart:async';
  2. import 'package:zhiying_comm/util/base_bloc.dart';
  3. import 'package:zhiying_comm/zhiying_comm.dart';
  4. class MainPageBloc extends BlocBase {
  5. List<Map<String, dynamic>> _pageData = List();
  6. StreamController<List<Map<String, dynamic>>> _mainController =
  7. StreamController<List<Map<String, dynamic>>>();
  8. Stream<List<Map<String, dynamic>>> get outData => _mainController.stream;
  9. @override
  10. void dispose() {
  11. _mainController.close();
  12. _mainController = null;
  13. }
  14. void loadData(String skipIdentifier) {
  15. NetUtil.request('/api/v1/mod/${skipIdentifier}', method: NetMethod.GET,
  16. onCache: (data) {
  17. _loadData(data);
  18. }, onSuccess: (data) {
  19. _loadData(data);
  20. });
  21. }
  22. void _loadData(dynamic data) {
  23. Map<String, dynamic> json = Map<String, dynamic>.from(data);
  24. List<dynamic> list = json['mod_list'];
  25. _pageData = list.map((item) {
  26. return Map<String, dynamic>.from(item);
  27. }).toList();
  28. _mainController.add(_pageData);
  29. }
  30. }