From 9a9a47195b510fe8721529bf26e833e4a7703ebf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cyanghuaxuan=E2=80=9D?= <“646903573@qq.com”> Date: Tue, 18 May 2021 15:39:12 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=8A=A0=E5=85=A5=E5=88=B7=E6=96=B0=E7=BB=84?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/custom_page/custom_item_page.dart | 9 ++- lib/pages/main_page/main_page.dart | 11 ++- lib/pages/wallet_page/wallet_page.dart | 15 ++-- lib/widgets/base_state/base_state.dart | 56 ++++++++++++++ .../custom/multi_nav/custom_quick_entry.dart | 30 +++++--- .../mine/mine_data/mine_data_container.dart | 10 ++- .../mine_header/mine_header_container.dart | 8 +- .../mine_header_static_container.dart | 27 +++---- .../wallet/wallet_data/wallet_data.dart | 77 +++++-------------- .../wallet/wallet_detail/wallet_detail.dart | 4 +- 10 files changed, 146 insertions(+), 101 deletions(-) create mode 100644 lib/widgets/base_state/base_state.dart diff --git a/lib/pages/custom_page/custom_item_page.dart b/lib/pages/custom_page/custom_item_page.dart index db43bb0..eefb351 100644 --- a/lib/pages/custom_page/custom_item_page.dart +++ b/lib/pages/custom_page/custom_item_page.dart @@ -6,6 +6,7 @@ import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:provider/provider.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_notifier.dart'; +import 'package:zhiying_base_widget/widgets/base_state/base_state.dart'; import 'package:zhiying_base_widget/widgets/custom/bottom_pic/bottom_pic.dart'; import 'package:zhiying_base_widget/widgets/empty/empty_widget.dart'; import 'package:zhiying_base_widget/widgets/home/home_auth/home_auth.dart'; @@ -66,7 +67,7 @@ class _CustomItemPageContainer extends StatefulWidget { __CustomItemPageContainerState createState() => __CustomItemPageContainerState(); } -class __CustomItemPageContainerState extends State<_CustomItemPageContainer> with AutomaticKeepAliveClientMixin { +class __CustomItemPageContainerState extends BasePageState<_CustomItemPageContainer> { @override bool get wantKeepAlive => true; @@ -88,6 +89,10 @@ class __CustomItemPageContainerState extends State<_CustomItemPageContainer> wit /// 刷新 void _refreshEvent() { BlocProvider.of(context).add(CustomItemPageRefreshEvent()); + + ///刷新页面 + + refreshPage(); } /// 下拉更多 @@ -120,7 +125,7 @@ class __CustomItemPageContainerState extends State<_CustomItemPageContainer> wit } @override - Widget build(BuildContext context) { + Widget buildX(BuildContext context) { return BlocConsumer( listener: (context, state) {}, buildWhen: (prev, current) { diff --git a/lib/pages/main_page/main_page.dart b/lib/pages/main_page/main_page.dart index 889c1e4..cd5ffd9 100644 --- a/lib/pages/main_page/main_page.dart +++ b/lib/pages/main_page/main_page.dart @@ -8,6 +8,7 @@ import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:zhiying_base_widget/pages/main_page/main_page_bloc.dart'; import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_bg_notifier.dart'; import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_notifier.dart'; +import 'package:zhiying_base_widget/widgets/base_state/base_state.dart'; import 'package:zhiying_base_widget/widgets/home/home_auth/home_auth.dart'; import 'package:zhiying_base_widget/widgets/mine/mine_nav/mine_nav_bg.dart'; import 'package:zhiying_base_widget/widgets/others/mine_header_bg_widget.dart'; @@ -53,7 +54,7 @@ class _MainPageContainer extends StatefulWidget { _MainPageContainerState createState() => _MainPageContainerState(); } -class _MainPageContainerState extends State<_MainPageContainer> { +class _MainPageContainerState extends BasePageState<_MainPageContainer> { bool _isEnded = false; ScrollController _controller = ScrollController(); MainPageBloc _bloc; @@ -73,6 +74,7 @@ class _MainPageContainerState extends State<_MainPageContainer> { if (widget.data.containsKey('skip_identifier')) { _bloc.loadData(widget.data['skip_identifier']); + refreshPage(); } } @@ -106,7 +108,7 @@ class _MainPageContainerState extends State<_MainPageContainer> { } @override - Widget build(BuildContext context) { + Widget buildX(BuildContext context) { double top = MediaQueryData.fromWindow(window).padding.top; return StreamBuilder>>( stream: _bloc.outData, @@ -185,9 +187,6 @@ class _MainPageContainerState extends State<_MainPageContainer> { ///处理特殊背景图 Widget validateBgWidget(BuildContext context, List> datas) { - - - for (int i = 0; i < datas.length; i++) { WidgetModel item = WidgetModel.fromJson(Map.from(datas[i])); if (item.modName == "profile_background") { @@ -221,7 +220,7 @@ class _MainPageContainerState extends State<_MainPageContainer> { if (_bloc.backgroundModel != null) { var headerBg = _bloc.backgroundModel.headerBg; return Container( - height: double.tryParse(_bloc?.backgroundModel?.headerBg?.height)?? 0, + height: double.tryParse(_bloc?.backgroundModel?.headerBg?.height) ?? 0, decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.topCenter, diff --git a/lib/pages/wallet_page/wallet_page.dart b/lib/pages/wallet_page/wallet_page.dart index 07c0274..07ad796 100644 --- a/lib/pages/wallet_page/wallet_page.dart +++ b/lib/pages/wallet_page/wallet_page.dart @@ -5,6 +5,7 @@ import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_bg_notifier.dart'; import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_notifier.dart'; import 'package:zhiying_base_widget/utils/contants.dart'; +import 'package:zhiying_base_widget/widgets/base_state/base_state.dart'; import 'package:zhiying_base_widget/widgets/hot_ranking/hot_ranking_list/model/hot_ranking_list_model.dart'; import 'package:zhiying_base_widget/widgets/refresh/refresh_header/refresh_header.dart'; import 'package:zhiying_base_widget/widgets/wallet/wallet_appbar/wallet_appbar_sk.dart'; @@ -28,22 +29,19 @@ class WalletPage extends StatefulWidget { _WalletPageState createState() => _WalletPageState(); } -class _WalletPageState extends State { +class _WalletPageState extends BasePageState { + + @override - Widget build(BuildContext context) { + Widget buildX(BuildContext context) { return Scaffold( backgroundColor: Color(0xfff9f9f9), - body: MultiProvider( - providers: [ - ChangeNotifierProvider.value(value: BaseChangeNotifier()), - ], - child: BlocProvider( + body: BlocProvider( bloc: WalletPageBloc(), child: _WalletPageContainer( data: widget.data, ), ), - ), ); } } @@ -103,7 +101,6 @@ class _WalletPageContainerState extends State<_WalletPageContainer> void _onRefresh() async { if (widget.data.containsKey(Constants.SkipIdentifierName)) { _pageBloc.loadData(widget.data[Constants.SkipIdentifierName]); - Provider.of(context,listen: false).refresh(); } } diff --git a/lib/widgets/base_state/base_state.dart b/lib/widgets/base_state/base_state.dart new file mode 100644 index 0000000..3b4530e --- /dev/null +++ b/lib/widgets/base_state/base_state.dart @@ -0,0 +1,56 @@ +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import 'package:zhiying_comm/zhiying_comm.dart'; +import 'package:zhiying_comm/util/base_bloc.dart'; + +///每个页面顶层使用这个状态 +abstract class BasePageState extends State { + // Widget build(BuildContext context) { + // return MultiProvider(providers: [ + // ChangeNotifierProvider.value(value: BaseChangeNotifier()), + // ], child: child); + // } + + BaseChangeNotifier baseChangeNotifier; + + @override + Widget build(BuildContext context) { + if(baseChangeNotifier==null){ + baseChangeNotifier = BaseChangeNotifier(); + } + return MultiProvider(providers: [ + ChangeNotifierProvider.value(value: baseChangeNotifier), + ], child: buildX(context)); + } + + Widget buildX(BuildContext context); + + ///刷新,所继承的子类调用此方法可刷新子组件 + void refreshPage() { + baseChangeNotifier.refresh(); + } + +} + +///每个需要刷新的小组件使用这个状态 +abstract class BaseWidgetState extends State { + + RefreshListener refreshListener = RefreshListener(); + + @override + void didChangeDependencies() { + refreshListener.listen(context, (value) { + print("刷新子控件"); + refreshWidget(value); + }); + super.didChangeDependencies(); + } + + @override + void dispose() { + //refreshListener?.close(); + super.dispose(); + } + + void refreshWidget(String value); +} diff --git a/lib/widgets/custom/multi_nav/custom_quick_entry.dart b/lib/widgets/custom/multi_nav/custom_quick_entry.dart index 8c94c73..bca50a2 100644 --- a/lib/widgets/custom/multi_nav/custom_quick_entry.dart +++ b/lib/widgets/custom/multi_nav/custom_quick_entry.dart @@ -4,6 +4,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_swiper/flutter_swiper.dart'; +import 'package:zhiying_base_widget/widgets/base_state/base_state.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'custom_quick_entry_sk.dart'; @@ -35,7 +36,7 @@ class _CustomQuickEntryContainer extends StatefulWidget { __CustomQuickEntryContainerState createState() => __CustomQuickEntryContainerState(); } -class __CustomQuickEntryContainerState extends State<_CustomQuickEntryContainer> with TickerProviderStateMixin, AutomaticKeepAliveClientMixin { +class __CustomQuickEntryContainerState extends BaseWidgetState<_CustomQuickEntryContainer> with TickerProviderStateMixin, AutomaticKeepAliveClientMixin { /// Icon点击事件 void _itemIconClick(ListStyle model) { print("item type = ${model.skipIdentifier}"); @@ -48,7 +49,7 @@ class __CustomQuickEntryContainerState extends State<_CustomQuickEntryContainer> @override void initState() { _controller = SwiperController(); - + print(widget?.model); super.initState(); } @@ -220,7 +221,6 @@ class __CustomQuickEntryContainerState extends State<_CustomQuickEntryContainer> ), ), ) - ], ), ), @@ -350,10 +350,11 @@ class __CustomQuickEntryContainerState extends State<_CustomQuickEntryContainer> width: 40, ), ), + /// 小角标 Visibility( visible: model?.isShowCornerIcon == '1', - child: Align(alignment: Alignment.topRight, child: Transform.translate( offset: Offset(7, -3) ,child: MyNetWorkImage(item?.rightIcon, width: 34)))) + child: Align(alignment: Alignment.topRight, child: Transform.translate(offset: Offset(7, -3), child: MyNetWorkImage(item?.rightIcon, width: 34)))) ], ), @@ -405,7 +406,8 @@ class __CustomQuickEntryContainerState extends State<_CustomQuickEntryContainer> SwiperPagination _swiperPaginationDot(CustomQuickEntryModel model) { return SwiperPagination( margin: const EdgeInsets.only(), - builder: DotSwiperPaginationBuilder(color: HexColor.fromHex(model?.paginationUnselectColor), activeColor: HexColor.fromHex(model?.paginationSelectColor), size: 8, activeSize: 8)); + builder: DotSwiperPaginationBuilder( + color: HexColor.fromHex(model?.paginationUnselectColor), activeColor: HexColor.fromHex(model?.paginationSelectColor), size: 8, activeSize: 8)); } // 自定义进度条 条形 @@ -448,6 +450,11 @@ class __CustomQuickEntryContainerState extends State<_CustomQuickEntryContainer> @override // TODO: implement wantKeepAlive bool get wantKeepAlive => true; + + @override + void refreshWidget(String value) { + setState(() {}); + } } /// @@ -476,7 +483,7 @@ class CustomQuickCateEntry extends StatefulWidget { _CustomQuickCateEntryState createState() => _CustomQuickCateEntryState(); } -class _CustomQuickCateEntryState extends State with TickerProviderStateMixin, AutomaticKeepAliveClientMixin { +class _CustomQuickCateEntryState extends BaseWidgetState with TickerProviderStateMixin, AutomaticKeepAliveClientMixin { TabController tabController; bool isOnTap = false; @@ -858,7 +865,6 @@ class _CustomQuickCateEntryState extends State with Ticker child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ - Stack( children: [ /// 图标 @@ -868,10 +874,11 @@ class _CustomQuickCateEntryState extends State with Ticker width: 40, ), ), + /// 小角标 Visibility( - visible: model?.isShowCornerIcon == '1', - child: Align(alignment: Alignment.topRight, child: Transform.translate( offset: Offset(7, -3) ,child: MyNetWorkImage(item?.rightIcon, width: 34)))) + visible: model?.isShowCornerIcon == '1', + child: Align(alignment: Alignment.topRight, child: Transform.translate(offset: Offset(7, -3), child: MyNetWorkImage(item?.rightIcon, width: 34)))) ], ), @@ -973,6 +980,11 @@ class _CustomQuickCateEntryState extends State with Ticker @override bool get wantKeepAlive => true; + + @override + void refreshWidget(String value) { + BlocProvider.of(context).add(CustomQuickEntryInitEvent(model: widget?.model?.toJson())); + } } class PageItem { diff --git a/lib/widgets/mine/mine_data/mine_data_container.dart b/lib/widgets/mine/mine_data/mine_data_container.dart index b32853e..ba6a507 100644 --- a/lib/widgets/mine/mine_data/mine_data_container.dart +++ b/lib/widgets/mine/mine_data/mine_data_container.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:zhiying_base_widget/widgets/base_state/base_state.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'; @@ -14,7 +15,7 @@ class MineDataContainer extends StatefulWidget { _MineDataContainerState createState() => _MineDataContainerState(); } -class _MineDataContainerState extends State { +class _MineDataContainerState extends BaseWidgetState { MineHeaderBloc _bloc; @override @@ -35,4 +36,11 @@ class _MineDataContainerState extends State { : MineDataWidget(profile, widget?.data); }); } + + @override + void refreshWidget(String value) { + _bloc.loadData(); + } + + } diff --git a/lib/widgets/mine/mine_header/mine_header_container.dart b/lib/widgets/mine/mine_header/mine_header_container.dart index c5ca829..3fac444 100644 --- a/lib/widgets/mine/mine_header/mine_header_container.dart +++ b/lib/widgets/mine/mine_header/mine_header_container.dart @@ -4,6 +4,7 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:fluttertoast/fluttertoast.dart'; +import 'package:zhiying_base_widget/widgets/base_state/base_state.dart'; import 'package:zhiying_base_widget/widgets/mine/mine_header/mine_header_bloc.dart'; import 'package:zhiying_base_widget/widgets/mine/mine_header/mine_header_sk.dart'; import 'package:zhiying_base_widget/widgets/mine/mine_header/model/mine_header_model.dart'; @@ -29,7 +30,7 @@ class MineHeaderContainer extends StatefulWidget { _MineHeaderContainerState createState() => _MineHeaderContainerState(); } -class _MineHeaderContainerState extends State { +class _MineHeaderContainerState extends BaseWidgetState { MineHeaderBloc _bloc; @override @@ -182,4 +183,9 @@ class _MineHeaderContainerState extends State { ); }); } + + @override + void refreshWidget(String value) { + _bloc?.loadData(); + } } diff --git a/lib/widgets/mine/mine_header/mine_header_static_container.dart b/lib/widgets/mine/mine_header/mine_header_static_container.dart index 3179c31..926ecf4 100644 --- a/lib/widgets/mine/mine_header/mine_header_static_container.dart +++ b/lib/widgets/mine/mine_header/mine_header_static_container.dart @@ -2,6 +2,7 @@ import 'dart:convert' as convert; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; +import 'package:zhiying_base_widget/widgets/base_state/base_state.dart'; import 'package:zhiying_base_widget/widgets/mine/mine_header/model/mine_header_model.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; @@ -21,7 +22,7 @@ class MineStaticContainer extends StatefulWidget { _MineStaticContainerState createState() => _MineStaticContainerState(); } -class _MineStaticContainerState extends State { +class _MineStaticContainerState extends BaseWidgetState { @override Widget build(BuildContext context) { return Container( @@ -32,15 +33,10 @@ class _MineStaticContainerState extends State { margin: EdgeInsets.only(left: 20, top: 20, bottom: 20, right: 12), width: 56, height: 56, - child: ClipRRect( - borderRadius: BorderRadius.circular(28), - child: CachedNetworkImage( - imageUrl: widget.staticModel.nonLginAvatar, - fit: BoxFit.cover)), + child: ClipRRect(borderRadius: BorderRadius.circular(28), child: CachedNetworkImage(imageUrl: widget.staticModel.nonLginAvatar, fit: BoxFit.cover)), ), onTap: () { - RouterUtil.route( - SkipModel.fromJson(widget.json), widget.json, context); + RouterUtil.route(SkipModel.fromJson(widget.json), widget.json, context); }, ), Expanded( @@ -52,10 +48,7 @@ class _MineStaticContainerState extends State { width: 120, child: Text( widget.staticModel.loginName, - style: TextStyle( - color: HexColor.fromHex( - widget.staticModel?.userNameColor ?? '#ffffff'), - fontSize: 17), + style: TextStyle(color: HexColor.fromHex(widget.staticModel?.userNameColor ?? '#ffffff'), fontSize: 17), ), ), Container( @@ -63,10 +56,7 @@ class _MineStaticContainerState extends State { width: 80, child: Text( widget.staticModel.loginNameHelpText, - style: TextStyle( - color: HexColor.fromHex( - widget.staticModel?.userNameColor ?? '#ffffff'), - fontSize: 13), + style: TextStyle(color: HexColor.fromHex(widget.staticModel?.userNameColor ?? '#ffffff'), fontSize: 13), )), ], )) @@ -74,4 +64,9 @@ class _MineStaticContainerState extends State { ), ); } + + @override + void refreshWidget(String value) { + setState(() {}); + } } diff --git a/lib/widgets/wallet/wallet_data/wallet_data.dart b/lib/widgets/wallet/wallet_data/wallet_data.dart index a1b56ca..2df3ad2 100644 --- a/lib/widgets/wallet/wallet_data/wallet_data.dart +++ b/lib/widgets/wallet/wallet_data/wallet_data.dart @@ -3,6 +3,7 @@ import 'dart:convert'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:zhiying_base_widget/widgets/base_state/base_state.dart'; import 'package:zhiying_base_widget/widgets/wallet/wallet_data/model/wallet_header_model.dart'; import 'package:zhiying_base_widget/widgets/wallet/wallet_data/wallet_data_bloc.dart'; import 'package:zhiying_base_widget/widgets/wallet/wallet_data/wallet_data_sk.dart'; @@ -18,7 +19,7 @@ class WalletData extends StatefulWidget { _WalletDataState createState() => _WalletDataState(); } -class _WalletDataState extends State { +class _WalletDataState extends BaseWidgetState { Map data; WalletDataBloc _bloc; @@ -32,16 +33,6 @@ class _WalletDataState extends State { _bloc.loadHeaderData(); } - @override - void didChangeDependencies() { - - RefreshListener.listen(context, (event) { - _bloc.loadHeaderData(); - }); - super.didChangeDependencies(); - } - - @override void dispose() { super.dispose(); @@ -68,11 +59,7 @@ class _WalletDataState extends State { : Container( margin: EdgeInsets.only(left: 12.5, right: 12.5, top: 10), padding: EdgeInsets.only(left: 18, right: 13), - decoration: BoxDecoration( - image: DecorationImage( - image: CachedNetworkImageProvider( - model?.headerImg ?? ""), - fit: BoxFit.fill)), + decoration: BoxDecoration(image: DecorationImage(image: CachedNetworkImageProvider(model?.headerImg ?? ""), fit: BoxFit.fill)), height: 145, child: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, @@ -91,26 +78,17 @@ class _WalletDataState extends State { Padding( padding: const EdgeInsets.all(8.0), child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( model?.headerCashOutText ?? "", - style: TextStyle( - fontSize: 12.5, - color: HexColor.fromHex( - model?.headerCashOutTextColor ?? - "")), + style: TextStyle(fontSize: 12.5, color: HexColor.fromHex(model?.headerCashOutTextColor ?? "")), ), Text( - dataModel.containsKey( - model.headerCashOutKey) - ? dataModel[model.headerCashOutKey] - : "", + dataModel.containsKey(model.headerCashOutKey) ? dataModel[model.headerCashOutKey] : "", style: TextStyle( fontSize: 20, - color: HexColor.fromHex( - model.headerCashOutTextColor), + color: HexColor.fromHex(model.headerCashOutTextColor), fontFamily: 'Din-Bold', package: 'zhiying_comm', ), @@ -122,28 +100,18 @@ class _WalletDataState extends State { ), GestureDetector( onTap: () { - RouterUtil.route( - model, model.toJson(), context); + RouterUtil.route(model, model.toJson(), context); }, child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), - image: DecorationImage( - image: CachedNetworkImageProvider( - model.headerCashOutBtnImg ?? ''), - fit: BoxFit.fill), + image: DecorationImage(image: CachedNetworkImageProvider(model.headerCashOutBtnImg ?? ''), fit: BoxFit.fill), ), child: Padding( - padding: EdgeInsets.only( - left: 14.5, - right: 14.5, - top: 10, - bottom: 10), + padding: EdgeInsets.only(left: 14.5, right: 14.5, top: 10, bottom: 10), child: Text( model.headerCashOutBtnText, - style: TextStyle( - color: HexColor.fromHex( - model.headerCashOutBtnTextColor)), + style: TextStyle(color: HexColor.fromHex(model.headerCashOutBtnTextColor)), ), ), ), @@ -153,9 +121,7 @@ class _WalletDataState extends State { Divider( height: 1, ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: _buildTopListItem(model)) + Row(mainAxisAlignment: MainAxisAlignment.spaceAround, children: _buildTopListItem(model)) ], ), )); @@ -171,23 +137,22 @@ class _WalletDataState extends State { mainAxisSize: MainAxisSize.min, children: [ Text( - dataModel.containsKey(item.valueKey) - ? dataModel[item.valueKey] - : "", - style: TextStyle( - color: HexColor.fromHex(item.valueColor), - fontSize: 15, - fontFamily: 'Din-Bold', - package: 'zhiying_comm'), + dataModel.containsKey(item.valueKey) ? dataModel[item.valueKey] : "", + style: TextStyle(color: HexColor.fromHex(item.valueColor), fontSize: 15, fontFamily: 'Din-Bold', package: 'zhiying_comm'), ), Text( item.text, - style: TextStyle( - color: HexColor.fromHex(item.textColor), fontSize: 11), + style: TextStyle(color: HexColor.fromHex(item.textColor), fontSize: 11), ), ], )); } return listWidget; } + + @override + void refreshWidget(String value) { + _bloc.loadHeaderData(); + } + } diff --git a/lib/widgets/wallet/wallet_detail/wallet_detail.dart b/lib/widgets/wallet/wallet_detail/wallet_detail.dart index c7d628d..0683d19 100644 --- a/lib/widgets/wallet/wallet_detail/wallet_detail.dart +++ b/lib/widgets/wallet/wallet_detail/wallet_detail.dart @@ -43,9 +43,11 @@ class _WalletDetailState extends State with TickerProviderStateMix super.initState(); } + RefreshListener refreshListener = RefreshListener(); + @override void didChangeDependencies() { - RefreshListener.listen(context, (event) { + refreshListener.listen(context, (event) { if (event == "refresh") { if (_bloc.currentType == null) { _bloc.loadData(_model.providers[0].type, _bloc.selectDay);