accountDisplayName static method

Widget accountDisplayName(
  1. String? address,
  2. Map? accInfo, {
  3. bool expand = true,
  4. MainAxisAlignment mainAxisAlignment = MainAxisAlignment.start,
})

Implementation

static Widget accountDisplayName(
  String? address,
  Map? accInfo, {
  bool expand = true,
  MainAxisAlignment mainAxisAlignment = MainAxisAlignment.start,
}) {
  bool hasId = false;
  bool good = false;
  if (accInfo != null) {
    if (accInfo['identity']['display'] != null) {
      hasId = true;
    }
    if (accInfo['identity']['judgements'].length > 0) {
      final judgement = accInfo['identity']['judgements'][0][1];
      if (Map.of(judgement).keys.contains('knownGood') ||
          Map.of(judgement).keys.contains('reasonable')) {
        good = true;
      }
    }
  }
  return Row(
    mainAxisAlignment: mainAxisAlignment,
    children: <Widget>[
      hasId
          ? Container(
              width: 14,
              margin: EdgeInsets.only(right: 4),
              child: good
                  ? Icon(
                      Icons.check_circle,
                      size: 16,
                      color: Colors.lightGreen,
                    )
                  : Icon(
                      Icons.remove_circle,
                      size: 16,
                      color: Colors.black12,
                    ),
            )
          : Container(width: 1, height: 2),
      expand
          ? Expanded(
              child: Text(accountDisplayNameString(address, accInfo)!,
                  overflow: TextOverflow.ellipsis),
            )
          : Text(accountDisplayNameString(address, accInfo)!,
              overflow: TextOverflow.ellipsis)
    ],
  );
}