Error: Couldn't find constructor 'TypeMatcher'. .ancestorStateOfType(const TypeMatcher<AnimatedCircularChartState>()); - flutter

i even done that but errors are still there. i tried to downgrade the flutter version sdk to that project but didn't find the specific version and the ones i found are not helping.
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_circular_chart-0.1.0/lib/src/animated_circular_chart.dart:122:36: Error: Couldn't find constructor 'TypeMatcher'.
.ancestorStateOfType(const TypeMatcher\<AnimatedCircularChartState\>());
^^^^^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_circular_chart-0.1.0/lib/src/animated_circular_chart.dart:122:10: Error: The method 'ancestorStateOfType' isn't defined for the class 'BuildContext'.
- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/framework.dart').
Try correcting the name to the name of an existing method, or defining a method named 'ancestorStateOfType'.
.ancestorStateOfType(const TypeMatcher\<AnimatedCircularChartState\>());
^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_circular_chart-0.1.0/lib/src/animated_circular_chart.dart:221:60: Error: The getter 'body2' isn't defined for the class 'TextTheme'.
- 'TextTheme' is from 'package:flutter/src/material/text_theme.dart' ('/C:/src/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 'body2'.
widget.labelStyle ?? Theme.of(context).textTheme.body2;
^^^^^
Failed to compile application.
So i downloaded this flutter project from github that was 3 years old so it was deprecated version, i fix the deprecated version error by following the documentation. now that error is fixed but after that i'm getting these errors above. i have tried so many things like pub upgrade, pub outdated and most of the commands like this but the error are still there. I somewhere read to add override dependencies: "dependency_overrides:
charts_flutter:
git:
url: https://github.com/google/charts
path: charts_flutter"

Related

Flutter app on Chrome - no longer running - Error: The getter 'completert' isn't defined for the class 'BrowserClient'

This afternoon - out of the blue - my Flutter app is no longer running on Chrome
I get the following error...
Waiting for connection from debug service on Chrome...
../../sdk/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.13.5/lib/src/browser_client.dart:56:7: Error: The getter 'completert' isn't defined for the class 'BrowserClient'.
- 'BrowserClient' is from 'package:http/src/browser_client.dart' ('../../sdk/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.13.5/lib/src/browser_client.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'completert'.
completert.complete(StreamedResponse(
^^^^^^^^^^
Failed to compile application.
Any suggestions?
Fixed by downloading an installing the latest DART build

Flutter Build_Runner Build Failing While Generating Mocks

Running build_runner to generate mocks using the Mockito package fails.
Terminal output:
[INFO] Generating build script... [INFO] Generating build script
completed, took 2.2s
[INFO] Precompiling build script...... [WARNING]
/D:/flutter_windows_1.22.5-stable/flutter/.pub-cache/hosted/pub.dartlang.org/mockito-5.3.0/lib/src/builder.dart:412:19:
Error: The getter 'libraryExports' isn't defined for the class
'LibraryElement'.
'LibraryElement' is from 'package:analyzer/dart/element/element.dart'
('/D:/flutter_windows_1.22.5-stable/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-3.4.1/lib/dart/element/element.dart').
Try correcting the name to the name of an existing getter, or defining
a getter or field named 'libraryExports'.
...entryLib.libraryExports,
^^^^^^^^^^^^^^ /D:/flutter_windows_1.22.5-stable/flutter/.pub-cache/hosted/pub.dartlang.org/mockito-5.3.0/lib/src/builder.dart:413:19:
Error: The getter 'libraryImports' isn't defined for the class
'LibraryElement'.
'LibraryElement' is from 'package:analyzer/dart/element/element.dart'
('/D:/flutter_windows_1.22.5-stable/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-3.4.1/lib/dart/element/element.dart').
Try correcting the name to the name of an existing getter, or defining
a getter or field named 'libraryImports'.
...entryLib.libraryImports,
^^^^^^^^^^^^^^ /D:/flutter_windows_1.22.5-stable/flutter/.pub-cache/hosted/pub.dartlang.org/mockito-5.3.0/lib/src/builder.dart:1493:36:
Error: The getter 'enclosingElement2' isn't defined for the class
'ParameterElement'.
'ParameterElement' is from 'package:analyzer/dart/element/element.dart'
('/D:/flutter_windows_1.22.5-stable/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-3.4.1/lib/dart/element/element.dart').
Try correcting the name to the name of an existing getter, or defining
a getter or field named 'enclosingElement2'.
final method = parameter.enclosingElement2!;
^^^^^^^^^^^^^^^^^ /D:/flutter_windows_1.22.5-stable/flutter/.pub-cache/hosted/pub.dartlang.org/mockito-5.3.0/lib/src/builder.dart:1524:30:
Error: The getter 'enclosingElement2' isn't defined for the class
'ParameterElement'.
'ParameterElement' is from 'package:analyzer/dart/element/element.dart'
('/D:/flutter_windows_1.22.5-stable/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-3.4.1/lib/dart/element/element.dart').
Try correcting the name to the name of an existing getter, or defining
a getter or field named 'enclosingElement2'.
final method = parameter.enclosingElement2 as MethodElement;
^^^^^^^^^^^^^^^^^ /D:/flutter_windows_1.22.5-stable/flutter/.pub-cache/hosted/pub.dartlang.org/mockito-5.3.0/lib/src/builder.dart:1525:27:
Error: The getter 'enclosingElement2' isn't defined for the class
'MethodElement'.
'MethodElement' is from 'package:analyzer/dart/element/element.dart'
('/D:/flutter_windows_1.22.5-stable/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-3.4.1/lib/dart/element/element.dart').
Try correcting the name to the name of an existing getter, or defining
a getter or field named 'enclosingElement2'.
final class_ = method.enclosingElement2 as ClassElement;
^^^^^^^^^^^^^^^^^ /D:/flutter_windows_1.22.5-stable/flutter/.pub-cache/hosted/pub.dartlang.org/mockito-5.3.0/lib/src/builder.dart:1535:28:
Error: The getter 'enclosingElement2' isn't defined for the class
'ExecutableElement'.
'ExecutableElement' is from 'package:analyzer/dart/element/element.dart'
('/D:/flutter_windows_1.22.5-stable/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-3.4.1/lib/dart/element/element.dart').
Try correcting the name to the name of an existing getter, or defining
a getter or field named 'enclosingElement2'.
overriddenMethod.enclosingElement2 as ClassElement, name);
^^^^^^^^^^^^^^^^^ /D:/flutter_windows_1.22.5-stable/flutter/.pub-cache/hosted/pub.dartlang.org/mockito-5.3.0/lib/src/builder.dart:1934:23:
Error: The getter 'enclosingElement2' isn't defined for the class
'Element'.
'Element' is from 'package:analyzer/dart/element/element.dart' ('/D:/flutter_windows_1.22.5-stable/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-3.4.1/lib/dart/element/element.dart').
Try correcting the name to the name of an existing getter, or defining
a getter or field named 'enclosingElement2'.
var className = enclosingElement2!.name;
^^^^^^^^^^^^^^^^^ /D:/flutter_windows_1.22.5-stable/flutter/.pub-cache/hosted/pub.dartlang.org/mockito-5.3.0/lib/src/builder.dart:1937:23:
Error: The getter 'enclosingElement2' isn't defined for the class
'Element'.
'Element' is from 'package:analyzer/dart/element/element.dart' ('/D:/flutter_windows_1.22.5-stable/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-3.4.1/lib/dart/element/element.dart').
Try correcting the name to the name of an existing getter, or defining
a getter or field named 'enclosingElement2'.
var className = enclosingElement2!.name;
^^^^^^^^^^^^^^^^^ [INFO] Precompiling build script... completed, took 22.4s
[SEVERE] Failed to precompile build script
.dart_tool/build/entrypoint/build.dart. This is likely caused by a
misconfigured builder definition.
I have tried overriding the analyzer dependency to 1.5.0 but it causes conflicts with other dependencies in the project.
Running flutter doctor shows the same errors in the terminal.
This is related to upgrading to mockito v5.3.0, dart pub upgrade might solve it. if not, revert mockito version to 5.2.0 and it should work.
mockito: 5.2.0 without the ^
The issue is caused by analyzer package, that it's used as a dependency for mockito.
Seems like the new version 4.4.0 deprecated a few APIs.
What I did to fix it for now (until maintainers fix it on the package) is to include analyzer as a dependency on my pubspec.yaml with latest stable version 4.3.1 and it works now.
dev_dependencies:
analyzer: 4.3.1
Hope this helps

flutter pub run build_runner build not working

when running flutter pub run build_runner build I get this error.
Failed to build build_runner:build_runner:
../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-0.41.2/lib/src/error/best_practices_verifier.dart:258:50: Error: The property 'displayString' is defined in multiple extensions for 'TargetKind' and neither is more specific.
- 'TargetKind' is from 'package:meta/meta_meta.dart' ('../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/meta-1.7.0/lib/meta_meta.dart').
Try using an explicit extension application of the wanted extension or hiding unwanted extensions from scope.
var kindNames = kinds.map((kind) => kind.displayString).toList()
^^^^^^^^^^^^^
../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-0.41.2/lib/src/error/best_practices_verifier.dart:1950:14: Context: This is one of the extension members.
String get displayString {
^^^^^^^^^^^^^
../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/meta-1.7.0/lib/meta_meta.dart:91:14: Context: This is one of the extension members.
String get displayString {
^^^^^^^^^^^^^
../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-0.41.2/lib/src/error/best_practices_verifier.dart:260:36: Error: The getter 'commaSeparatedWithOr' isn't defined for the class 'List<dynamic>'.
- 'List' is from 'dart:core'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'commaSeparatedWithOr'.
var validKinds = kindNames.commaSeparatedWithOr;
This issue is related to outdated dependencies most likely, I had a similar one just today.
Run flutter pub upgrade and it should work!
Those who are experiencing this problem, just overwrite the "meta" dependency.
just add these lines to pubspec.yaml
dependency_overrides:
meta: 1.6.0
This might solve your issue, and there is well discussed github discussion https://github.com/dart-lang/sdk/issues/46687

Flushbar plugin: Error: The method 'attach' isn't defined for the class 'FocusScopeNode'

my previous project I used flushbar plugin without any error. but my new project when try to use flushbar i got error..
Project is working well without flushbar.
full error message
Compiler message:
file:///Users/bhanukaisuru/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/flushbar-1.7.0/lib/flushbar.dart:207:3: Error: Type 'FocusAttachment' not found.
FocusAttachment _focusAttachment;
^^^^^^^^^^^^^^^
file:///Users/bhanukaisuru/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/flushbar-1.7.0/lib/flushbar.dart:207:3: Error: 'FocusAttachment' isn't a type.
FocusAttachment _focusAttachment;
^^^^^^^^^^^^^^^
file:///Users/bhanukaisuru/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/flushbar-1.7.0/lib/flushbar.dart:228:35: Error: The method 'attach' isn't defined for the class 'FocusScopeNode'.
- 'FocusScopeNode' is from 'package:flutter/src/widgets/focus_manager.dart' ('file:///Users/bhanukaisuru/Documents/flutter/packages/flutter/lib/src/widgets/focus_manager.dart').
Try correcting the name to the name of an existing method, or defining a method named 'attach'.
_focusAttachment = _focusNode.attach(context);
^^^^^^
file:///Users/bhanukaisuru/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/flushbar-1.7.0/lib/flushbar.dart:239:16: Error: The method 'dispose' isn't defined for the class 'FocusScopeNode'.
- 'FocusScopeNode' is from 'package:flutter/src/widgets/focus_manager.dart' ('file:///Users/bhanukaisuru/Documents/flutter/packages/flutter/lib/src/widgets/focus_manager.dart').
Try correcting the name to the name of an existing method, or defining a method named 'dispose'.
_focusNode.dispose();
I tried these four version, but nothing change
flushbar: ^1.3.0
flushbar: ^1.5.3
flushbar: ^1.7.0
flushbar: ^1.6.0
and also I used,
FocusScope.of(context).requestFocus(FocusNode()),
I was facing the same problem after flutter upgrade.
Remove ^ from your pubspec.yaml for now. It should work.
flushbar: 1.5.3
Reference : https://github.com/flutter/flutter/issues/33827

Internal compiler error message during Flutter hot reload:

I get the following error during Flutter hot reload
Compiler message:
org-dartlang-debug:synthetic_debug_expression:1:1: Error: Getter not found: 'response'.
^^^^^^^^^^^^
org-dartlang-debug:synthetic_debug_expression:1:1: Error: The getter 'using' isn't defined for the class 'MyHomePageState'.
- 'MyHomePageState' is from 'package:SampleApp/main.dart' ('lib/main.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'using'.
using
This is a known bug which should be fixed in the next release. The only workaround is to run flutter clean. (Using Android Studios Tools -> Flutter -> Flutter Clean should also work).