web3modal_flutter关闭底部弹窗时误退当前路由问题求助
问题描述
在Flutter项目中使用web3modal_flutter包打开钱包选择底部弹窗时,点击弹窗的关闭按钮(X),包会执行Navigator.pop(context)退出当前所在的页面路由,而非仅关闭底部弹窗。但在Dialog组件内调用相同的openModal方法时功能正常,使用同一个context调用自定义的bottom sheet也能正常关闭。目前怀疑是传入的context存在问题,但未排查到代码异常。
相关代码
页面实现代码
@RoutePage() class CreateWalletQuickFundPage extends StatelessWidget { const CreateWalletQuickFundPage({super.key}); @override Widget build(BuildContext context) { final userBloc = context.read<UserBloc>(); return PageWrapper( cubit: ConnectWalletCubit(context.read<UserBloc>()), child: Padding( padding: const EdgeInsets.symmetric(horizontal: 32), child: Column( children: [ const SizedBox(height: 32), BlocBuilder<UserBloc, UserState>( builder: (context, state) { return WalletQrCode(wallet: state.selectedWallet!); }, ), const SizedBox(height: 32), Text( context.l10n.welcomeToYourNewWallet, style: context.typography.heading2, textAlign: TextAlign.center, ), const SizedBox(height: 14), ConstrainedBox( constraints: const BoxConstraints(maxWidth: 290), child: Text( context.l10n.thisIsYourPersonalBankVaultForTokens, style: context.typography.text14, textAlign: TextAlign.center, ), ), const SizedBox(height: 50), BlocBuilder<ConnectWalletCubit, ConnectWalletState>( builder: (context, state) { final connectWalletCubit = context.read<ConnectWalletCubit>(); return Button( onTap: () async { await connectWalletCubit.w3mService.openModal(context); }, text: context.l10n.fundYourWallet, activeColor: context.colors.moonGreen, ); }, ), ], ), ), ); } }
自定义Bottom Sheet调用代码
showBottomSheet( context: context, builder: (context) => const SelectNetworkBottomSheet(), );
内容的提问来源于stack exchange,提问作者Nixon
相关产品推荐
相关产品推荐

