Files
2021-04-03 19:41:21 +08:00

69 lines
2.2 KiB
Dart
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:flutter/material.dart';
/// create by 张风捷特烈 on 2020-03-23
/// contact me by email 1981462002@qq.com
/// 说明: 225 相关属性变化时具有动画效果的PhysicalModel组件本质是PhysicalModel和动画结合的产物。可指定阴影、影深、圆角、动画时长、结束回调等属性。
// {
// "widgetId": 225 ,
// "name": 'AnimatedPhysicalModel基本使用',
// "priority": 1,
// "subtitle":
// "【color】 : 背景色 【Color】\n"
// "【duration】 : 动画时长 【Duration】\n"
// "【onEnd】 : 动画结束回调 【Function()】\n"
// "【curve】 : 动画曲线 【Duration】\n"
// "【shape】 : 形状 【BoxShape】\n"
// "【elevation】 : 影深 【double】\n"
// "【borderRadius】 : 圆角 【BorderRadius】\n"
// "【shadowColor】 : 阴影色 【Color】\n"
// "【child】 : 子组件 【Widget】",
// }
class AnimatedPhysicalModelDemo extends StatefulWidget {
@override
_AnimatedPhysicalModelDemoState createState() =>
_AnimatedPhysicalModelDemoState();
}
class _AnimatedPhysicalModelDemoState extends State<AnimatedPhysicalModelDemo> {
bool flag = false;
@override
Widget build(BuildContext context) {
return Column(
children: <Widget>[
_buildSwitch(),
Container(
width: 150,
height: 150,
child: AnimatedPhysicalModel(
duration: Duration(seconds: 2),
curve: Curves.fastOutSlowIn,
shadowColor: flag?Colors.orange:Colors.purple,
elevation: flag?10:5,
child: Image.asset(
'assets/images/caver.webp',
fit: BoxFit.cover,
),
borderRadius: BorderRadius.all(Radius.circular(flag? 10:75)),
clipBehavior: Clip.hardEdge,
shape: BoxShape.rectangle,
color: Colors.deepPurpleAccent,
onEnd: () {
print('----onEnd---');
},
),
),
],
);
}
Widget _buildSwitch() {
return Switch(
value: flag,
onChanged: (v) {
setState(() {
flag = v;
});
});
}
}