showSnackBar method

void showSnackBar(
  1. BuildContext context
)

Implementation

void showSnackBar(BuildContext context) {
  final snackBar = SnackBar(
    content: Row(
      children: [
        Icon(
          Icons.wifi_off_sharp,
          color: Colors.white,
        ),
        SizedBox(
          width: 20,
        ),
        if (customNoInternetText == null) ...[
          Text('No Internet'),
        ] else ...[
          customNoInternetText ?? Text('No Internet'),
        ]
      ],
    ),
    backgroundColor: Colors.black,
    behavior: SnackBarBehavior.fixed,
    dismissDirection: DismissDirection.none,
    duration: 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);
}