starknet.dart
starknet.dart copied to clipboard
Account infos loading issue with wallet_kit when WalletBody widget is not used
When using wallet_kit, I encountered an issue where the DeployAccountButtonappear, and a message saying "Not enough ETH" is shown — even though my account does have ETH.
This issue occurs depending on how the widgets are structured in the widget tree.
✅ Working code (button is available):
const Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Column(
mainAxisSize: MainAxisSize.min,
children: [
WalletSelector(),
AccountAddress(),
DeployAccountButton(),
],
),
WalletBody(),
SendEthButton(),
WalletErrorHandler(),
],
),
❌ Not working (button is NOT available):
const Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Column(
mainAxisSize: MainAxisSize.min,
children: [
WalletSelector(),
AccountAddress(),
DeployAccountButton(),
],
),
SendEthButton(),
WalletErrorHandler(),
],
),
Note: The two snippets look the same — this is intentional, as I’m using the same code, but getting different behavior depending on how it's rendered.
Hypothesis:
It seems that WalletBody may internally initialize some providers or context necessary for DeployAccountButton to work correctly (ex: selectedAccount!.balances).
I forced in my project
final selectedAccount =
ref.watch(walletsProvider.select((value) => value.selectedAccount));
if (selectedAccount != null) {
ref.read(walletsProvider.notifier)
..refreshEthBalance(
selectedAccount.walletId,
selectedAccount.id,
)
..refreshStrkBalance(
selectedAccount.walletId,
selectedAccount.id,
);
}
instead of using WalletBody widget
Could you assign me this issue please
Recommended by OnlyDust for outstanding experience and quality contributions.
Hi, I have multiple OSS experience and mobile development on blockchain projects, would love to tackle this!
Recommended by OnlyDust for outstanding experience and quality contributions.