微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在列表视图中弹跳容器

如何解决在列表视图中弹跳容器

我知道启用一个按钮可以在点击时弹跳,但是我面临的问题是我想在包含容器的列表视图中实现此功能,但我无法做到这一点。关于这里的单个按钮只有问题{{ 3}},但不适用于整个按钮/容器列表。我尝试了上面的链接包,但它还会导致其他问题,例如列表无法滚动,有时甚至根本无法正常工作,请帮助

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: HomePage()
    );
  }
}

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> with SingleTickerProviderStateMixin{
  AnimationController animationController;
  double _scale;
  @override
  void initState(){
    animationController=AnimationController(vsync: this,duration: Duration(milliseconds: 500),lowerBound: 0.0,upperBound: 0.2);

    animationController.addListener(() {
      setState(() {

      });
    });
    super.initState();
  }

  void Ontapdown(TapDownDetails details){
    animationController.forward();
  }


  void Ontapup(TapUpDetails details){
    animationController.reverse();
  }

  bool lights=false;
  int count1=0;
  int count2=0;
  @override
  Widget build(BuildContext context) {
    _scale =1-animationController.value;
    return Scaffold(
      appBar: AppBar(
        title: Text("Quickier"),centerTitle: true,backgroundColor: Colors.indigo,),body: Container(
        height: 250,margin: EdgeInsets.fromLTRB(10,10,5,10),child: ListView(
              scrollDirection: Axis.horizontal,physics: BouncingScrollPhysics(),children: <Widget>[
                GestureDetector(
                  onTap: (){
                    Navigator.push(context,MaterialPageRoute(builder:
                    (context)=> camerapp()));
                  },child: Container(
                    margin: EdgeInsets.fromLTRB(5,0),height: 100,width: 200,decoration: Boxdecoration(
                          color: Colors.grey[700],borderRadius: BorderRadius.all(Radius.circular(10),)

                      ),child: Column(
                        crossAxisAlignment: CrossAxisAlignment.center,mainAxisAlignment: MainAxisAlignment.center,children: <Widget>[
                          Icon(
                            Icons.camera_alt,color: Colors.black,size: 70,SizedBox(height: 20.0),Text(
                            "Camera",style: TextStyle(
                               fontSize: 20.0,color: Colors.black
                             ),)
                        ],)
                      ),GestureDetector(
                  onTap: (){
                    setState(() {
                      if(count1%2==1){
                      lights=false;
                      Flashlight.lightOff();}
                      else{
                        lights=true;
                        Flashlight.lightOn();
                      }
                      count1+=1;
                    });
                  },child: Container(
                      margin: EdgeInsets.fromLTRB(5,padding: EdgeInsets.symmetric(vertical: 20.0,horizontal: 20.0),decoration: Boxdecoration(
                          color: Colors.teal[300],children: <Widget>[
                          Icon(
                            Icons.highlight,color: lights ? Colors.yellow.shade600 : Colors.black,Text(
                            "Flashlight",style: TextStyle(
                                fontSize: 20.0,color: Colors.black
                            ),)

                  ),GestureDetector(
                  onTap: (){
                    HapticFeedback.lightImpact();
                    },onTapDown: Ontapdown,onTapUp: Ontapup,child: Transform.scale(
                    scale: _scale,child: Container(
                        margin: EdgeInsets.fromLTRB(5,decoration: Boxdecoration(
                            color: Colors.teal[400],)
                        ),child: Column(
                          crossAxisAlignment: CrossAxisAlignment.center,children: <Widget>[
                              Icon(
                                Icons.vibration,Text(
                              "Vibration",style: TextStyle(
                                  fontSize: 20.0,color: Colors.black
                              ),)
                          ],)

                    ),Container(
                    margin: EdgeInsets.fromLTRB(5,decoration: Boxdecoration(
                        color: Colors.teal[500],)
                    ),child: Column(
                      crossAxisAlignment: CrossAxisAlignment.center,children: <Widget>[
                        Icon(
                          Icons.settings,Text(
                          "Settings",style: TextStyle(
                              fontSize: 20.0,color: Colors.black
                          ),)
                      ],)
                )
              ],)
    );
  }
}

我已经在一个容器上启用了它,即振动了三分之一,但是当我在另一个容器的GestureDetector上应用ontapup和ontapdown时,会发生非常不同的事情,例如,如果我单击其中一个容器同时弹跳,请键入... ...

所以,请告诉我应该怎么做,或者如果有其他方法,因为我只是一个初学者,这将是有帮助的。

任何其他建议也将不胜感激。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。