Flutter:AnimatedPadding动态修改padding

html 复制代码
// 默认top为10,点击后修改为100,此时方块会向下移动
padding: EdgeInsets.fromLTRB(left, top, right, bottom),
js 复制代码
class _MyHomePageState extends State<MyHomePage> {
  bool flag = true;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('标题'),
      ),
      body: AnimatedPadding(
        curve: Curves.easeIn, // 动画属性
        duration: Duration(milliseconds: 500),
        // 默认
        padding: EdgeInsets.fromLTRB(10, flag ?10 : 100, 0, 0),
        child: Container(
          width: 100,
          height: 100,
          color: Colors.red,
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: (){
          flag = !flag;
          setState(() {});
        },
        child: const Icon(Icons.add),
      ),
    );
  }
}


相关推荐
alexhilton6 小时前
使用FunctionGemma进行设备端函数调用
android·kotlin·android jetpack
冬奇Lab9 小时前
InputManagerService:输入事件分发与ANR机制
android·源码阅读
张小潇12 小时前
AOSP15 Input专题InputManager源码分析
android·操作系统
Zsnoin能13 小时前
Flutter仿ios液态玻璃效果
flutter
RdoZam14 小时前
Android-封装基类Activity\Fragment,从0到1记录
android·kotlin
傅里叶18 小时前
iOS相机权限获取
flutter·ios
Haha_bj18 小时前
Flutter—— 本地存储(shared_preferences)
flutter
心之语歌19 小时前
Flutter 存储权限:适配主流系统
flutter
奥陌陌20 小时前
android 打印函数调用堆栈
android
用户9851200358320 小时前
Compose Navigation 3 深度解析(二):基础用法
android·android jetpack