Import the package:#
Create your ReownAppKitModal() instance, which is your primary class for opening, closing, disconnecting, etc.
Be sure to update the project ID and metadata with your own.
Head over to Reown Dashboard and create a new project.
Initialization#
In order to initialize ReownAppKitModal() instance you must provide a projectId and a metadata.
Alternatively, ReownAppKitModal() allows you to create an instance by passing a ReownAppKit() object as follows:
The metadata object should contain your dApp's name, description, url and icon. Redirect object is optional but highly recommended. See next session why.
Redirect to your dApp#
AppKit's metadata object contains a redirect option that should be used by the wallet to redirect back to your dapp after connection.
native: value must be a valid URI scheme: https://developer.mozilla.org/en-US/docs/Web/URI/Reference/Schemes#syntax
But in order for the redirect mechanism to work, you would also need to add the following in the iOS and Android native sides:
- Locate your
Info.plistfile underyour_project/ios/Runner/folder. - Locate the
<key>CFBundleURLTypes</key>section. - Add your schema as
<dict>entry within the<array>object as follows.
- Locate your
AndroidManifest.xmlfile underyour_project/android/app/src/main/folder. - Locate the
<Activity .MainActivityinside the<application />scope. - Add the following intent
If you encounter any issues with your deep linking navigation, especially after upgrading to Flutter 3.27 or later, we kindly encourage you to disable Flutter built-in deep-linking feature as it's been set to true by default, introducing a breaking change: https://docs.flutter.dev/release/breaking-changes/deep-links-flag-change
So below your <intent-filter>, you would add this:
Available Buttons#
AppKitModalConnectButton to open the modal and connect to a wallet or through social options
AppKitModalNetworkSelectButton to select an available network
AppKitModalAccountButton to open account screen once connected
AppKitModalAddressButton shows the address on the current selected network
AppKitModalBalanceButton shows wallet balance on the current selected network
To connect to a wallet, you can either use AppKitModalConnectButton or AppKitModalNetworkSelectButton.
AppKitModalNetworkSelectButton will allow the user to pre-select a network before connecting while AppKitModalConnectButton will directly show available wallets and social options.
Once connected, AppKitModalConnectButton will serve as a Disconnect button while AppKitModalAccountButton will show basic account data such as balance and address and will be used to open the Account screen.
Quick example:
AppKitModalAccountButton is composed of AppKitModalBalanceButton and AppKitModalAddressButton, and you can use these separately from AppKitModalAccountButton
Custom Buttons#
If you'd like, you can also override AppKit's buttons by using the custom: property as follows
openModalView() method can accept a "startWidget" argument that you can leverage to open specifics screens of the modal: