阻止listview.builder滚动

时间:2019-12-28 10:33:02

标签: image listview flutter stack

我有一个图片网址数组。我需要在不会向下滚动的listview.builder中显示它们。我希望它显示它们为堆栈。 Like this

2 个答案:

答案 0 :(得分:1)

您可以为此使用Stack小部件。您可以将图像列表传递到堆栈的children属性。

示例:

class _StackImagesState extends State<StackImages> {

  List<String> _urls = [];

  @override
  void initState() {
    super.initState();
    _urls = [
      "https://toppng.com/uploads/preview/royalty-free-stock-eyelash-clipart-glitter-glitter-eyelash-transparent-background-11562955805upbu10lfl4.png",
      "https://www.netclipart.com/pp/m/8-82184_banner-free-stock-apple-transparent-background-image-apple.png"
    ];
  }

  @override
  Widget build(BuildContext context) {
    return Stack(
      children:_urls.map((String url) => Image.network(url)).toList(),
    );
  }
}

答案 1 :(得分:0)

  Stack(
      alignment: Alignment.centerRight,
      children: <Widget>[
        Image.network(url:arr[0]),
        Image.network(url:arr[1]),
      ],
    ),
  );

您可以从数组中一张一张地放置图像