WalletConnectModalService class
- Inheritance
-
- Implemented types
-
Constructors
-
WalletConnectModalService({IWeb3App? web3App, String? projectId, PairingMetadata? metadata, Map<String, RequiredNamespace>? requiredNamespaces, Set<String>? recommendedWalletIds, ExcludedWalletState excludedWalletState = ExcludedWalletState.list, Set<String>? excludedWalletIds})
-
Creates a new instance of WalletConnectModalService.
web3App
is optional and can be used to pass in an already created Web3App
.
projectId
and metadata
are optional and can be used to create a new Web3App
.
You must provide either a projectId
and metadata
or an already created web3App
, or this will throw an ArgumentError.
requiredNamespaces
is optional and can be used to pass in a custom set of required namespaces.
explorerService is optional and can be used to pass in a custom IExplorerService.
recommendedWalletIds
is optional and can be used to pass in a custom set of recommended wallet IDs.
excludedWalletState
is optional and can be used to pass in a custom ExcludedWalletState.
excludedWalletIds
is optional and can be used to pass in a custom set of excluded wallet IDs.
Properties
-
address
→ String?
-
The address of the currently connected account.
no setteroverride
-
connectResponse
↔ ConnectResponse?
-
getter/setter pair
-
context
↔ BuildContext?
-
getter/setter pair
-
didDispose
→ Future<Null>
-
A Future that will complete when this object has been disposed.
no setterinherited
-
disposableTypeName
→ String
-
A type name, similar to runtimeType but intended to work
with minified code.
no setterinherited
-
disposalTreeSize
→ int
-
The total size of the disposal tree rooted at the current Disposable
instance.
no setterinherited
-
hashCode
→ int
-
The hash code for this object.
no setterinherited
-
hasListeners
→ bool
-
Whether any listeners are currently registered.
no setterinherited
-
initError
→ dynamic
-
If the web3App fails to initialize and throws an exception, this will contain the caught exception.
Otherwise, it will be null.
no setteroverride
-
isConnected
→ bool
-
Variable that can be used to check if the web3App is connected
no setteroverride
-
isDisposed
→ bool
-
Whether this object has been disposed.
no setterinherited
-
isInitialized
→ bool
-
Whether or not this object has been initialized.
no setteroverride
-
isLeakFlagSet
→ bool
-
Whether the leak flag for this object has been set.
no setterinherited
-
isOpen
→ bool
-
Variable that can be used to check if the modal is visible on screen.
no setteroverride
-
isOrWillBeDisposed
→ bool
-
Whether the disposal of this object has been requested, is in progress, or
is complete.
no setterinherited
-
projectId
→ String
-
The project ID used to initialize the web3App.
no setteroverride
-
requiredNamespaces
→ Map<String, RequiredNamespace>
-
The required namespaces that will be used when connecting to the wallet
no setteroverride
-
runtimeType
→ Type
-
A representation of the runtime type of the object.
no setterinherited
-
session
→ SessionData?
-
The current session's data.
no setteroverride
-
sessionFuture
→ Future<SessionData>?
-
no setter
-
wcUri
→ String?
-
The URI that can be used to connect to this dApp.
This is only available after the open function is called.
no setteroverride
-
web3App
→ IWeb3App?
-
The object that manages sessions, authentication, events, and requests
for WalletConnect.
no setteroverride
Methods
-
addListener(VoidCallback listener)
→ void
-
Register a closure to be called when the object changes.
inherited
-
awaitBeforeDispose<T>(Future<T> future)
→ Future<T>
-
Add
future
to a list of futures that will be awaited before the
object is disposed.
inherited
-
close()
→ void
-
Closes the modal.
override
-
connectWallet({required WalletData walletData})
→ Future<void>
-
override
-
disconnect()
→ Future<void>
-
Disconnects the session and pairing, if any.
If there is no session, this does nothing.
override
-
dispose()
→ Future<Null>
-
Dispose of the object, cleaning up to prevent memory leaks.
inherited
-
flagLeak([String? description])
→ void
-
Flag the object as having been disposed in a way that allows easier
profiling.
inherited
-
getManagedDelayedFuture<T>(Duration duration, T callback())
→ Future<T>
-
Creates a Future that will complete, with the value
returned by
callback
, after the given amount of time has elapsed.
inherited
-
getManagedDisposer(Disposer disposer)
→ ManagedDisposer
-
Automatically handle arbitrary disposals using a callback.
inherited
-
getManagedPeriodicTimer(Duration duration, void callback(Timer timer))
→ Timer
-
Creates a periodic Timer that will be cancelled if active
upon disposal.
inherited
-
getManagedTimer(Duration duration, void callback())
→ Timer
-
Creates a Timer instance that will be cancelled if active
upon disposal.
inherited
-
getReferer()
→ String
-
Sets the required namespaces that will be used when connecting to the wallet
The default is set to the NamespaceConstants.ethereum namespace.
Gets the name of the currently connected wallet.
override
-
init()
→ Future<void>
-
The service used to fetch wallet listings from the explorer API.
Sets up the explorer and the web3App if they already been initialized.
override
-
launchCurrentWallet()
→ Future<void>
-
override
-
listenToStream<T>(Stream<T> stream, void onData(T event), {Function? onError, void onDone()?, bool? cancelOnError})
→ StreamSubscription<T>
-
Returns a StreamSubscription which handles events from the stream using
the provided
onData
, onError
and onDone
handlers.
inherited
-
manageAndReturnTypedDisposable<T extends Disposable>(T disposable)
→ T
-
Automatically dispose another object when this object is disposed.
inherited
-
manageCompleter<T>(Completer<T> completer)
→ Completer<T>
-
Ensure that a completer is completed when the object is disposed.
inherited
-
manageDisposable(Disposable disposable)
→ void
-
inherited
-
manageStreamController(StreamController controller)
→ void
-
Automatically cancel a stream controller when this object is disposed.
inherited
-
noSuchMethod(Invocation invocation)
→ dynamic
-
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners()
→ void
-
Call all the registered listeners.
inherited
-
onDispose()
→ Future<Null>
-
Callback to allow arbitrary cleanup on dispose.
-
onWillDispose()
→ Future<Null>
-
Callback to allow arbitrary cleanup as soon as disposal is requested (i.e.
dispose
is called) but prior to disposal actually starting.
inherited
-
open({required BuildContext context, Widget? startWidget})
→ Future<void>
-
Opens the modal with the provided
startState
.
If none is provided, the default state will be used based on platform.
override
-
rebuildConnectionUri()
→ Future<void>
-
Rebuilds the connection URI.
If the dapp attempts to connect to a wallet, and the connection proposal is consumed,
but not accepted or rejected (no response), and they navigate back to the dapp and try again
then no connection proposal will be sent. This is because the connection proposal is already consumed.
So, every time they tap on a button to connect to a wallet, we need to rebuild the connection URI to
ensure that each time they tap on a wallet, a new connection proposal is sent.
override
-
removeListener(VoidCallback listener)
→ void
-
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
setDefaultChain({required Map<String, RequiredNamespace> requiredNamespaces})
→ void
-
Sets the required namespaces that will be used when connecting to the wallet
The default is set to the NamespaceConstants.ethereum namespace.
override
-
toString()
→ String
-
A string representation of this object.
inherited