public_address_wallet 0.0.6 copy "public_address_wallet: ^0.0.6" to clipboard
public_address_wallet: ^0.0.6 copied to clipboard

A package to get verified public address from wallet using WalletConnect protocol v1.

example/example.md

example #

import 'package:flutter/material.dart';
import 'package:public_address_wallet/public_address_wallet.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  String publicAddress = "";

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            if (publicAddress.isNotEmpty) ...{
              const Text("Public address in wallet:"),
              Text(
                publicAddress,
                style: const TextStyle(fontWeight: FontWeight.bold),
              )
            },
            TextButton(
                onPressed: () => startConnect(Wallet.metamask),
                child: const Text('Start Connect Metamask')),
            TextButton(
                onPressed: () => startConnect(Wallet.trustWallet),
                child: const Text('Start Connect Trust Wallet')),
            TextButton(
                onPressed: () => startConnect(Wallet.rainbowMe),
                child: const Text('Start Connect Rainbow'))
          ],
        ),
      ),
    );
  }

  startConnect(Wallet wallet) async {
    final connector = WalletConnector(
        AppInfo(name: "Mobile App", url: "https://example.mobile.com"));
    setState(() {
      publicAddress = '';
    });
    var address =
        await connector.publicAddress(wallet: wallet).catchError((onError) {
      print(onError);
      throw onError;
    });
    print(address);
    // in case you want open wallet by your self
    // connector.initSession((uri) {
    //   print(uri);
    // });
    setState(() {
      publicAddress = address;
    });
  }
}

4
likes
120
pub points
24%
popularity

Publisher

unverified uploader

A package to get verified public address from wallet using WalletConnect protocol v1.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

convert, cryptography, flutter, json_annotation, stack_trace, url_launcher, uuid, web_socket_channel

More

Packages that depend on public_address_wallet