showWalletSelectDialog function
- required BuildContext context,
- required List<
BaseWalletAdapter> adapters, - WidgetBuilder dialogTitleBuilder = _selectWallet,
- double height = 400,
- double width = 300,
- WalletStateToText walletStateToText = _defaultEnglish,
- WidgetOverrideBuilder? overrideBuilder,
Shows a dialog that lets the user select a wallet.
adapters is a list of adapters the user should choose from.
The future completes either with the BaseWalletAdapter the user choose
from the adapters list, or with null if the user closed the dialog
without selecting a wallet.
You can change the dimension of the dialog using the height and width
parameters.
The walletStateToText is used to convert the BaseWalletAdapter.walletState
into a human readable text. It defaults to English, so override this if you want to
localize the dialog. The wallet state of each element in adapters is shown
as part of the dialog.
You can change the dialogs title widget from the default Select Wallet text
to something different by specifying a builder, what is useful for localization.
Finally, you can override or extend the way the dialog should be build by passing an
overrideBuilder. In this case, whatever the overrideBuilder returns will
be used as dialog widget (for the underlying showDialog) instead. The child
parameter of the WidgetOverrideBuilder will contain the way that the dialog
would have been build if you hadn't spcifyed the overrideBuilder.
Implementation
Future<BaseWalletAdapter?> showWalletSelectDialog(
{required BuildContext context,
required List<BaseWalletAdapter> adapters,
WidgetBuilder dialogTitleBuilder = _selectWallet,
double height = 400,
double width = 300,
WalletStateToText walletStateToText = _defaultEnglish,
WidgetOverrideBuilder? overrideBuilder}) {
//ignore: prefer_function_declarations_over_variables
WidgetBuilder builder = (BuildContext context) => new SimpleDialog(
title: dialogTitleBuilder(context),
children: [
new SizedBox(
height: height,
width: width,
child: new ListView.builder(
itemCount: adapters.length,
itemBuilder: (BuildContext context, int index) {
return new _AdapterListTile(
adapter: adapters[index],
walletStateToText: walletStateToText,
);
}),
)
],
);
return showDialog<BaseWalletAdapter>(
context: context,
builder: overrideBuilder == null
? builder
: (BuildContext context) => overrideBuilder(context, builder));
}