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

37 lines
1.1 KiB

  1. import 'dart:async';
  2. import 'dart:convert' as convert;
  3. import 'package:zhiying_base_widget/pages/setting_page/models/setting_page_style_model.dart';
  4. import 'package:zhiying_comm/util/base_bloc.dart';
  5. import 'package:zhiying_comm/zhiying_comm.dart';
  6. class SettingPageBloc extends BlocBase {
  7. SettingPageStyleModel _style;
  8. StreamController<SettingPageStyleModel> _styleController =
  9. StreamController<SettingPageStyleModel>();
  10. Stream<SettingPageStyleModel> get outData => _styleController.stream;
  11. @override
  12. void dispose() {
  13. _styleController.close();
  14. _styleController = null;
  15. }
  16. void loadData(String skipIdentifier) async {
  17. Api api = Api(
  18. '/api/v1/mod/${skipIdentifier.toString()}', method: NetMethod.GET,);
  19. _loadData(await api.onCache());
  20. _loadData(await api.onRequest());
  21. }
  22. void _loadData(dynamic data) {
  23. Map<String, dynamic> json = Map<String, dynamic>.from(data);
  24. String d = json['data'];
  25. Map<String, dynamic> da = Map<String, dynamic>.from(convert.jsonDecode(d));
  26. _style = SettingPageStyleModel.fromJson(da);
  27. _styleController.add(_style);
  28. }
  29. }