如何使用 children 小部件更改 AppBar 内容?

How to change AppBar content using children widget?

我正在尝试将 AppBar 标题从 LoginWidget 级别更改为 "Log In",但我不知道该怎么做。

可能看起来像 IoC 模式,但我认为它仍然可以做到。

我现在正在尝试扩展一个 Scaffold object 并向其添加一些方法,但它似乎不起作用。

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
            backgroundColor: Colors.amber,
            title: new Text("Application name")
        ),
        body: new LoginWidget()
      )
    );
  }
}

这是不可能的

小部件不能以任何方式修改其他小部件。他们唯一能做的就是提交事件,让他们可能做出反应。

只有 MyApp 可以更改应用栏。