From 90325a15ae5190cb77c350da4906ad7d88c96e76 Mon Sep 17 00:00:00 2001 From: PH2 <1293456824@qq.com> Date: Fri, 16 Oct 2020 17:12:13 +0800 Subject: [PATCH 1/2] =?UTF-8?q?1=E3=80=81=E4=BA=BA=E8=84=89=E5=85=B3?= =?UTF-8?q?=E8=81=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team_page/model/team_data_model.dart | 88 +++++++++++-------- .../team/recommend/team_recommend_widget.dart | 11 ++- 2 files changed, 58 insertions(+), 41 deletions(-) diff --git a/lib/pages/team_page/model/team_data_model.dart b/lib/pages/team_page/model/team_data_model.dart index 05ccb3b..ba6cffc 100644 --- a/lib/pages/team_page/model/team_data_model.dart +++ b/lib/pages/team_page/model/team_data_model.dart @@ -1,41 +1,55 @@ class TeamDataModel { - String all_fans; - String direct_fans_count; - String indirect_fans_count; - String referrer_invite_code; - String referrer_phone; - String referrer_username; - String referrer_wechat; - String today_add; - String yesterday_add; + String all_fans; + String direct_fans_count; + String indirect_fans_count; + String referrer_invite_code; + String referrer_phone; + String referrer_username; + String referrer_wechat; + String today_add; + String yesterday_add; + String referrerAvatar; - TeamDataModel({this.all_fans, this.direct_fans_count, this.indirect_fans_count, this.referrer_invite_code, this.referrer_phone, this.referrer_username, this.referrer_wechat, this.today_add, this.yesterday_add}); + TeamDataModel({ + this.all_fans, + this.direct_fans_count, + this.indirect_fans_count, + this.referrer_invite_code, + this.referrer_phone, + this.referrer_username, + this.referrer_wechat, + this.today_add, + this.yesterday_add, + this.referrerAvatar, + }); - factory TeamDataModel.fromJson(Map json) { - return TeamDataModel( - all_fans: json['all_fans'], - direct_fans_count: json['direct_fans_count'], - indirect_fans_count: json['indirect_fans_count'], - referrer_invite_code: json['referrer_invite_code'], - referrer_phone: json['referrer_phone'], - referrer_username: json['referrer_username'], - referrer_wechat: json['referrer_wechat'], - today_add: json['today_add'], - yesterday_add: json['yesterday_add'], - ); - } + factory TeamDataModel.fromJson(Map json) { + return TeamDataModel( + all_fans: json['all_fans'], + direct_fans_count: json['direct_fans_count'], + indirect_fans_count: json['indirect_fans_count'], + referrer_invite_code: json['referrer_invite_code'], + referrer_phone: json['referrer_phone'], + referrer_username: json['referrer_username'], + referrer_wechat: json['referrer_wechat'], + today_add: json['today_add'], + yesterday_add: json['yesterday_add'], + referrerAvatar: json['referrer_avatar'], + ); + } - Map toJson() { - final Map data = new Map(); - data['all_fans'] = this.all_fans; - data['direct_fans_count'] = this.direct_fans_count; - data['indirect_fans_count'] = this.indirect_fans_count; - data['referrer_invite_code'] = this.referrer_invite_code; - data['referrer_phone'] = this.referrer_phone; - data['referrer_username'] = this.referrer_username; - data['referrer_wechat'] = this.referrer_wechat; - data['today_add'] = this.today_add; - data['yesterday_add'] = this.yesterday_add; - return data; - } -} \ No newline at end of file + Map toJson() { + final Map data = new Map(); + data['all_fans'] = this.all_fans; + data['direct_fans_count'] = this.direct_fans_count; + data['indirect_fans_count'] = this.indirect_fans_count; + data['referrer_invite_code'] = this.referrer_invite_code; + data['referrer_phone'] = this.referrer_phone; + data['referrer_username'] = this.referrer_username; + data['referrer_wechat'] = this.referrer_wechat; + data['today_add'] = this.today_add; + data['yesterday_add'] = this.yesterday_add; + data['referrer_avatar'] = this.referrerAvatar; + return data; + } +} diff --git a/lib/widgets/team/recommend/team_recommend_widget.dart b/lib/widgets/team/recommend/team_recommend_widget.dart index 80b454f..d8a624a 100644 --- a/lib/widgets/team/recommend/team_recommend_widget.dart +++ b/lib/widgets/team/recommend/team_recommend_widget.dart @@ -231,7 +231,7 @@ class _TeamRecommendWidgetState extends State<_TeamRecommendWidgetContainer> { mainAxisAlignment: MainAxisAlignment.start, children: [ /// 头像widget - _getAvatarWidget(), + _getAvatarWidget(dataModel), const SizedBox(width: 12), @@ -242,11 +242,14 @@ class _TeamRecommendWidgetState extends State<_TeamRecommendWidgetContainer> { } /// 头像widget - Widget _getAvatarWidget() { + Widget _getAvatarWidget(TeamDataModel dataModel) { return Container( width: 55, - height: 55, - color: Colors.red, + // height: 55, + // color: Colors.red, + child: CachedNetworkImage( + imageUrl: dataModel?.referrerAvatar ?? '', + ), ); } From c75396ce8d93ae16b3e044ec242232cb46969f1d Mon Sep 17 00:00:00 2001 From: PH2 <1293456824@qq.com> Date: Mon, 19 Oct 2020 15:15:24 +0800 Subject: [PATCH 2/2] =?UTF-8?q?1=E3=80=81=E5=95=86=E5=93=81=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E7=9A=84=E9=A2=84=E5=8A=A0=E8=BD=BD=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=202=E3=80=81=E6=88=91=E7=9A=84=E4=BA=BA=E8=84=89=E7=9A=84?= =?UTF-8?q?=E5=A4=B4=E9=83=A8=E6=8E=A8=E8=8D=90=E4=BA=BAbug=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bloc/goods_details_page_bloc.dart | 13 +- .../bloc/goods_details_page_repository.dart | 220 +++++++++++------- .../goods_details_page.dart | 7 +- lib/pages/team_page/bloc/team_bloc.dart | 1 - .../team_page/model/team_data_model.dart | 11 +- lib/pages/team_page/team_page.dart | 4 +- .../home_goods/models/home_goods_model.dart | 30 +-- .../recommend/bloc/team_recommend_bloc.dart | 7 +- .../bloc/team_recommend_repository.dart | 15 ++ .../recommend/bloc/team_recommend_state.dart | 4 +- .../team/recommend/team_recommend_widget.dart | 12 +- 11 files changed, 207 insertions(+), 117 deletions(-) diff --git a/lib/pages/goods_details_page/bloc/goods_details_page_bloc.dart b/lib/pages/goods_details_page/bloc/goods_details_page_bloc.dart index 81cdf21..9a5182f 100644 --- a/lib/pages/goods_details_page/bloc/goods_details_page_bloc.dart +++ b/lib/pages/goods_details_page/bloc/goods_details_page_bloc.dart @@ -30,13 +30,16 @@ class GoodsDetailsPageBloc extends Bloc _mapInitEventToState(GoodsDetailsPageInitEvent event) async* { - var result = await repository.fetchInitModData(event.model); + + // 获取上面传回来的数据 + var parendData = await repository.fetchParentPageData(event?.model); + if(!EmptyUtil.isEmpty(parendData)){ + yield GoodsDetailsPageLoadedState(model: parendData); + } + // 获取服务器的数据 + var result = await repository.fetchInitModData(event?.model); if (!EmptyUtil.isEmpty(result)) { yield GoodsDetailsPageLoadedState(model: result); - // var itemModelData = await repository.fetchModData(event.model); - // if(!EmptyUtil.isEmpty(itemModelData)){ - // yield GoodsDetailsPageLoadedState(model: itemModelData); - // } } else { yield GoodsDetailsPageErrorState(); } diff --git a/lib/pages/goods_details_page/bloc/goods_details_page_repository.dart b/lib/pages/goods_details_page/bloc/goods_details_page_repository.dart index 8beaab1..9f5e117 100644 --- a/lib/pages/goods_details_page/bloc/goods_details_page_repository.dart +++ b/lib/pages/goods_details_page/bloc/goods_details_page_repository.dart @@ -2,107 +2,161 @@ import 'dart:convert'; import 'package:zhiying_comm/zhiying_comm.dart'; class GoodsDetailsPageRepository { - - - + /// 获取上个页面传进来的数据 + Future>> fetchParentPageData(final Map model) async { + try { + if (!EmptyUtil.isEmpty(model) && model.containsKey('detail_data') && !EmptyUtil.isEmpty(model['detail_data'])) { + String provider = model['provider']?.toString(); + String goodId = model['good_id']?.toString(); + if (!EmptyUtil.isEmpty(provider) && !EmptyUtil.isEmpty(goodId)) { + Map detailData = model['detail_data']; + return _baseDataProcess(goodId, provider, detailData); + // Logger.log('商品类型 = $provider, 商品ID = $goodId'); + // List> _pageData = []; + // List modLists = detailData['mod_list']; + // for (int i = 0; i < modLists.length; i++) { + // Map item = modLists[i]; + // Map data = item['data']; + // Map baseData = {'provider': provider, 'good_id': goodId}; + // data.addAll(baseData); + // item['data'] = data; + // _pageData.add(item); + // } + // return _pageData; + } + } + } catch (e, s) { + Logger.error(e, s); + } + return null; + } /// 获取数据 - Future>> fetchInitModData(final Map model) async{ - - String provider = model['provider']; - String goodId = model['good_id']; + Future>> fetchInitModData(final Map model) async { try { + String provider = model['provider']; + String goodId = model['good_id']; if (!EmptyUtil.isEmpty(provider) && !EmptyUtil.isEmpty(goodId)) { Logger.log('商品类型 = $provider, 商品ID = $goodId'); var result = await NetUtil.post('/api/v1/detail/$provider/$goodId', method: NetMethod.GET); if (NetUtil.isSuccess(result) && !EmptyUtil.isEmpty(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA])) { + return _baseDataProcess(goodId, provider, result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]); + // List> _pageData = []; - List> _pageData = []; /// 合并数据 - List modLists = result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]['mod_list']; - for(int i = 0; i < modLists.length; i++){ - Map item = modLists[i]; - Map data = item['data']; - Map style = jsonDecode(item['style']); + // List modLists = result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]['mod_list']; + // for (int i = 0; i < modLists.length; i++) { + // Map item = modLists[i]; + // Map data = item['data']; + // Map style = jsonDecode(item['style']); + // + // Map baseData = {'provider': provider, 'good_id': goodId}; + // style.addAll(baseData); + // + // if (!EmptyUtil.isEmpty(data)) { + // style.addAll(data); + // item['data'] = jsonEncode(style); + // _pageData.add(item); + // } else { + // item['data'] = jsonEncode(style); + // _pageData.add(item); + // } + // } + // + // return _pageData; + } + } + } catch (e, s) { + Logger.error(e, s); + } + return null; + } - Map baseData = {'provider': provider, 'good_id': goodId}; - style.addAll(baseData); + /// 数据处理 + List> _baseDataProcess(String goodId, String provider, final Map model) { + if (!EmptyUtil.isEmpty(provider) && !EmptyUtil.isEmpty(goodId) && !EmptyUtil.isEmpty(model)) { + try { + List> _pageData = []; + Map baseData = {'provider': provider, 'good_id': goodId}; + List modLists = model['mod_list']; + for (int i = 0; i < modLists.length; i++) { + Map item = modLists[i]; + Map data = item['data'] is String ? jsonDecode(item['data']) : item['data']; + Map style = jsonDecode(item['style']); + style.addAll(baseData); - if(!EmptyUtil.isEmpty(data)){ - style.addAll(data); - item['data'] = jsonEncode(style); - _pageData.add(item); - }else{ - item['data'] = jsonEncode(style); - _pageData.add(item); - } + if (!EmptyUtil.isEmpty(data)) { + style.addAll(data); + item['data'] = jsonEncode(style); + _pageData.add(item); + } else { + item['data'] = jsonEncode(style); + _pageData.add(item); } - - return _pageData; } + return _pageData; + } catch (e, s) { + Logger.error(e, s); } - }catch(e){ - Logger.log(e); } return null; } - ///【弃用】获取mod数据 把子mod数据塞在data中 - // Future>> fetchModData(final Map model) async{ - // String provider = model['provider']; - // String goodId = model['good_id']; - // try { - // if (!EmptyUtil.isEmpty(provider) && !EmptyUtil.isEmpty(goodId)) { - // Logger.log('商品类型 = $provider, 商品ID = $goodId'); - // var result = await NetUtil.post('/api/v1/detail/$provider/$goodId', method: NetMethod.GET); - // if(NetUtil.isSuccess(result) && !EmptyUtil.isEmpty(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA])) { - // for (int i = 0; i < _pageData.length; i++) { - // //result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]['mod_list'][i]; - // Map resultData = result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]['mod_list'][i]; - // Map data = jsonDecode(_pageData[i]['data']); - // if(!EmptyUtil.isEmpty(data)){ - // data.addAll(resultData); - // _pageData[i]['data'] = jsonEncode(data); - // }else{ - // _pageData[i]['data'] = (null != resultData && resultData.length > 0) ? jsonEncode(resultData) : ''; - // } - // } - // return _pageData; - // } - // } - // }catch(e){ - // Logger.log(e); - // } - // return null; - // } - // - // ///【弃用】初始化 - // Future>> fetchInitData(Map model) async { - // int id = 13; - // var result = await NetUtil.post('/api/v1/mod', method: NetMethod.POST, params: {'ids': [id]}); - // try { - // if(NetUtil.isSuccess(result) && !EmptyUtil.isEmpty(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA])) { - // return _loadData(id, result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]); - // } - // } catch (e) { - // Logger.log(e); - // } - // return null; - // } - // - // ///【弃用】处理数据 - // List> _loadData(int id, dynamic data) { - // String key = id.toString(); - // Map json = Map.from(data); - // if (json.containsKey(key)) { - // List list = json[key]; - // _pageData = list.map((item) { - // return Map.from(item); - // }).toList(); - // return _pageData; - // } - // return null; - // } +// Future>> fetchModData(final Map model) async{ +// String provider = model['provider']; +// String goodId = model['good_id']; +// try { +// if (!EmptyUtil.isEmpty(provider) && !EmptyUtil.isEmpty(goodId)) { +// Logger.log('商品类型 = $provider, 商品ID = $goodId'); +// var result = await NetUtil.post('/api/v1/detail/$provider/$goodId', method: NetMethod.GET); +// if(NetUtil.isSuccess(result) && !EmptyUtil.isEmpty(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA])) { +// for (int i = 0; i < _pageData.length; i++) { +// //result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]['mod_list'][i]; +// Map resultData = result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]['mod_list'][i]; +// Map data = jsonDecode(_pageData[i]['data']); +// if(!EmptyUtil.isEmpty(data)){ +// data.addAll(resultData); +// _pageData[i]['data'] = jsonEncode(data); +// }else{ +// _pageData[i]['data'] = (null != resultData && resultData.length > 0) ? jsonEncode(resultData) : ''; +// } +// } +// return _pageData; +// } +// } +// }catch(e){ +// Logger.log(e); +// } +// return null; +// } +// +// ///【弃用】初始化 +// Future>> fetchInitData(Map model) async { +// int id = 13; +// var result = await NetUtil.post('/api/v1/mod', method: NetMethod.POST, params: {'ids': [id]}); +// try { +// if(NetUtil.isSuccess(result) && !EmptyUtil.isEmpty(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA])) { +// return _loadData(id, result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]); +// } +// } catch (e) { +// Logger.log(e); +// } +// return null; +// } +// +// ///【弃用】处理数据 +// List> _loadData(int id, dynamic data) { +// String key = id.toString(); +// Map json = Map.from(data); +// if (json.containsKey(key)) { +// List list = json[key]; +// _pageData = list.map((item) { +// return Map.from(item); +// }).toList(); +// return _pageData; +// } +// return null; +// } } diff --git a/lib/pages/goods_details_page/goods_details_page.dart b/lib/pages/goods_details_page/goods_details_page.dart index 173cad3..5f7354d 100644 --- a/lib/pages/goods_details_page/goods_details_page.dart +++ b/lib/pages/goods_details_page/goods_details_page.dart @@ -23,7 +23,7 @@ class GoodsDetailsPage extends StatefulWidget { class _GoodsDetailsPageState extends State { @override void initState() { - print("parent data = ${widget.data}"); + print("parent data = ${widget?.data}"); super.initState(); } @@ -36,8 +36,7 @@ class _GoodsDetailsPageState extends State { ], child: BlocProvider( create: (_) => - GoodsDetailsPageBloc(repository: GoodsDetailsPageRepository()) - ..add(GoodsDetailsPageInitEvent(model: widget?.data)), + GoodsDetailsPageBloc(repository: GoodsDetailsPageRepository())..add(GoodsDetailsPageInitEvent(model: widget?.data)), child: GoodsDetailsContainer(widget?.data), ), ); @@ -118,7 +117,7 @@ class _GoodsDetailsContainerState extends State { return true; }, builder: (context, state) { - print('currente state = $state'); + print('GoodsDetailsPage currente state = $state'); if (state is GoodsDetailsPageLoadedState) { return _getMainWidget(state?.model); } diff --git a/lib/pages/team_page/bloc/team_bloc.dart b/lib/pages/team_page/bloc/team_bloc.dart index 8074b41..a32e173 100644 --- a/lib/pages/team_page/bloc/team_bloc.dart +++ b/lib/pages/team_page/bloc/team_bloc.dart @@ -46,7 +46,6 @@ class TeamBloc extends Bloc { } var resultData = await repository.fetchNetData(); if (!EmptyUtil.isEmpty(resultData) && (!EmptyUtil.isEmpty(resultStyle) || !EmptyUtil.isEmpty(cache))) { - Logger.log('================================================= load ================='); yield TeamLoadedState(dataModel: resultData, styleModel: !EmptyUtil.isEmpty(resultStyle) ? resultStyle : cache); } else { yield TeamErrorState(); diff --git a/lib/pages/team_page/model/team_data_model.dart b/lib/pages/team_page/model/team_data_model.dart index ba6cffc..eae9d97 100644 --- a/lib/pages/team_page/model/team_data_model.dart +++ b/lib/pages/team_page/model/team_data_model.dart @@ -1,4 +1,6 @@ -class TeamDataModel { +import 'package:equatable/equatable.dart'; + +class TeamDataModel extends Equatable { String all_fans; String direct_fans_count; String indirect_fans_count; @@ -52,4 +54,11 @@ class TeamDataModel { data['referrer_avatar'] = this.referrerAvatar; return data; } + + + + + @override + List get props => [this.all_fans, this.direct_fans_count, this.indirect_fans_count, this.referrer_invite_code, this.referrer_phone, this.referrer_username, this.referrer_wechat, + this.today_add, this.yesterday_add, this.referrerAvatar]; } diff --git a/lib/pages/team_page/team_page.dart b/lib/pages/team_page/team_page.dart index 51110ea..8e50910 100644 --- a/lib/pages/team_page/team_page.dart +++ b/lib/pages/team_page/team_page.dart @@ -52,10 +52,10 @@ class _TeamPageContainerState extends State<_TeamPageContainer> { return true; }, builder: (context, state) { - print('TeamPage state === $state'); + print('TeamPage state === $state, '); if (state is TeamLoadedState) { _initTabController(state?.styleModel); - return _getMainWidget(state.styleModel, state.dataModel); + return _getMainWidget(state?.styleModel, state?.dataModel); } /// 骨架屏幕 diff --git a/lib/widgets/home/home_goods/models/home_goods_model.dart b/lib/widgets/home/home_goods/models/home_goods_model.dart index 334ebed..d180c9c 100644 --- a/lib/widgets/home/home_goods/models/home_goods_model.dart +++ b/lib/widgets/home/home_goods/models/home_goods_model.dart @@ -12,19 +12,22 @@ class HomeGoodsModel extends Equatable { String marketPrice; String currentPrice; String inorderCount; + Map detailData; - HomeGoodsModel( - {this.provider, - this.providerName, - this.goodId, - this.goodImage, - this.goodTitle, - this.shopName, - this.coupon, - this.commission, - this.marketPrice, - this.currentPrice, - this.inorderCount}); + HomeGoodsModel({ + this.provider, + this.providerName, + this.goodId, + this.goodImage, + this.goodTitle, + this.shopName, + this.coupon, + this.commission, + this.marketPrice, + this.currentPrice, + this.inorderCount, + this.detailData, + }); HomeGoodsModel.fromJson(Map json) { provider = json['provider']; @@ -38,6 +41,7 @@ class HomeGoodsModel extends Equatable { marketPrice = json['market_price']; currentPrice = json['current_price']; inorderCount = json['inorder_count']; + detailData = json['detail_data']; } Map toJson() { @@ -53,10 +57,10 @@ class HomeGoodsModel extends Equatable { data['market_price'] = this.marketPrice; data['current_price'] = this.currentPrice; data['inorder_count'] = this.inorderCount; + data['detail_data'] = this.detailData; return data; } @override List get props => [this.goodId, this.provider, this.providerName]; } - diff --git a/lib/widgets/team/recommend/bloc/team_recommend_bloc.dart b/lib/widgets/team/recommend/bloc/team_recommend_bloc.dart index c8480ce..bddd677 100644 --- a/lib/widgets/team/recommend/bloc/team_recommend_bloc.dart +++ b/lib/widgets/team/recommend/bloc/team_recommend_bloc.dart @@ -37,7 +37,12 @@ class TeamRecommendBloc extends Bloc { /// 初始化数据 Stream _mapInitEventToState(TeamRecommendInitEvent event) async* { - yield TeamRecommendLoadedState(event?.dataModel); + var dataModel = await repository.fetchNetData(); + if (!EmptyUtil.isEmpty(dataModel) && !EmptyUtil.isEmpty(dataModel.referrer_username) && !EmptyUtil.isEmpty(dataModel.referrer_invite_code)) { + yield TeamRecommendLoadedState(dataModel); + } else { + yield TeamRecommendErrorState(); + } } /// 关联推荐人 diff --git a/lib/widgets/team/recommend/bloc/team_recommend_repository.dart b/lib/widgets/team/recommend/bloc/team_recommend_repository.dart index a269743..ebe3245 100644 --- a/lib/widgets/team/recommend/bloc/team_recommend_repository.dart +++ b/lib/widgets/team/recommend/bloc/team_recommend_repository.dart @@ -14,4 +14,19 @@ class TeamRecommendRepository { } return null; } + + /// 获取网络数据 + Future fetchNetData() async { + var data = await NetUtil.post('/api/v1/user/myteam', method: NetMethod.GET); + try { + if (NetUtil.isSuccess(data) && !EmptyUtil.isEmpty(data[GlobalConfig.HTTP_RESPONSE_KEY_DATA])) { + TeamDataModel _dataModel = TeamDataModel.fromJson(data[GlobalConfig.HTTP_RESPONSE_KEY_DATA]); + return _dataModel; + } + } catch (e, s) { + Logger.log('e = $e, s = $s'); + } + return null; + } + } diff --git a/lib/widgets/team/recommend/bloc/team_recommend_state.dart b/lib/widgets/team/recommend/bloc/team_recommend_state.dart index dda193e..0e5ba3b 100644 --- a/lib/widgets/team/recommend/bloc/team_recommend_state.dart +++ b/lib/widgets/team/recommend/bloc/team_recommend_state.dart @@ -10,9 +10,9 @@ class TeamRecommendInitial extends TeamRecommendState { } class TeamRecommendLoadedState extends TeamRecommendState { - TeamDataModel model; + final TeamDataModel model; - TeamRecommendLoadedState(this.model); + const TeamRecommendLoadedState(this.model); @override List get props => [this.model]; diff --git a/lib/widgets/team/recommend/team_recommend_widget.dart b/lib/widgets/team/recommend/team_recommend_widget.dart index d8a624a..1cbb204 100644 --- a/lib/widgets/team/recommend/team_recommend_widget.dart +++ b/lib/widgets/team/recommend/team_recommend_widget.dart @@ -21,7 +21,7 @@ class TeamRecommendWidget extends StatelessWidget { Widget build(BuildContext context) { return BlocProvider( create: (_) => TeamRecommendBloc(TeamRecommendRepository())..add(TeamRecommendInitEvent(dataModel: dataModel)), - child: _TeamRecommendWidgetContainer(styleModel), + child: _TeamRecommendWidgetContainer(styleModel, dataModel), ); } } @@ -29,17 +29,19 @@ class TeamRecommendWidget extends StatelessWidget { class _TeamRecommendWidgetContainer extends StatefulWidget { TeamStyleModel styleModel; - // TeamDataModel dataModel; + TeamDataModel dataModel; - _TeamRecommendWidgetContainer(this.styleModel); + _TeamRecommendWidgetContainer(this.styleModel, dataModel); @override - _TeamRecommendWidgetState createState() => _TeamRecommendWidgetState(); + __TeamRecommendWidgetState createState() => __TeamRecommendWidgetState(); } -class _TeamRecommendWidgetState extends State<_TeamRecommendWidgetContainer> { +class __TeamRecommendWidgetState extends State<_TeamRecommendWidgetContainer> { TextEditingController _textEditingController; FocusNode _focusNode; + TeamStyleModel styleModel; + TeamDataModel dataModel; /// 按钮点击添加事件 void _onClickListener() {