Tobias H.
Tobias H.

Reputation: 494

Interact with widget under an image in flutter/dart

I have a question, how do I make a image on top of a listview and still be able to scroll on the listview? Like scroll though the image, so the image is not moving. When I stack them with 'stack widget' I still can't scroll, only in the parts of the scrollview that dosn't have an image on top of it. Please help me, this is like a big part of my app that i've been developing for 6 weeks now, and if I can't make it work, my app is kinda done for it!

Here's an example:

Stack(
children: <Widget>[
  ListView(
    controller: scrollController,
    children: <Widget>[
      Container(
       child: Text('widget 1'),
      ),
      Container(
       child: Text('widget 2'),
      ),
      Container(
       child: Text('widget 3'),
      ),
     ],
    ),
    Image.asset('assets/myImage.png'),
 ],
),

Upvotes: 1

Views: 281

Answers (1)

Mobina
Mobina

Reputation: 7109

You can wrap the image with an IgnorePointer widget:

Stack(
        children: <Widget>[
          ListView(
            controller: scrollController,
            children: <Widget>[
              Container(
                child: Text('widget 1'),
              ),
              Container(
                child: Text('widget 2'),
              ),
              Container(
                child: Text('widget 3'),
              ),
            ],
          ),
          IgnorePointer(child: Image.asset('assets/myImage.png')),
        ],
      ),

Upvotes: 1

Related Questions