Skip to content

Latest commit

 

History

History
77 lines (62 loc) · 1.82 KB

README.md

File metadata and controls

77 lines (62 loc) · 1.82 KB

Examples

The library is built on 4 layers so the examples are stored in their subfolder:

To give a brief idea of the differences, for example in generating a new wallet:

  • Stateless

    final networkInfo = NetworkInfo(
      bech32Hrp: 'did:com:',
      lcdUrl: 'http://localhost:1317',
    );
    
    final wallet = await StatelessCommercioAccount.generateNewWallet(
      networkInfo: networkInfo);
  • Stateful

    final commercioAccount = StatefulCommercioAccount();
    
    await commercioAccount.generateNewWallet();
  • BLoC

    BlocProvider<CommercioAccountBloc>(
      create: (_) =>
        CommercioAccountBloc(commercioAccount: StatefulCommercioAccount()),
          child: BlocBuilder<CommercioAccountBloc, CommercioAccountState>(
            builder: (_, state) {
              if (state is CommercioAccountInitial) {
                // ...
              }
    
              if (state is CommercioAccountLoadingGenerateWallet) {
                // ...
              }
    
              if (state is CommercioAccountGeneratedWithWallet) {
                // ...
              }
            },
          ),
    )
  • Widgets

    BlocProvider<CommercioAccountBloc>(
      create: (_) =>
        CommercioAccountBloc(commercioAccount: StatefulCommercioAccount()),
      child: Column(
        children: [
          GenerateWalletFlatButton(
              child: () => const Text('Generate new wallet'),
              loadingChild: () => const Text('Generating...'),
            ),
            GenerateWalletCommercioAccountTextField(
              loadingTextCallback: () => 'Generating...',
              textCallback: (state) => state.commercioAccount.walletAddress,
            ),
        ],
      ),
    )