[Solved] Error: Undefined name ’SnackDismissDirection’ in Flutter

In this post, we are going to show you how to solve Error: Undefined name 'SnackDismissDirection' error in Flutter. This error occurs due to "SnackDismissDirection". See the solution below to solve this error:

Error: Undefined name 'SnackDismissDirection'.
    dismissDirection: SnackDismissDirection.HORIZONTAL,

This error occurs when you have recently upgraded the Flutter SKD and pub. To solve this error, see the solution below:

To solve this error, replace 'Error: Undefined name 'SnackDismissDirection' with 'DismissDirection' on your dart code:

Replace:

SnackDismissDirection

With 

DismissDirection.

For example:

GetSnackBar(
  backgroundColor: Colors.green,
  message: 'message',
  snackStyle: SnackStyle.FLOATING,
  borderRadius: 10,
  isDismissible: true,
  dismissDirection: SnackDismissDirection.horizontal,
)

Update this code like below:

GetSnackBar( //if you are useing GetBar(), update it to GetSnackBar()
  backgroundColor: Colors.green,
  message: 'message',
  snackStyle: SnackStyle.FLOATING,
  borderRadius: 10,
  isDismissible: true,
  dismissDirection: DismissDirection.horizontal,
)

Now, run your app. The code must be solved.

In this way, you can solve Error: Undefined name 'SnackDismissDirection' error in Flutter.

No any Comments on this Article


Please Wait...