near_wallet_connect 0.1.0 copy "near_wallet_connect: ^0.1.0" to clipboard
near_wallet_connect: ^0.1.0 copied to clipboard

Drop-in NEAR wallet connection for Flutter — adaptive connect (web redirect, mobile deep links), persistent key storage, and a NearConnectButton widget.

near_wallet_connect #

License: MIT

Drop-in NEAR wallet connection for Flutter — adaptive connect (web redirect, mobile deep links), persistent key storage, and a ready-made NearConnectButton. Built on near_dart.

Connecting provisions a function-call key and stores it, so afterward you sign contract calls locally — no more redirects.

Add it #

dependencies:
  near_wallet_connect: ^0.1.0

Use it (this is the whole integration) #

import 'package:near_wallet_connect/near_wallet_connect.dart';

final wallet = NearWalletController(
  network: MyNearWalletNetwork.testnet,
  contractId: AccountId('app.testnet'),
  callbackScheme: 'nearsdk', // your mobile deep-link scheme
);

@override
void initState() {
  super.initState();
  wallet.init(); // restores the session + processes the redirect callback
}

// In your build():
NearConnectButton(controller: wallet);

// After connect, sign locally — no redirect:
final signer = await wallet.signer();
await signer!.callFunction(
  contractId: AccountId('app.testnet'),
  methodName: 'add_message',
  args: {'text': 'hello'},
);

That's it. See example/ for a complete minimal app.

Platform setup (one-time) #

The mobile callback uses a custom URL scheme (default nearsdk://). Register it:

Androidandroid/app/src/main/AndroidManifest.xml, inside <activity>:

<intent-filter android:autoVerify="false">
  <action android:name="android.intent.action.VIEW"/>
  <category android:name="android.intent.category.DEFAULT"/>
  <category android:name="android.intent.category.BROWSABLE"/>
  <data android:scheme="nearsdk"/>
</intent-filter>

iOSios/Runner/Info.plist:

<key>CFBundleURLTypes</key>
<array>
  <dict>
    <key>CFBundleURLSchemes</key>
    <array><string>nearsdk</string></array>
  </dict>
</array>

Web — no setup; the callback returns to your app URL.

How it works #

  • Web: connect() does a full-page redirect to MyNearWallet; on return init() reads the callback from the app URL.
  • Mobile/desktop: launches the system browser; the callback arrives via the deep-link scheme (app_links).
  • Keys persist via SharedPrefsKeyStore (swap in your own encrypted KeyStore for production mobile).

MyNearWallet is the supported wallet today. Its redirect pattern carries to successor wallets; adapters for more wallets are planned.

License #

MIT

0
likes
150
points
2
downloads

Documentation

API reference

Publisher

verified publisher0xj.dev

Weekly Downloads

Drop-in NEAR wallet connection for Flutter — adaptive connect (web redirect, mobile deep links), persistent key storage, and a NearConnectButton widget.

Homepage
Repository (GitHub)
View/report issues

Topics

#near #wallet #flutter #web3 #blockchain

License

MIT (license)

Dependencies

app_links, flutter, near_dart, shared_preferences, url_launcher

More

Packages that depend on near_wallet_connect