Flutter: Method not found: ButtonTheme.bar

Issue

I was working on this project for past 4-5 months and after the flutter 2.0 update it started producing plugin version conflicts between flutter_form_builder and intl.

After downgrading flutter_form_builder to 3.14.1 I had this error related to date_range_picker,

../../.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( 

After fixing it with overriding dependency using this code

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

I got this error

../../.pub-cache/hosted/pub.dartlang.org/country_pickers-1.3.0/lib/utils/my_alert_dialog.dart:139:36: Error: Method not found: 'ButtonTheme.bar'.
      children.add(new ButtonTheme.bar(                                 
                                   ^^^     

Note: I’m not using any of these plugins i.e, date_range_picker or country_pickers

Solution

After messing around with this weird error, I found a solution.

Error caused by country_pickers

I didn’t use country_pickers in my project and what caused this error was the usage of country_pickers version 1.3.0 by one of the package I was using, which threw this exception,

../../.pub-cache/hosted/pub.dartlang.org/country_pickers-1.3.0/lib/utils/my_alert_dialog.dart:139:36: Error: Method not found: 'ButtonTheme.bar'.
      children.add(new ButtonTheme.bar(                                 
                                   ^^^ 

All I needed to do was to override my project’s dependency on country_pickers to version 2.0.0

dependency_overrides:
  country_pickers: ^2.0.0

Error caused by date_range_picker

If you face the following error,

../../.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( 

Override date_range_picker dependency,

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

P.S: You might get these errors even if you are not using any of these packages, because some package you are using might depend on any of these.

Answered By – ASAD HAMEED

Answer Checked By – Candace Johnson (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *