Skip to content

思考题:为什么build方法的参数不定义成Element对象,而要定义成BuildContext ? #323

Closed
@evanwsu

Description

@evanwsu

这个问题可以探讨一下,不留下解答很难受呀!
先说下我的理解,使用BuildContext是不想将Element完全暴露出去,因为Element依赖Widget,如果参数使用Element, 则Widget也会依赖Element,这就导致互相依赖,形成了高耦合,使用BuildContext作为参数,可以避免互相依赖。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions