import 'dart:convert' as convert; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:zhiying_base_widget/widgets/mine/mine_data/mine_data_container.dart'; import 'package:zhiying_base_widget/widgets/mine/mine_data/mine_data_sk.dart'; import 'package:zhiying_base_widget/widgets/mine/mine_data/mine_data_widget.dart'; import 'package:zhiying_base_widget/widgets/mine/mine_data/model/mine_data_model.dart'; import 'package:zhiying_base_widget/widgets/mine/mine_header/mine_header_bloc.dart'; import 'package:zhiying_base_widget/widgets/mine/mine_header/model/mine_profile_model.dart'; import 'package:zhiying_comm/util/base_bloc.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; class MineData extends StatefulWidget { final Map data; const MineData(this.data, {Key key}) : super(key: key); @override _MineDataState createState() => _MineDataState(); } class _MineDataState extends State { UserInfoModel _user; bool _isSketelon = true; @override Widget build(BuildContext context) { if (_isSketelon) { Provider.of(context).getUserInfoModel().then((user) { setState(() { _user = user; _isSketelon = false; }); }); } if (_isSketelon) { return MineDataSkeleton(); } if (_user == null) { String value = '123'; int result = int.tryParse(value); // 未登录 String d = widget.data['data']; Map json = convert.jsonDecode(d); MineDataModel style = MineDataModel.fromJson(Map.from(json)); List list = style.gridView.map((item) { return MineProfileDataModel(name: item.name, value: '¥0'); }).toList(); MineProfileModel profile = MineProfileModel( username:'', avatar:'', inviteCode:'', userLvName:'', userLvIcon:'', total:'', gridViews:list, ); return MineDataWidget(profile, widget.data); } return BlocProvider( bloc: MineHeaderBloc(), child: MineDataContainer(widget.data), ); } }