|
123456789101112131415161718192021222324252627282930313233343536 |
- import 'dart:async';
- import 'dart:convert' as convert;
-
- import 'package:zhiying_base_widget/pages/setting_page/models/setting_page_style_model.dart';
- import 'package:zhiying_comm/util/base_bloc.dart';
- import 'package:zhiying_comm/zhiying_comm.dart';
-
- class SettingPageBloc extends BlocBase {
- SettingPageStyleModel _style;
-
- StreamController<SettingPageStyleModel> _styleController =
- StreamController<SettingPageStyleModel>();
-
- Stream<SettingPageStyleModel> get outData => _styleController.stream;
-
- @override
- void dispose() {
- _styleController.close();
- _styleController = null;
- }
-
- void loadData(String skipIdentifier) async {
- Api api = Api(
- '/api/v1/mod/${skipIdentifier.toString()}', method: NetMethod.GET,);
- _loadData(await api.onCache());
- _loadData(await api.onRequest());
- }
-
- void _loadData(dynamic data) {
- Map<String, dynamic> json = Map<String, dynamic>.from(data);
- String d = json['data'];
- Map<String, dynamic> da = Map<String, dynamic>.from(convert.jsonDecode(d));
- _style = SettingPageStyleModel.fromJson(da);
- _styleController.add(_style);
- }
- }
|