Skip to content

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

@Lock128

Description

@Lock128

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions