flutter_fuels_beta3 0.0.5+1 copy "flutter_fuels_beta3: ^0.0.5+1" to clipboard
flutter_fuels_beta3: ^0.0.5+1 copied to clipboard

Flutter Plugin for Fuel SDK beta-3

example/lib/main.dart

import 'dart:async';

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

const _betaApiUrl = 'https://beta-3.fuel.network';

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

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  static const _defaultWalletAddressTitle = 'not generated yet';

  String _bech32Address = _defaultWalletAddressTitle;
  String _b256Address = _defaultWalletAddressTitle;
  String _signedMessage = 'message is not signed yet';

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

  @override
  Widget build(BuildContext context) {
    const textStyle = TextStyle(fontSize: 25);

    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Fuel SDK'),
        ),
        body: SingleChildScrollView(
          child: Container(
            padding: const EdgeInsets.all(16),
            alignment: Alignment.center,
            child: Column(
              children: [
                Text(
                  'bech32: $_bech32Address',
                  style: textStyle,
                  textAlign: TextAlign.center,
                ),
                const SizedBox(height: 8),
                Text(
                  'b256: $_b256Address',
                  style: textStyle,
                  textAlign: TextAlign.center,
                ),
                const SizedBox(height: 8),
                Text(
                  'signed message: "$_signedMessage"',
                  style: textStyle,
                  textAlign: TextAlign.center,
                ),
                const SizedBox(height: 8),
                OutlinedButton(
                  onPressed: _generateWallet,
                  child: const Text('Generate address'),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }

  Future<void> _generateWallet() async {
    final wallet = await FuelWallet.generateNewWallet(networkUrl: _betaApiUrl);
    // test utils
    final b256 = await FuelUtils.b256FromBech32String(wallet.bech32Address);
    final signedMessage = await wallet.signMessage(message: 'message');
    setState(() {
      _bech32Address = wallet.bech32Address;
      _b256Address = b256;
      _signedMessage = signedMessage;
    });
  }
}
1
likes
120
points
47
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter Plugin for Fuel SDK beta-3

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

AGPL-3.0 (license)

Dependencies

flutter, flutter_web_plugins, fuels_beta3, js, plugin_platform_interface

More

Packages that depend on flutter_fuels_beta3