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_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 { @override Widget build(BuildContext context) { UserInfoModel user = Provider.of(context).userInfo; if (user == null || user.token == null || user.token == '') { // 未登录 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), ); } }