cacheTextBuilder static method

Widget cacheTextBuilder({
  1. required TextStyle textStyle,
  2. required dynamic cacheKey,
})

Implementation

static Widget cacheTextBuilder(
    {required TextStyle textStyle, required dynamic cacheKey}) {
  return FutureBuilder(
    future: ReadCache.getString(key: cacheKey),
    builder: (context, snaphot) {
      if (snaphot.connectionState == ConnectionState.waiting) {
        return Center(
            child: SizedBox(
                height: 10, width: 10, child: CircularProgressIndicator()));
      }
      if (snaphot.hasData) {
        return Text(snaphot.data.toString(), style: textStyle);
      }
      return Text("Invalid cache", style: textStyle);
    },
  );
}