getBlockByNumber method Null safety

Future<EtherScanBlockByNumberModel> getBlockByNumber (
  1. {required String? tag}
)

Returns information about a block by block number.

tag - Tag to look up

Example

var blockNumber = eth.getBlockByNumber(tag: '0x10d4f');

Implementation

Future<EtherScanBlockByNumberModel> getBlockByNumber({
  required String? tag,
}) async {
  const module = 'proxy';
  const action = 'eth_getBlockByNumber';
  const boolean = true;

  Map<String, dynamic>? query = {
    'tag': tag,
    'module': module,
    'action': action,
    'boolean': boolean,
    'apiKey': apiKey,
  };

  return (await get(query)).fold(
    (l) => EtherScanBlockByNumberModel.empty(),
    (r) => EtherScanBlockByNumberModel.fromJson(r),
  );
}