Whenever I try to run flutter app, I am getting this error.
../flutter/.pub-cache/hosted/pub.dartlang.org/percent_indicator-4.2.1/lib/linear_percent_indicator.dart:162:5: Warning: The class 'WidgetsBinding' cannot be null.
Try replacing '?.' with '.'
WidgetsBinding?.instance.addPostFrameCallback((_) {
^^^^^^^^^^^^^^
../flutter/.pub-cache/hosted/pub.dartlang.org/percent_indicator-4.2.1/lib/linear_percent_indicator.dart:162:30: Error: Method 'addPostFrameCallback' cannot be called on 'WidgetsBinding?' because it is potentially null.
- 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../flutter/packages/flutter/lib/src/widgets/binding.dart').
Try calling using ?. instead.
WidgetsBinding?.instance.addPostFrameCallback((_) {
^^^^^^^^^^^^^^^^^^^^
FAILURE: Build failed with an exception.
* Where:
Script '/home/user/Downloads/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1102
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command '/home/user/Downloads/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 22s
Running Gradle task 'assembleDebug'... 22.8s
Exception: Gradle task assembleDebug failed with exit code 1
Here, is my Flutter doctor output
[✓] Flutter (Channel stable, 2.10.3, on Ubuntu 20.04.4 LTS 5.13.0-41-generic, locale en_IN)
• Flutter version 2.10.3 at /home/user/Downloads/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 7e9793dee1 (3 months ago), 2022-03-02 11:23:12 -0600
• Engine revision bd539267b4
• Dart version 2.16.1
• DevTools version 2.9.2
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
• Android SDK at /home/user/Android/Sdk
• Platform android-32, build-tools 32.1.0-rc1
• Java binary at: /opt/android-studio-2021.1.1/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.11 0-b60-7590822)
• All Android licenses accepted.
[✓] Chrome - develop for the web
• Chrome at google-chrome
[✓] Android Studio (version 2021.1)
• Android Studio at /opt/android-studio-2021.1.1/android-studio
• Flutter plugin version 66.0.1
• Dart plugin version 211.7811
• Java version OpenJDK Runtime Environment (build 11.0.11 0-b60-7590822)
[✓] Android Studio
• Android Studio at /opt/android-studio
• Flutter plugin can be installed from: