Error: Method not found: 'ButtonTheme.bar'

Viewed 6577

I have flutter application under development. When running the app , an error occurs Method not found: 'ButtonTheme.bar'. I tried cleaning the project. but still same error persists

/C:/Users/RdpUser/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/date_range_picker-1.0.6/lib/date_range_picker.dart:1152:44: Error: Method not found: 'ButtonTheme.bar'.
    final Widget actions = new ButtonTheme.bar(
                                           ^^^
Failed to compile application.
4 Answers

Click on the error link to go in my_alert_dialog.dart and change ButtonTheme.bar to ButtonBarTheme like this :

enter image description here

change to :

enter image description here

It's works !

The temporary solution @pepe-calero referred would look like this:

Add the following section in your pubspec.yaml

dependency_overrides:
  date_range_picker:
    git:
      url: https://github.com/LempereurBenjamin/date_range_picker

I just updated flutter and I also keep getting this error. I agree with @PatelFab, ButtonTheme.bar is deprecated. If you are using ButtonTheme.bar "directly" in your code, just change it to ButtonBarTheme.

Another solution would be to use the flutter showDateRangePicker function.

I have the problem of not using ButtonTheme.bar "directly", but another package I depend on uses it: flutter_form_builder. In case you use flutter_form_builder, the issue has already been posted in github and I bet they're working on it.

I'll update when it's solved.

Related