Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Method not found: 'ButtonTheme.bar'

Tags:

flutter

dart

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.
like image 693
Android_id Avatar asked Feb 03 '21 12:02

Android_id


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 !

like image 90
AkMax Avatar answered Oct 18 '22 00:10

AkMax


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
like image 34
Seb Avatar answered Oct 18 '22 01:10

Seb


Use this,

Deprecated. Please use ButtonBarTheme instead which offers more flexibility to configure ButtonBar widgets.

This feature was deprecated after v1.9.1.

Because ButtonTheme.bar is deprecated.

For reference, https://api.flutter.dev/flutter/material/ButtonTheme/ButtonTheme.bar.html

like image 3
Ronak Patel Avatar answered Oct 18 '22 00:10

Ronak Patel


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.

like image 2
pepe calero Avatar answered Oct 18 '22 01:10

pepe calero