apihandler 0.1.3 copy "apihandler: ^0.1.3" to clipboard
apihandler: ^0.1.3 copied to clipboard

outdated

Dart library to connect to Ethereum clients. Send transactions and interact with smart contracts!

example/lib/main.dart

import 'package:apihandler/apiHandler.dart';
import 'package:apihandler/web3dart.dart';
import 'package:flutter/material.dart';
import 'dart:async';

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  int _counter = 0;

  @override
  void initState() {
    super.initState();
   // testingModelData();
  }


  void _incrementCounter() {
    checkNetwork();
    web3dart.getOwnerAddress();
    web3dart.setUpPrivateKey(privateKey:'d1bdc683fbeb9fa0b4ceb26adb39eaffb21b16891ea28e4cf1bc3118fdd39295');
    Future.delayed(Duration(milliseconds: 1000), () {
    //  web3dart.sendETHTransaction(amount: EtherAmount.fromUnitAndValue(EtherUnit.finney, 1),toAddress:'0xA3B4dE5E90A18512BD82c1A640AC99b39ef2258A');
      web3dart.getETHClientDetail();
    });
    Future.delayed(Duration(milliseconds: 4000), () {
      web3dart.getAddressDetail();
      web3dart.sendERC20Transaction(contractAddress: '0x7e0480ca9fd50eb7a3855cf53c347a1b4d6a2ff5',amount: BigInt.from(1000000000000000000),toAddress:'0xA3B4dE5E90A18512BD82c1A640AC99b39ef2258A');
    });
    setState(() {
      _counter++;
    });
  }

  void checkNetwork() async{
    //checkConnectivity
    ConnectivityResult connectivityResult = await (Connectivity().checkConnectivity());
    print("start connectivityResult:$connectivityResult");

    // onConnectivityChanged
    apiHandler.onConnectivityChanged.listen((ConnectivityResult result) {
      print("ConnectivityResult:$result");
    });
  }

  // void callApi() async{
  //   String phoneCode = "86";
  //   String phone = "12345673";
  //   String smsCode = "000000";
  //   await apiCaller.updateDevice(phoneCode: phoneCode,phone: phone,code: smsCode,email: "");
  //   await apiCaller.signIn(phoneCode: phoneCode,phone: phone,code: smsCode);
  // }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child:  Text(
            '$_counter',
            style: Theme.of(context).textTheme.headline4,
          ),
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: _incrementCounter,
          tooltip: 'Increment',
          child: Icon(Icons.add),
        ), // This trail
      ),
    );
  }
}
1
likes
0
pub points
1%
popularity

Publisher

unverified uploader

Dart library to connect to Ethereum clients. Send transactions and interact with smart contracts!

Homepage

License

unknown (LICENSE)

Dependencies

connectivity, dio, flutter, http, web3dart

More

Packages that depend on apihandler