I start learning flutter last year and created a small project which run fine, and stopped learning it until now...
so today, after update flutter to latest version (2.5.0) and start running the project again, I'm stuck with this error when trying to run it again :
Launching lib\order_route.dart on ASUS X01BDA in debug mode...
Running Gradle task 'assembleDebug'...
/D:/progie/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_widgets-0.1.12/lib/src/tagged_text/tagged_text.dart:295:36: Error: No named parameter with the name 'nullOk'.
MediaQuery.of(context, nullOk: true)?.textScaleFactor ??
^^^^^^
/D:/progie/flutter/packages/flutter/lib/src/widgets/media_query.dart:841:25: Context: Found this candidate, but the arguments don't match.
static MediaQueryData of(BuildContext context) {
^^
/D:/progie/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_widgets-0.1.12/lib/src/feature_discovery/src/overlay_widgets.dart:239:20: Error: The getter 'title' isn't defined for the class 'TextTheme'.
- 'TextTheme' is from 'package:flutter/src/material/text_theme.dart' ('/D:/progie/flutter/packages/flutter/lib/src/material/text_theme.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'title'.
style: theme.title.copyWith(color: Colors.white),
^^^^^
/D:/progie/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_widgets-0.1.12/lib/src/feature_discovery/src/overlay_widgets.dart:248:20: Error: The getter 'subhead' isn't defined for the class 'TextTheme'.
- 'TextTheme' is from 'package:flutter/src/material/text_theme.dart' ('/D:/progie/flutter/packages/flutter/lib/src/material/text_theme.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'subhead'.
style: theme.subhead.copyWith(color: Colors.white70),
^^^^^^^
FAILURE: Build failed with an exception.
* Where:
Script 'D:\progie\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1005
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'D:\progie\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 14s
Exception: Gradle task assembleDebug failed with exit code 1
what I already did :
- running flutter doctor, everything ok
- invalidate caches/restart
- Pub Upgrade in pubspec.yaml
but doesn't help at all
I'm using android studio version 4.1
From the error, the code is 700ish line, but I don't know which part generate the above error, and I don't even use the TextTheme or MediaQuery in the code.
running pub outdated :
Showing outdated packages.
[*] indicates versions that are not the latest available.
Package Name Current Upgradable Resolvable Latest
direct dependencies: all up-to-date.
transitive dependencies:
async *2.8.1 *2.8.1 *2.8.1 2.8.2
characters *1.1.0 *1.1.0 *1.1.0 1.2.0
csslib *0.16.2 *0.16.2 *0.16.2 0.17.0
html *0.14.0 4 *0.14.0 4 *0.14.0 4 0.15.0
matcher *0.12.10 *0.12.10 *0.12.10 0.12.11
quiver *2.1.5 *2.1.5 *2.1.5 3.0.1
transitive dev_dependencies:
test_api *0.4.2 *0.4.2 *0.4.2 0.4.3
all dependencies are up-to-date.
Process finished with exit code 0
is the problem related to the dependencies above?
any help will really appreciated, thank you in advance!
CodePudding user response:
A lot has happened with flutter over the past one year. You upgrading to 2.5 means your flutter projects will have null safety and you might need to update any of your dependencies to their latest versions that might support null safety. So the error is coming from the flutter widgets package. If you check https://pub.dev/packages/flutter_widgets it says the package is no longer updated so it is outdated and you are advised to use one of the alternatives available.