Map data = {
      'acc_name': 'guru',
    };

    List<eos.Action> actions = [
      eos.Action()
        ..account = 'guru11111111'
        ..name = 'getborrower'
        ..authorization = auth
        ..data = data
    ];

    eos.Transaction transaction = eos.Transaction()..actions = actions;
    _eosClient.pushTransaction(transaction, broadcast: true).then((trx) {
      print(trx);

my data is in trx variable and it's coming this way in my flutter console

I/flutter ( 8554): {transaction_id: ed53dd56e76a313ad95fda218bb5061e995844e46f7d8ad613e944bc26cb297d, processed: {id: ed53dd56e76a313ad95fda218bb5061e995844e46f7d8ad613e944bc26cb297d, block_num: 51263066, block_time: 2019-09-24T06:29:57.000, producer_block_id: null, receipt: {status: executed, cpu_usage_us: 173, net_usage_words: 13}, elapsed: 173, net_usage: 104, scheduled: false, action_traces: [{action_ordinal: 1, creator_action_ordinal: 0, closest_unnotified_ancestor_action_ordinal: 0, receipt: {receiver: guru11111111, act_digest: 55e9b8f98bde721c3f3e53cf98a20814a5d426290b0bf55f842d97866bc71f6c, global_sequence: 488200462, recv_sequence: 216, auth_sequence: [[guru11111111, 286]], code_sequence: 25, abi_sequence: 14}, receiver: guru11111111, act: {account: guru11111111, name: getborrower, authorization: [{actor: guru11111111, permission: active}], data: {acc_name: guru}, hex_data: 0000000000a0af66}, context_free: false, elapsed: 51, console: Borrower Name: guru ID: 1 Location: varanasi Phone Number: 8563070443

**I have tried to serialise a bit to the above data **

**what i want to print is below in short and after this you will get to look at full data **

processed{

                                action_traces
                                            [
                                                {
                                                    console: 
                                                    Borrower Name: guru
                                                    ID: 1
                                                    Location: varanasi
                                                    Phone Number: 8563070443, 
                                                    Loan Amount:465200 
                                                }
                                            ]
                             }
processed: {
        id: c459d2da5100afb1b4ab0352debfa4736aadd8c2e36529fe0861c9c8cadddeae, 
        block_num: 51299894, 
        block_time: 2019-09-24T11:40:11.500, 
        producer_block_id: null, 
        receipt: {
            status: executed, 
            cpu_usage_us: 226, 
            net_usage_words: 13
        }, 
        elapsed: 226, 
        net_usage: 104, 
        scheduled: false, 
        action_traces: [
                        {
                            action_ordinal: 1, 
                            creator_action_ordinal: 0, 
                            closest_unnotified_ancestor_action_ordinal: 0, 
                            receipt: {
                                        receiver: guru11111111, 
                                        act_digest: 55e9b8f98bde721c3f3e53cf98a20814a5d426290b0bf55f842d97866bc71f6c, 
                                        global_sequence: 488304782, 
                                        recv_sequence: 329, 
                                        auth_sequence: [
                                            [guru11111111, 399]
                                        ], 
                                        code_sequence: 25, 
                                        abi_sequence: 14
                                        }, 
                            receiver: guru11111111, 
                            act: {
                                    account: guru11111111, 
                                    name: getborrower, 
                                    authorization: [
                                                        {
                                                            actor: guru11111111, 
                                                            permission: active
                                                        }
                                                    ], 
                                    data: 
                                        {
                                            acc_name: guru
                                        }, 
                                    hex_data: 0000000000a0af66
                                }, 
                            context_free: false, 
                            elapsed: 60, 
                            console: 
                            Borrower Name: guru
                            ID: 1
                            Location: varanasi
                            Phone Number: 8563070443, 
                            Loan Amount:465200 
                        }

I want to view the bold data on my screen please help me I have tried this way and its not working



import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:eosdart/eosdart.dart' as eos;

SharedPreferences sharedPreferences;
getCredential() async {
  sharedPreferences = await SharedPreferences.getInstance();
}

void main() => runApp(GetBorrower());

class GetBorrower extends StatefulWidget {
  @override
  _GetBorrowerState createState() => _GetBorrowerState();
}

class _GetBorrowerState extends State<GetBorrower> {
  eos.Account _account;
  eos.EOSClient _eosClient = eos.EOSClient(
      'http://jungle2.cryptolions.io:80', 'v1',
      privateKeys: ["5JfVW2PtRkAcLbLETevxCwaQuT8NNWvP2eBYCrPRKPBWDgZDEo1"]);

  Map fetch = new Map();
//  List fetch;
  void _fetchborrower() {
    List<eos.Authorization> auth = [
      eos.Authorization()
        ..actor = 'guru11111111'
        ..permission = 'active'
    ];
//
    Map data = {
      'acc_name': 'guru',
    };

    List<eos.Action> actions = [
      eos.Action()
        ..account = 'guru11111111'
        ..name = 'getborrower'
        ..authorization = auth
        ..data = data
    ];
    setState(() {
      eos.Transaction transaction = eos.Transaction()..actions = actions;
      _eosClient.pushTransaction(transaction, broadcast: true).then((trx) {
        print(trx);
        fetch = trx;
      });

      print('hiiiii');
    });

//      fetch = json.decode(trx).toString() as Map;
//      print('Loaded ${fetch.length}');
  }

  fetchdata() {
    return Expanded(
      flex: 4,
      child: new ListView.builder(
          itemCount: fetch.length,
          itemBuilder: (BuildContext context, int index) {
            String key = fetch.keys.elementAt(index);
            return Column(
              children: <Widget>[
//                          Text('$key'),
                Text('${fetch[key]}'),
              ],
            );
          }),
    );
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        backgroundColor: Colors.teal,
        body: SafeArea(
          child: Column(
            children: <Widget>[
              Text('hi'),
              FlatButton(
                color: Colors.white,
                child: Text('get borrower'),
                onPressed: () {
                  _fetchborrower();
                },
              ),
              Flexible(
                child: new ListView.builder(
                    itemCount: fetch.length,
                    itemBuilder: (BuildContext context, int index) {
                      String key = fetch.keys.elementAt(index);
                      return Column(
                        children: <Widget>[
//                          Text('$key'),
                          Text('${fetch[key]}'),
                        ],
                      );
                    }),
              ),
            ],
          ),
        ),
      ),
    );
  }

what else i can do or what i'm doing wrong please help actually my data is coming in the fetch but its not getting render at that time when i'm pressing ctrl+s and my widget get refresh its showing the data on screen then how can i improve this ?


Solution 1: George Herbert

I would move the setState inside the then on your future.

  eos.Transaction transaction = eos.Transaction()..actions = actions;
  _eosClient.pushTransaction(transaction, broadcast: true).then((trx) {
      print(trx);
      setState(() {
        fetch = trx;
      });

      print('hiiiii');
  });