@farmerswalker (jun)

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

Flutter、リストビューの上にStackで配置したボタンをタップできるかつ、後ろのスクロールも可能にしたい。

解決したいこと

リストビューやスクロールビューの上にStackで配置したボタンをタップできるかつ、ボタンの部分で後ろのスクロールも可能にしたい。

例)
以下のようなイメージなのですが、青いボタンをタップでタップ処理できるかつ、青いボタンの部分を上下にスクロールすると後ろのリストビューがスクロールされるようにしたいです。
Screenshot_20211225-030740.jpg

例)

class Test extends StatelessWidget {
  final items = List<String>.generate(100, (i) => "Item $i");

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('テスト'),
      ),
      body: Stack(
        children: [
          ListView.builder(
            itemCount: items.length,
            itemBuilder: (context, index) {
              return ListTile(
                title: Text('${items[index]}'),
              );
            },
          ),
          Positioned(
            bottom: 100,
            right: 0,
            child: OutlinedButton(
              child:  Text('タップ可能で後ろのスクロールも可能'),
              style: OutlinedButton.styleFrom(
                backgroundColor: Colors.lightBlueAccent,
                primary: Colors.white,
                shape:  StadiumBorder(),
              ),
              onPressed: () {},
            ),
          )
        ],
      )
    );
  }
}

自分で試したこと

ボタンにIgnorePointerをかければ、ボタン部分をスクロールしても後ろのリストビューはもちろんスクロールできるようになるのですが、それに加えてタップでタップ処理できるところまでできませんでした。この二つを可能にできる方法があれば教えていただきたいです!

0 likes

No Answers yet.

Your answer might help someone💌