codegrue / card_settings

A flutter package for building card based forms.
https://pub.dartlang.org/packages/card_settings
MIT License
555 stars 103 forks source link

error: Undefined name 'ScaffoldMessenger'. (undefined_identifier at [flutter_form] lib/plumbing/scaffold.dart:66) #161

Closed NTMS2017 closed 3 years ago

NTMS2017 commented 3 years ago

I created a empty flutter project and replace your example data and I am getting error on:

error: Undefined name 'ScaffoldMessenger'. (undefined_identifier at [flutter_form] lib/plumbing/scaffold.dart:66)

But couldn't find anything related to ScaffoldMessenger in your code. Please help.

codegrue commented 3 years ago

ScaffoldMessenger is in the code that displays the toast when a value changes. You can probably delete any references to that and your code should work.

  void showSnackBar(String label, dynamic value) {
    ScaffoldMessenger.of(context).removeCurrentSnackBar();
    ScaffoldMessenger.of(context).showSnackBar(
      SnackBar(
        duration: Duration(seconds: 1),
        content: Text(label + ' = ' + value.toString()),
      ),
    );
  }