import 'package:flutter/material.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_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'; 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) { return BlocProvider( bloc: MineHeaderBloc(), child: _MineDataContainer(widget.data), ); } } class _MineDataContainer extends StatefulWidget { final Map data; const _MineDataContainer(this.data, {Key key}) : super(key: key); @override _MineDataContainerState createState() => _MineDataContainerState(); } class _MineDataContainerState extends State<_MineDataContainer> { MineHeaderBloc _bloc; @override void initState() { _bloc = BlocProvider.of(context); _bloc.loadData(); super.initState(); } @override Widget build(BuildContext context) { return StreamBuilder( stream: _bloc.outData, builder: (BuildContext context, AsyncSnapshot snapshot) { MineProfileModel profile = snapshot.data; return profile == null ? MineDataSkeleton() : MineDataWidget(profile, widget.data); }); } }