toTappableTextAsync method

Widget toTappableTextAsync(
  1. Future<void> onTap(), [
  2. Size? detectionBorder
])

Implementation

Widget toTappableTextAsync(
  Future<void> Function() onTap, [
  Size? detectionBorder,
]) {
  var isLoading = false;
  return WStatefulBuilder(
    builder: (_, final state) {
      return WTapDetector(
        detectionBorder: detectionBorder ?? Size.square(16.sc),
        onTap: isLoading
            ? null
            : () async {
                state.refresh(() {
                  isLoading = true;
                });
                await onTap();
                state.refresh(() {
                  isLoading = false;
                });
              },
        child: Row(
          mainAxisSize: MainAxisSize.min,
          children: [
            this,
            if (isLoading)
              Text(
                '...',
                style: this.style,
              ),
          ],
        ),
      );
    },
  );
}