在颤动中获得容器内部的点击

问题描述 投票:1回答:4
Stack(
    children: <Widget>[
        getChartView(widget.globalData.chartSelectValue),
        Container(
            decoration: BoxDecoration(
                border: Border.all(
                    color: HexColor("#0C1C3B"), // <--- border color
                    width: 10.0,
                ),
            ),
            width: MediaQuery.of(context).size.width,
            height: MediaQuery.of(context).size.height - 280,
        )
    ],
),

我想要在getChartView()中单击,但是该容器位于click和chartview之间,有谁可以帮助我吗?

flutter dart flutter-layout
4个回答
2
投票

Stack( children: <Widget>[ GestureDetector( child: Container( decoration: BoxDecoration( border: Border.all( color: HexColor("#0C1C3B"), width: 10.0, ), ), width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.height - 280, ), onTap: () { getChartView(widget.globalData.chartSelectValue); }, ) ], ),


1
投票
那么,您可能需要检查层次结构,即视图的呈现方式彼此重叠,这是因为您正在使用堆栈。另一个观点可能是冲动,而不是您的getChartView(....)

0
投票
或者您可以使用InkWell,它可以处理轻击事件并为动作设置动画。

InkWell( onTap: () { getChartView(widget.globalData.chartSelectValue); }, child: Container( decoration: BoxDecoration( border: Border.all( color: HexColor("#0C1C3B"), width: 10.0, ), ), width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.height - 280, ), ),


-1
投票

或者您可以使用InkWell,它可以处理轻击事件并为动作设置动画。

© www.soinside.com 2019 - 2024. All rights reserved.