showSnackBar method

void showSnackBar(
  1. BuildContext context
)

Implementation

void showSnackBar(BuildContext context) {
  final snackBar = SnackBar(
    content: Row(
      children: const [
        Icon(Icons.wifi_off_sharp, color: Colors.white),
        SizedBox(width: 20),
        Text('No Internet'),
      ],
    ),
    backgroundColor: Colors.black,
    behavior: SnackBarBehavior.fixed,
    dismissDirection: DismissDirection.none,
    duration: const Duration(days: 1),
    action: SnackBarAction(
      label: 'Try Again',
      disabledTextColor: Colors.white,
      textColor: Colors.white,
      onPressed: () {
        isInternetBack(
          internetStatus: (value) {
            if (value) {
              ScaffoldMessenger.of(context).removeCurrentSnackBar();
            } else {
              showSnackBar(context);
            }
          },
        );
      },
    ),
  );
  ScaffoldMessenger.of(context).showSnackBar(snackBar);
}