简体   繁体   中英

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'...

  • Where: Script 'C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 904 Running Gradle task 'assembleDebug'...
  • What went wrong: Execution failed for task ':app:compileFlutterBuildDebug'. Running Gradle task > Process 'command 'C:\flutter\bin\flutter.bat'' finished with non-zero exit value 1 Running Gradle task 'assembleDebug'...
  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

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 theof 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM