我正在尝试创建一个类,如果您单击一个按钮,该类将会增加,然后再次单击将其缩小。但动画不起作用
这就是我所拥有的
import 'package:flutter/material.dart';
import 'package:flutter_button_collection/flutter_button_collection.dart';
class AnimatedShadowButton extends StatefulWidget {
final double height;
final double width;
final double finalHeight;
final double finalWidth;
const AnimatedShadowButton(
{Key key, this.height, this.width, this.finalHeight, this.finalWidth})
: assert(height < finalHeight),
assert(width < finalWidth),
super(key: key);
@override
_AnimatedShadowButtonState createState() => _AnimatedShadowButtonState();
}
class _AnimatedShadowButtonState extends State<AnimatedShadowButton> {
double buttonHeight;
double buttonWidth;
void aniButo() {
setState(() {
buttonHeight = widget.height <= widget.finalHeight
? widget.finalHeight
: widget.height;
buttonWidth =
widget.width <= widget.finalWidth ? widget.finalWidth : widget.width;
});
}
Widget build(BuildContext context) {
return AnimatedContainer(
duration: Duration(milliseconds: 300),
curve: Curves.easeInBack,
width: buttonWidth,
height: buttonHeight,
child: AVLButton(
onPressed: () {
aniButo();
},
child: Text("This is a text"),
elevation: 30.0,
),
);
}
}
如果我提供了buttonHeight
和buttonWidth
的值,并且一切都是静态的,那么它可以工作,但是我希望能够像这样使用它
AnimatedShadowButton(
height: 60.0,
width: 100.0,
finalHeight: 90.0,
finalWidth: 150.0,
),
答案 0 :(得分:2)
我认为您必须更改Private Sub SimpleButton1_Click(sender As Object, e As EventArgs) Handles SimpleButton1.Click
Try
If Not qry.Contains("JOIN") Then
Dim builder As New OleDbCommandBuilder(adpt)
adpt.SelectCommand = New OleDbCommand(qry, con)
adpt.UpdateCommand = builder.GetUpdateCommand()
adpt.Update(dataTable)
Else
'TODO : Update GridView Without using QueryBuilder(Dynamically)
End If
Catch ex As Exception
End Try
con.Close()
End Sub
方法。像这样:
aniButo
UPD
在void aniButo() {
setState(() {
buttonHeight = buttonHeight == widget.height
? widget.finalHeight
: widget.height;
buttonWidth = buttonWidth == widget.width
? widget.finalWidth
: widget.width;
});
}
内添加_AnimatedShadowButtonState
方法
initState