一个展开按钮,点击时会自己执行旋转180的动画。可指定颜色、大小、边距,接收点击事件。
相关组件
ExpandIcon基本使用
【isExpanded】 : 是否展开 【bool】
【padding】 : 内边距 【EdgeInsetsGeometry】,
【size】 : 图标大小 【double】
【color】 : 不展开时颜色 【Color】
【expandedColor】 : 展开时颜色 【Color】
【onPressed】 : 点击事件 【Function(bool)】
import 'package:flutter/material.dart';class CustomExpandIcon extends StatefulWidget {@override_CustomExpandIconState createState() => _CustomExpandIconState();}class _CustomExpandIconState extends State<CustomExpandIcon> {var _closed = true;@overrideWidget build(BuildContext context) {return ExpandIcon(isExpanded: _closed,padding: EdgeInsets.all(5),size: 30,color: Colors.blue,expandedColor: Colors.orangeAccent,onPressed: (value) => setState(() => _closed = !_closed),);}}
