Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: The method 'ancestorStateOfType' isn't defined for the class 'BuildContext' #52

Open
Lock128 opened this issue Feb 24, 2021 · 0 comments

Comments

@Lock128
Copy link

Lock128 commented Feb 24, 2021

see https://api.flutter.dev/flutter/widgets/BuildContext/inheritFromWidgetOfExactType.html

This means that after upgrading to this version, compiling the app gives:

Target dart2js failed: Exception: /C:/ToolsJK/flutter/.pub-cache/hosted/pub.dartlang.org/dynamic_theme-1.0.1/lib/dynamic_theme.dart:25:20:
Error: The method 'ancestorStateOfType' isn't defined for the class 'BuildContext'.

  • 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/C:/ToolsJK/flutter/packages/flutter/lib/src/widgets/framework.dart').
    return context.ancestorStateOfType(const TypeMatcher());
    ^^^^^^^^^^^^^^^^^^^
    Error: Compilation failed.

Workaround:

Try correcting the name to the name of an existing method, or defining a method named 'ancestorStateOfType'.
with block 4.0.0

just change this in file .pub-cache/../dynamic_theme.dart:25:20

context.ancestorStateOfType()
on that

context.findAncestorStateOfType();

See also:
https://stackoverflow.com/questions/65749767/error-the-method-inheritfromwidgetofexacttype-isnt-defined-for-the-class-bu/66091525
https://stackoverflow.com/questions/65657716/error-the-method-ancestorstateoftype-isnt-defined-for-the-class-buildcontex

Lock128 added a commit to Lock128/dynamic_theme that referenced this issue Feb 24, 2021
Fixes deprecation/renaming
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant