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

Chapter3.14:A value of type 'Scaffold?' can't be assigned to a variable of type 'Scaffold'. #434

Open
Zongyoujifeng opened this issue Apr 23, 2021 · 1 comment

Comments

@Zongyoujifeng
Copy link

No description provided.

@TheSparklingStarrySky
Copy link

      You can do this :
      // 在 widget 树中向上查找最近的父级`Scaffold`  widget
      Scaffold scaffold = context.findAncestorWidgetOfExactType<Scaffold>() as Scaffold;
      // 直接返回 AppBar的title, 此处实际上是Text("Context测试")
      return (scaffold.appBar as AppBar).title as Widget;

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

2 participants