Header 要显示的图片

Header image to show

我试图让 header 图片显示在应用程序的页面上,但它没有显示,而且 _header 在我的代码中似乎变灰了。我想念一些我不确定的东西。编辑:我需要 header 显示在构建内容行的上方。

 Widget _header() {
return new Container(
  child: new Row(
    children:<Widget>[
      new Column(
        children: <Widget>[
          Image.asset(
            'assets/classes-Image.png',
          ),
        ],
      ),
    ],
  ),
);

}

下面的额外代码:

    Widget build(BuildContext context) {
    return new Scaffold(
      appBar: AppBar(
        title: const Text('Learn How to Paint'),
        backgroundColor: Color(0xFF202945),
      ),
      body: new Container(
        child: ListView(
          shrinkWrap: true,
          children: <Widget>[
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: <Widget>[
                new Column(
                  children: <Widget>[
                    Row(
                      children: <Widget>[
                        new Padding(
                          padding: const EdgeInsets.only(
                            left: 20.0,
                          ),
                        ),
                        Image.asset(
                          'assets/Profile-Photo.png',
                        ),
                        new Padding(
                          padding: const EdgeInsets.only(
                            right: 20.0,
                          ),
                        ),
                        Text(
                          'Katherine G.',
                        ),
                      ],
                    ),
                  ],
                ),
                ```


您需要从构建函数中的某处调用 _header() 并将结果作为子项提供给另一个小部件。它变灰可能意味着您没有调用它。

您可以将 header 小部件放在 Row 小部件之前。

header 没有显示,因为您没有在 ListView 中添加它。

希望这能解决您的问题。