buildHttpFuture method

Widget buildHttpFuture(
  1. BuildContext _,
  2. AsyncSnapshot<Response> snapshot
)

Function for FutureBuilder

Implementation

// ignore:long-method
Widget buildHttpFuture(
  BuildContext _,
  AsyncSnapshot<http.Response> snapshot,
) {
  final List<Widget> children;

  if (snapshot.hasData) {
    children = <Widget>[
      // FractionallySizedBox(
      //   widthFactor: 1,
      //   child:
      Card(
        child: Column(
          children: [
            const Icon(
              Icons.check_circle_outline,
              color: Colors.green,
              size: 20,
            ),
            Padding(
              padding: const EdgeInsets.only(top: 16),
              child: Html(
                data: snapshot.data?.body,
                shrinkWrap: true,
              ),
            ),
          ],
        ),
        // ),
      ),
    ];
  } else if (snapshot.hasError) {
    children = <Widget>[
      Card(
        child: Column(
          children: [
            const Icon(
              Icons.error_outline,
              color: Colors.red,
              size: 20,
            ),
            Padding(
              padding: const EdgeInsets.only(top: 16),
              child: Text('Error: ${snapshot.error}'),
            ),
          ],
        ),
      ),
    ];
  } else if (snapshot.connectionState == ConnectionState.none) {
    children = [];
  } else {
    children = <Widget>[
      const SizedBox(
        width: 20,
        height: 20,
        child: CircularProgressIndicator(),
      ),
      Padding(
        padding: const EdgeInsets.only(top: 16),
        child: Text(tr().awaitResults),
      ),
    ];
  }

  return Center(
    child: Column(
      children: children,
    ),
  );
}