不点击堆栈中的容器

我对Stack Widget有个问题。我有一个包含两个子元素的堆栈:一个用GestureDetector包装的图像和一个容器。当我在容器上的任意位置单击时,堆栈子列表中的最后一个人将列出其onTap

我对flutter还是个新手。

屏幕截图

?

?

这段代码

  sonItem(dynamic icon ,String text,Color color){
return  GestureDetector(
  onTap: () {
    print("dddddddddddddddd");
  },
  child: Container(

    width: 70,
    height: 100,
    margin: EdgeInsets.all(2),
    padding: EdgeInsets.all(2),

    child: Column(
      children: [
        Icon(icon ,color: color,),
        Text(text)
      ],
    ),
  ),
);

}

我对Stack Widget有个问题。我有一个包含两个子元素的堆栈:一个用GestureDetector包装的图像和一个容器。当我在容器上的任意位置单击时,堆栈子列表中的最后一个人将列出其onTap

 body: Container(
            color: Colors.white,
            child: SingleChildScrollView(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.stretch,
                children: [
                  Container(
                    color:  Color(0xffF0F0F0),
                    height: 200,
                    child: Stack(
                      overflow: Overflow.visible,
                      alignment: Alignment.center,
                      children: [
                  
                        Positioned(
                            bottom: -170.0,
                            child: Container(
                              padding: EdgeInsets.only(top: 40 , right: 10, left: 10),
                              height: 250,
                              decoration: BoxDecoration(
                                color: Color(0xffFFFFFF),
                                borderRadius: BorderRadius.circular(30),
                                border: Border.all(
                                  width: 1,
                                  color: Colors.black,
                                  style: BorderStyle.solid,
                                ),
                              ),
                              child: Column(
                                children: [
                                  Text('company',
                                    textAlign: TextAlign.center,
                                    style: TextStyle(
                                      fontSize: 24,
                                      color: Colors.black,
                                    ),
                                  ),
                                  Text("The number 2000"),
                                  RatingBar(
                                    rating: 3,
                                    icon:Icon(Icons.star,size:20,color: Colors.grey,),
                                    starCount: 5,
                                    spacing: 5.0,
                                    size: 20,
                                    isIndicator: false,
                                    allowHalfRating: true,
                                    onRatingCallback: (double value,ValueNotifier<bool> isIndicator){
                                      print('Number of stars-->  $value');
                                      //change the isIndicator from false  to true ,the       RatingBar cannot support touch event;
                                      isIndicator.value=true;
                                    },
                                    color: Colors.amber,
                                  ),
                                  Row(
                                    mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                                    children: [
                                      sonItem(Icons.phone,"call us",Colors.green),
                                      sonItem(Icons.location_on_outlined,"location",Colors.red),
                                      sonItem(Icons.facebook,"FaceBook",Colors.blue),
                                      sonItem(Icons.add_ic_call_outlined,"whatsapp",Colors.green)
                                    ],
                                  )
                                ],),
                            )),

转载请注明出处:http://www.dlaisen.com/article/20230526/1096837.html