如何在Flutter中显示ListTile

时间:2020-07-19 06:23:24

标签: flutter

我想像显示的图像那样做我的界面。我想显示图像,并在图像上放一个容器。现在我要显示的ListTile出现了问题,没有出来。

enter image description here

这是我的代码:

Scaffold(
      appBar: AppBar(
        title: Text('Detail'),
      ),
      body: Column(children: <Widget>[
      Expanded(
        child: 
          Stack(children: <Widget>[
            Container(
            decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.only(topLeft: Radius.circular(40), topRight: Radius.circular(40)),), 
            child: Image.assets('images/photo.png'),
          ),
          Container(
            margin: EdgeInsets.only(top: 170),
            child: Stack(alignment: Alignment.topCenter, children: <Widget>[
            Container(
            decoration: BoxDecoration(
            borderRadius: BorderRadius.only(topLeft: Radius.circular(40), topRight: Radius.circular(40)), 
            color: Colors.white),
          )
          ],
          ), 
          ),
          Positioned(top: 200, left: 8, 
          child: Column(children: <Widget>[
            ListTile(title: Text('Title'), subtitle: Text(''),)
          ],)
          )
        ],
        ),
        )
      ],)

    );

有人可以帮助我吗?

2 个答案:

答案 0 :(得分:1)

替换这样的代码

 return Scaffold(
   appBar: AppBar(
     title: Text("title text"),),
     body: Stack(children: <Widget>[
      Positioned(
        top: 0,
              child: Image.network("https://upload.wikimedia.org/wikipedia/commons/6/6d/Good_Food_Display_-_NCI_Visuals_Online.jpg",
                fit: BoxFit.cover,
                height: 200,
                width: MediaQuery.of(context).size.width,
                 ),
      ),

      Positioned(
        top: 190,
              child: Container(
                width: MediaQuery.of(context).size.width,
               height: 600,
                decoration: BoxDecoration(
                  color: Colors.white,
                  borderRadius: BorderRadius.only(topLeft:Radius.circular(20), topRight:Radius.circular(20)) ),
                  child: ListView(
                    shrinkWrap: true,
                    children: <Widget>[
                    ListTile(title: Text("Title 1"),),
                    ListTile(title: Text("Title 1"),),
                    ListTile(title: Text("Title 1"),),
                  ],) ,),
      )
     ],),
     
     );

答案 1 :(得分:1)

在“定位的”小部件内滚动时,您必须在列表视图中提供所有位置和滚动方向

Problem statement is:

a. Create a file 'user_UserID.info' file under /tmp. Populate the file 'user_UserID.info' with the following data:
Username,Password,PrimaryGroup,Comment,HomeDir

b. Create a Shell script to add user accounts and set the password for the users listed in 'user_UserID.info' file. All other 
dependent activities like group creation, directory creation etc. also should be done through this script.

c. Display the content of /home directory on console. Redirect the newly created 3 user’s information to userdetails_UserID.txt