flutter_web3 2.0.0-pre.3 copy "flutter_web3: ^2.0.0-pre.3" to clipboard
flutter_web3: ^2.0.0-pre.3 copied to clipboard

outdated

Web3 Ethereum, Etherjs and Wallet Connect wrapper for Flutter Web. Made especially for developing Dapp.

example/main.dart

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

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Ethereum Demo',
      home: Home(),
    );
  }
}

class Home extends StatefulWidget {
  @override
  _HomeState createState() => _HomeState();
}

class _HomeState extends State<Home> {
  String address = '';
  bool get isConnected => ethereum != null && ethereum!.isConnected();

  connect() async {
    if (ethereum != null) address = (await ethereum!.requestAccount()).first;
    setState(() {});
  }

  @override
  void initState() {
    if (ethereum != null) {
      ethereum!.onAccountsChanged((accounts) {
        if (accounts.isNotEmpty)
          address = accounts.first;
        else
          address = '';
        setState(() {});
      });
    }
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          children: [
            Text(
                'you are currently ${isConnected ? 'connected' : 'not connected'}'),
            Text('your address is ${address.isNotEmpty ? address : 'xxx'}'),
          ],
        ),
      ),
    );
  }
}
147
likes
0
pub points
90%
popularity

Publisher

unverified uploader

Web3 Ethereum, Etherjs and Wallet Connect wrapper for Flutter Web. Made especially for developing Dapp.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, js, meta

More

Packages that depend on flutter_web3