how to display images and text on it in listview flutter?

前端 未结 1 1608
名媛妹妹
名媛妹妹 2021-01-27 00:03

i want to display a images and text in listview. Data is parsed and set it in model class. can you please help me out. Below is my class.

import \'dart:async\';
         


        
相关标签:
1条回答
  • 2021-01-27 00:44

    You need to build your layout in itemBuilder property of ListView. If you want to place the text on the image the best layout widget is Stack.

    See the following in order to get the layout system of flutter: https://flutter.io/tutorials/layout/

    and for all the available layout widgets see: https://flutter.io/widgets/layout/

    and Stack: https://docs.flutter.io/flutter/widgets/Stack-class.html

    Something like this:

    new Stack(
      children: <Widget>[
        new Positioned.fill(
          child: new FadeInImage(
            placeholder: new AssetImage('placeholder.png'),
            image: new CachedNetworkImageProvider(photos[int].url),
            fit: BoxFit.contain,
            alignment: Alignment.center,
            fadeInDuration: new Duration(milliseconds: 200),
            fadeInCurve: Curves.linear,
          ),
        ),
        new Positioned(
          top: 10.0,
          left: 10.0,
          child: new Container(
            child: new Text(photos[int].title)
          ),
        ),
      ],
    )
    
    0 讨论(0)
提交回复
热议问题