I want to run one of my old projects and while running I’m getting this error:
Error: The getter ‘backgroundColor’ isn’t defined for the class ‘ThemeData’.
- ‘ThemeData’ is from ‘package:flutter/src/material/theme_data.dart’ (‘/C:/Android/flutter/packages/flutter/lib/src/material/theme_data.dart’).
Try correcting the name to the name of an existing getter, or defining a getter or field named ‘backgroundColor’.
TextStyle(color: confirmTextColor ?? theme.backgroundColor),
^^^^^^^^^^^^^^^Target kernel_snapshot failed: Exception
FAILURE: Build failed with an exception.
Where:
Script ‘C:Androidflutterpackagesflutter_toolsgradlesrcmaingroovyflutter.groovy’ line: 1629What went wrong:
Execution failed for task ‘:app:compileFlutterBuildDebug’.
Process ‘command ‘C:Androidflutterbinflutter.bat” finished with non-zero exit value 1Try:
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 6s
Error: Gradle task assembleDebug failed with exit code 1
I already tried to find where is that backgroundColor
in 'package:flutter/src/material/theme_data.dart'
but nothing in it. I didn’t find backgroundColor
in whole theme_data.dart
file.
How to solve this?
2
Answers
Okay I have solved this error, the error is coming from a package. I have used
Get
package in my old app which is outdated. I have just updated it,From
To
It looks like somewhere in your project you there is a
TextStyle(color: confirmTextColor ?? theme.backgroundColor)
You can’t use this
theme.backgroundColor
anymore. It looks like it might actually not be in your own code but in a package calledflutter_tools
. It seems this package hasn’t been updated for 4 years, and it’s now simply not compatible with the most recent flutter version anymore. The only way to get it to build again is to downgrade your flutter version, or to remove theflutter_tools
package from your project.