3

/C:/FlutterSdk/flutter/.pub-cache/hosted/pub.dartlang.org/fl_chart-0.50.5/lib/src/chart/pie_chart/pie_chart.dart:42:29: Error: Method 'addPostFrameCallback' cannot be called on 'WidgetsBinding?' because it is potentially null.

  • 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('/C:/FlutterSdk/flutter/packages/flutter/lib/src/widgets/binding.dart'). Try calling using ?. instead. WidgetsBinding.instance.addPostFrameCallback((_) { ^^^^^^^^^^^^^^^^^^^^

FAILURE: Build failed with an exception.

  • Where: Script 'C:\FlutterSdk\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1102

  • What went wrong: Execution failed for task ':app:compileFlutterBuildDebug'.

Process 'command 'C:\FlutterSdk\flutter\bin\flutter.bat'' finished with non-zero exit value 1

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

  • Get more help at https://help.gradle.org

BUILD FAILED in 33s Running Gradle task 'assembleDebug'... 38.2s Exception: Gradle task assembleDebug failed with exit code 1

0

5 Answers 5

4

use flutter pub cache repair command

because flutter stores the data in its own storage, and if it gets full, it will throw an error

Sign up to request clarification or add additional context in comments.

Comments

1

lib provider had breaking changes when migrating to flutter 3 but didn't bump the major version, you can try locking the version in pubspec.yml or migrate to flutter 3 as well...

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
1

There is one another similar error which indicates syntax error inside dart code. Full error text is like below:

What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command '/users/elmar/flutter/bin/flutter'' finished with non-zero exit value 1

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

* Get more help at https://help.gradle.org

BUILD FAILED in 16s
Running Gradle task 'assembleDebug'...                             17.3s
Exception: Gradle task assembleDebug failed with exit code 1

You need to find and correct sytax error and app wil run without any error after that.

Comments

1

don't forget to flutter pub get, I successfully used this method

Comments

1

Delete this import of your code : import 'dart:js_util. That's all

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.