Moez Zineb
Moez Zineb

Reputation: 15

Error running my flutter project : Scaffold.maybeOf(context)?

Running Gradle task 'assembleDebug'... AppData/Local/Pub/Cache/git/getflutter-a714b9b006b2208c983b8ecbeb21302f8ccacc13/lib/components/appbar/gf_appbar.dart:312:45: Error: Method not found: 'Scaffold.maybeOf'. Running Gradle task 'assembleDebug'...
final ScaffoldState scaffold = Scaffold.maybeOf(context); Running Gradle task 'assembleDebug'... ^^^^^^^ Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception. Running Gradle task 'assembleDebug'...

Upvotes: 0

Views: 2018

Answers (1)

tnc1997
tnc1997

Reputation: 1962

At the time of writing this answer, the maybeOf method is not available in the stable channel of Flutter. If you would like to use the maybeOf method then you should adjust your Flutter channel accordingly. Alternatively, you could use the of method with nullOk: true.

It looks like you might have a dependency on an unpublished package (getflutter). This dependency is pulling in a version of the getflutter package that uses the new maybeOf method, however you are on the stable channel of Flutter which does not have this method. You could resolve this issue by replacing the version of the package with a published version:

dependencies:
  getwidget: ^1.2.4

Upvotes: 0

Related Questions