首页 > 解决方案 > Flutter Upgrade 破坏了按钮转换,使一些按钮不可见。

问题描述

最近我运行了一个flutter upgrade,一个我用浮动操作按钮构建的按钮转换,以前可以正常工作,现在不再工作了。动画隐藏了除最后一个按钮之外的所有按钮。关于什么变化导致这个问题的任何想法?

在此处输入图像描述

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, v0.5.6-pre.55, on Linux, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
[✓] Android Studio (version 3.0)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] IntelliJ IDEA Ultimate Edition (version 2018.1)
[!] VS Code (version 1.23.1)
[✓] Connected devices (1 available)

看看一个示例项目:https ://github.com/abarrafo/flutter_button_animation

@override
Widget build(BuildContext context) {
    return new Scaffold(
    body: new Container(),
    floatingActionButton: new SingleChildScrollView(
        child: new Container(
            padding: new EdgeInsets.fromLTRB(
                0.0,
                _showMenu ? 50.0 : 0.0,
                0.0,
                0.0),
            child: new Column(
                mainAxisSize: MainAxisSize.min,
                children:
                !_showMenu ? new List()
                    : new List.generate(widget.icons.length, (int index) {
                Widget child = new Container(
                    height: 70.0,
                    width: 56.0,
                    alignment: FractionalOffset.topCenter,
                    child: new ScaleTransition(
                    scale: new CurvedAnimation(
                        parent: _animationController,
                        curve: new Interval(
                            0.0,
                            1.0 - index / widget.icons.length / 2.0,
                            curve: Curves.easeOut
                        ),
                    ),
                    child: index == 2 || index == 3 ? new GestureDetector(
                        onDoubleTap: (){
                        //do stuff
                        },
                        onLongPress: (){
                        //do other stuff
                        },
                        child: new FloatingActionButton(
                        heroTag: index,
                        mini: true,
                        child: new Icon(widget.icons[index]),
                        onPressed: () {
                            //do other stuff
                        },
                        ),
                    ) :
                    new FloatingActionButton(
                        heroTag: index,
                        mini: true,
                        child: new Icon(widget.icons[index]),
                        onPressed: () {
                        //do stuff
                        },
                    )
                    ,
                    ),
                );
                return child;
                }).toList()..add(
                new Opacity(opacity: 0.5,
                    child:  new FloatingActionButton(
                        elevation: 3.0,
                        child: new AnimatedBuilder(
                        animation: _animationController,
                        builder: (BuildContext context, Widget child) {
                            return new Transform(
                            transform: new Matrix4.rotationZ(
                                _animationController.value * 0.5 * math.pi),
                            alignment: FractionalOffset.center,
                            child: new Icon(_animationController.isDismissed
                                ? Icons.menu
                                : Icons.close),
                            );
                        },
                        ),
                        onPressed: () {
                        if (_animationController.isDismissed) {
                            setState(() {
                            _showMenu = true;
                            });
                            _animationController.forward();
                        } else {
                            new Timer(new Duration(milliseconds: 500), (){
                            setState(() {
                                _showMenu = false;
                            });
                            });
                            _animationController.reverse();
                        }
                        },
                    )
                ),
                )),
        )
    ),
    );
}

标签: flutter

解决方案


好的,我再次运行flutter upgrade,它已修复。我的猜测是这是在颤振构建中引入的一个错误,并很快得到解决。


推荐阅读