Multiply gesture detector in flutter

亡梦爱人 提交于 2020-07-10 10:25:25

问题


I have two views one over another and want get touches in both views. But now get touches only second view. How can I configure GestureDetector that all touches will be send both widgets

import 'package:flutter/material.dart';

class TestPage extends StatefulWidget {
  TestPage();

  @override
  _TestPageState createState() => _TestPageState();
}

class _TestPageState extends State<TestPage> {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      backgroundColor: Colors.blueAccent,
      body: Stack(
        children: [_renderFirstWidget(), _renderSecondWidget()],
      ),
    );
  }

  Widget _renderFirstWidget() {
    return Center(
      child: GestureDetector(
          onTap: () {
            print('first');
          },
          child: Container(height: 150, width: 150, color: Colors.greenAccent)),
    );
  }

  Widget _renderSecondWidget() {
    return Center(
        child: GestureDetector(
          onTap: () {
            print('second');
          },
            child: Container(
                height: 350,
                width: 350,
                color: Colors.redAccent.withOpacity(0.3))));
  }
}

来源:https://stackoverflow.com/questions/62792718/multiply-gesture-detector-in-flutter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!