基础组件库
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.
 
 
 
 
 

36 lines
841 B

  1. import 'dart:async';
  2. import 'package:zhiying_comm/util/base_bloc.dart';
  3. import 'package:zhiying_comm/zhiying_comm.dart';
  4. class HomePageBloc extends BlocBase {
  5. List<Map<String, dynamic>> _tabs = List();
  6. StreamController<List<Map<String, dynamic>>> _tabController =
  7. StreamController<List<Map<String, dynamic>>>();
  8. Stream<List<Map<String, dynamic>>> get outData => _tabController.stream;
  9. @override
  10. void dispose() {
  11. _tabController.close();
  12. _tabController = null;
  13. }
  14. void refresh() {
  15. NetUtil.request('/api/v1/config.json', onCache: (data) {
  16. _refresh(data);
  17. }, onSuccess: (data) {
  18. _refresh(data);
  19. });
  20. }
  21. void _refresh(dynamic data) {
  22. List list = data;
  23. _tabs = list.map((item) {
  24. return Map<String, dynamic>.from(item);
  25. }).toList();
  26. _tabController.add(_tabs);
  27. }
  28. }