背景图片未设置,显示在顶部

时间:2018-06-13 15:39:18

标签: flutter

 background is not set, its display top of the screen ..
background is not set, its display top of the screen ..

背景未设置,其显示屏顶部.. 背景未设置,其显示屏幕顶部..

我的代码如下,请检查并告诉我哪里出了问题....

我的代码如下,请检查并告诉我哪里出了问题.... 我的代码如下,请检查并告诉我它出错的地方....

  Widget build(BuildContext context) {
  return new Scaffold(
    appBar: new AppBar(),
    body: new SingleChildScrollView(
      child: new Center(
        child: new Column(
          mainAxisAlignment: MainAxisAlignment.center,

          children: <Widget>[
            new Image.asset(
              'assets/shopping.jpg',
              fit: BoxFit.cover,
              color: Colors.black54,
              colorBlendMode: BlendMode.darken,
            ),

            new Padding(padding: const EdgeInsets.only(top: 5.0),
              child: new Row(

                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: <Widget>[
                  new InkWell(
                    onTap: () {

                    },
                    child: new Column(
                      children: <Widget>[
                        new CircleAvatar(
                          child: new Icon(Icons.access_alarm, color: Colors.white),
                          backgroundColor: Colors.black,
                          radius: MediaQuery.of(context).orientation == Orientation.portrait
                              ? MediaQuery.of(context).size.width / 8
                              : MediaQuery.of(context).size.width / 12,
                        ),
                        new Padding(
                          padding: const EdgeInsets.only(top: 5.0),
                          child: new Text("Offer Of The Day",
                            maxLines: 2,
                            overflow: TextOverflow.ellipsis,
                            style: new TextStyle(color: Colors.grey[700], fontSize: 14.0),
                          ),
                        )
                      ],
                    ),
                  ),
                  new InkWell(
                    onTap: () {

                    },
                    child: new Column(
                      children: <Widget>[
                        new CircleAvatar(
                    child: new Icon(Icons.access_alarm, color: Colors.white),
                          backgroundColor: Colors.black,
                          radius: MediaQuery.of(context).orientation == Orientation.portrait
                              ? MediaQuery.of(context).size.width / 8
                              : MediaQuery.of(context).size.width / 12,
                        ),
                        new Padding(
                          padding: const EdgeInsets.only(top: 5.0),
                          child: new Text("aabb",
                            maxLines: 2,
                            overflow: TextOverflow.ellipsis,
                            style: new TextStyle(color: Colors.grey[700], fontSize: 14.0),
                          ),
                        )
                      ],
                    ),
                  ),
                ],
              ),),
            new Padding(padding: const EdgeInsets.only(top: 5.0),
              child: new Row(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: <Widget>[
                  new InkWell(
                    onTap: () {

                    },
                    child: new Column(
                      children: <Widget>[
                        new CircleAvatar(
                          child: new Icon(Icons.access_alarm, color: Colors.white),
                          backgroundColor: Colors.black,
                          radius: MediaQuery.of(context).orientation == Orientation.portrait
                              ? MediaQuery.of(context).size.width / 8
                              : MediaQuery.of(context).size.width / 12,
                        ),
                        new Padding(
                          padding: const EdgeInsets.only(top: 5.0),
                          child: new Text("aabb",
                            maxLines: 2,
                            overflow: TextOverflow.ellipsis,
                            style: new TextStyle(color: Colors.grey[700], fontSize: 14.0),
                          ),
                        )
                      ],
                    ),
                  ),
                  new InkWell(
                    onTap: () {

                    },
                    child: new Column(
                      children: <Widget>[
                        new CircleAvatar(
                          child: new Icon(Icons.access_alarm, color: Colors.white),
                          backgroundColor: Colors.black,
                          radius: MediaQuery.of(context).orientation == Orientation.portrait
                              ? MediaQuery.of(context).size.width / 8
                              : MediaQuery.of(context).size.width / 12,
                        ),
                        new Padding(
                          padding: const EdgeInsets.only(top: 5.0),
                          child: new Text("aabb",
                            maxLines: 2,
                            overflow: TextOverflow.ellipsis,
                            style: new TextStyle(color: Colors.grey[700], fontSize: 14.0),
                          ),
                        )
                      ],
                    ),
                  ),
                ],
              ),),
            new Padding(padding: const EdgeInsets.only(top: 5.0),
              child: new Row(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: <Widget>[
                  new InkWell(
                    onTap: () {

                    },
                    child: new Column(
                      children: <Widget>[
                        new CircleAvatar(
                          child: new Icon(Icons.access_alarm, color: Colors.white),
                          backgroundColor: Colors.black,
                          radius: MediaQuery.of(context).orientation == Orientation.portrait
                              ? MediaQuery.of(context).size.width / 8
                              : MediaQuery.of(context).size.width / 12,
                        ),
                        new Padding(
                          padding: const EdgeInsets.only(top: 5.0),
                          child: new Text("aabb",
                            maxLines: 2,
                            overflow: TextOverflow.ellipsis,
                            style: new TextStyle(color: Colors.grey[700], fontSize: 14.0),
                          ),
                        )
                      ],
                    ),
                  ),
                  new InkWell(
                    onTap: () {

                    },
                    child: new Column(
                      children: <Widget>[
                        new CircleAvatar(
                          child: new Icon(Icons.access_alarm, color: Colors.white),
                          backgroundColor: Colors.black,
                          radius: MediaQuery.of(context).orientation == Orientation.portrait
                              ? MediaQuery.of(context).size.width / 8
                              : MediaQuery.of(context).size.width / 12,
                        ),
                        new Padding(
                          padding: const EdgeInsets.only(top: 5.0),
                          child: new Text("aabb",
                            maxLines: 2,
                            overflow: TextOverflow.ellipsis,
                            style: new TextStyle(color: Colors.grey[700], fontSize: 14.0),
                          ),
                        )
                      ],
                    ),
                  ),
                ],
              ),),
            new Padding(padding: const EdgeInsets.only(top: 5.0),
              child: new Row(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: <Widget>[
                  new InkWell(
                    onTap: () {

                    },
                    child: new Column(
                      children: <Widget>[
                        new CircleAvatar(
                          child: new Icon(Icons.access_alarm, color: Colors.white),
                          backgroundColor: Colors.black,
                          radius: MediaQuery.of(context).orientation == Orientation.portrait
                              ? MediaQuery.of(context).size.width / 8
                              : MediaQuery.of(context).size.width / 12,
                        ),
                        new Padding(
                          padding: const EdgeInsets.only(top: 5.0),
                          child: new Text("aabb",
                            maxLines: 2,
                            overflow: TextOverflow.ellipsis,
                            style: new TextStyle(color: Colors.grey[700], fontSize: 14.0),
                          ),
                        )
                      ],
                    ),
                  ),
                  new InkWell(
                    onTap: () {

                    },
                    child: new Column(
                      children: <Widget>[
                        new CircleAvatar(
                          child: new Icon(Icons.access_alarm, color: Colors.white),
                          backgroundColor: Colors.black,
                          radius: MediaQuery.of(context).orientation == Orientation.portrait
                              ? MediaQuery.of(context).size.width / 8
                              : MediaQuery.of(context).size.width / 12,
                        ),
                        new Padding(
                          padding: const EdgeInsets.only(top: 5.0),
                          child: new Text("aabb",
                            maxLines: 2,
                            overflow: TextOverflow.ellipsis,
                            style: new TextStyle(color: Colors.grey[700], fontSize: 14.0),
                          ),
                        )
                      ],
                    ),
                  ),
                ],
              ),),
            new Padding(padding: const EdgeInsets.only(top: 5.0),
              child: new Row(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: <Widget>[
                  new InkWell(
                    onTap: () {

                    },
                    child: new Column(
                      children: <Widget>[
                        new CircleAvatar(
                          child: new Icon(Icons.access_alarm, color: Colors.white),
                          backgroundColor: Colors.black,
                          radius: MediaQuery.of(context).orientation == Orientation.portrait
                              ? MediaQuery.of(context).size.width / 8
                              : MediaQuery.of(context).size.width / 12,
                        ),
                        new Padding(
                          padding: const EdgeInsets.only(top: 5.0),
                          child: new Text("aabb",
                            maxLines: 2,
                            overflow: TextOverflow.ellipsis,
                            style: new TextStyle(color: Colors.grey[700], fontSize: 14.0),
                          ),
                        )
                      ],
                    ),
                  ),
                  new InkWell(
                    onTap: () {

                    },
                    child: new Column(
                      children: <Widget>[
                        new CircleAvatar(
                          child: new Icon(Icons.access_alarm, color: Colors.white),
                          backgroundColor: Colors.black,
                          radius: MediaQuery.of(context).orientation == Orientation.portrait
                              ? MediaQuery.of(context).size.width / 8
                              : MediaQuery.of(context).size.width / 12,
                        ),
                        new Padding(
                          padding: const EdgeInsets.only(top: 5.0),
                          child: new Text("aabb",
                            maxLines: 2,
                            overflow: TextOverflow.ellipsis,
                            style: new TextStyle(color: Colors.grey[700], fontSize: 14.0),
                          ),
                        )
                      ],
                    ),
                  ),
                ],
              ),),
          ],

        ),
      ),
    )

  );
}

}

1 个答案:

答案 0 :(得分:0)

将SingleChildScrollView包装在堆栈中,然后您可以在SingleChildScrollView的背景中显示图像

 return new Scaffold(
        appBar: new AppBar(),
        body: new Stack(
          children: <Widget>[
            new Container(
              decoration: new BoxDecoration(
                image: new DecorationImage(
                  image: new AssetImage("assets/shopping.jpg"),
                  fit: BoxFit.cover,
                ),
              ),
            ),
            new YourSingleChildScrollView(),
          ],
        ));

enter image description here