forked from lxm_flutter/FlutterUnit
优化 隐式组件使用
This commit is contained in:
@@ -36,12 +36,8 @@ class _CustomFadeTransitionState extends State<CustomFadeTransition>
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_ctrl.reset();
|
||||
_ctrl.forward();
|
||||
});
|
||||
},
|
||||
onTap: () => _ctrl.forward(from: 0),
|
||||
|
||||
child: Container(
|
||||
color: Colors.grey.withAlpha(22),
|
||||
width: 100,
|
||||
|
||||
@@ -36,12 +36,7 @@ class _CustomAlignTransitionState extends State<CustomAlignTransition>
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_ctrl.reset();
|
||||
_ctrl.forward();
|
||||
});
|
||||
},
|
||||
onTap: () => _ctrl.forward(from: 0),
|
||||
child: Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
color: Colors.grey.withAlpha(33),
|
||||
|
||||
@@ -39,12 +39,7 @@ class _CustomDecoratedBoxTransitionState
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_ctrl.reset();
|
||||
_ctrl.forward();
|
||||
});
|
||||
},
|
||||
onTap: () => _ctrl.forward(from: 0),
|
||||
child: Container(
|
||||
width: 200,
|
||||
height: 100,
|
||||
|
||||
@@ -37,12 +37,7 @@ class _CustomPositionedTransitionState extends State<CustomPositionedTransition>
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_ctrl.reset();
|
||||
_ctrl.forward();
|
||||
});
|
||||
},
|
||||
onTap: () => _ctrl.forward(from: 0),
|
||||
child: Container(
|
||||
color: Colors.grey.withAlpha(33),
|
||||
width: 200,
|
||||
|
||||
@@ -40,12 +40,7 @@ class _CustomRelativePositionedTransitionState
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_ctrl.reset();
|
||||
_ctrl.forward();
|
||||
});
|
||||
},
|
||||
onTap: () => _ctrl.forward(from: 0),
|
||||
child: Container(
|
||||
color: Colors.grey.withAlpha(33),
|
||||
width: 200,
|
||||
|
||||
@@ -23,7 +23,7 @@ class _CustomRotationTransitionState extends State<CustomRotationTransition> wit
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_ctrl= AnimationController(vsync: this,duration: Duration(seconds: 2));
|
||||
_ctrl= AnimationController(vsync: this,duration: const Duration(seconds: 2));
|
||||
_ctrl.forward();
|
||||
super.initState();
|
||||
}
|
||||
@@ -37,19 +37,14 @@ class _CustomRotationTransitionState extends State<CustomRotationTransition> wit
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_ctrl.reset();
|
||||
_ctrl.forward();
|
||||
});
|
||||
},
|
||||
onTap: () => _ctrl.forward(from: 0),
|
||||
child: Container(
|
||||
color: Colors.grey.withAlpha(22),
|
||||
width: 100,
|
||||
height: 100,
|
||||
child: RotationTransition(
|
||||
turns: CurvedAnimation(parent: _ctrl, curve: Curves.linear),
|
||||
child: Icon(Icons.android,color: Colors.green,size: 60),
|
||||
child: const Icon(Icons.camera_outlined,color: Colors.green,size: 60),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -35,12 +35,7 @@ class _CustomScaleTransitionState extends State<CustomScaleTransition>
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_ctrl.reset();
|
||||
_ctrl.forward();
|
||||
});
|
||||
},
|
||||
onTap: () => _ctrl.forward(from: 0),
|
||||
child: Container(
|
||||
color: Colors.grey.withAlpha(22),
|
||||
width: 100,
|
||||
|
||||
@@ -37,12 +37,7 @@ class _CustomSizeTransitionState extends State<CustomSizeTransition>
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_ctrl.reset();
|
||||
_ctrl.forward();
|
||||
});
|
||||
},
|
||||
onTap: () => _ctrl.forward(from: 0),
|
||||
child: Wrap(
|
||||
runSpacing: 20,
|
||||
children: <Widget>[
|
||||
|
||||
@@ -37,12 +37,7 @@ class _CustomSlideTransitionState extends State<CustomSlideTransition>
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_ctrl.reset();
|
||||
_ctrl.forward();
|
||||
});
|
||||
},
|
||||
onTap: () => _ctrl.forward(from: 0),
|
||||
child: Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
color: Colors.grey.withAlpha(33),
|
||||
|
||||
@@ -42,12 +42,7 @@ class _CustomAnimatedIconState extends State<CustomAnimatedIcon>
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_ctrl.reset();
|
||||
_ctrl.forward();
|
||||
});
|
||||
},
|
||||
onTap: () => _ctrl.forward(from: 0),
|
||||
child: Wrap(
|
||||
runSpacing: 30,
|
||||
children: _buildChildren(),
|
||||
|
||||
Reference in New Issue
Block a user