}
}
class SearchAppBarState extends State {
late FocusNode _focusNode;
///默认不展示控件
bool _offstage = true;
///监听TextField内容变化
final TextEditingController _textEditingController = TextEditingController();
@override
void initState() {
super.initState();
_focusNode = FocusNode();
_textEditingController.addListener(() {
var isVisible = _textEditingController.text.isNotEmpty;
_updateDelIconVisible(isVisible);
});
}
_updateDelIconVisible(bool isVisible) {
setState(() {
_offstage = !isVisible;
});
}
@override
Widget build(BuildContext context) {
return SizedBox(
width: double.infinity,
height: 30,
child: Row(
children: [
Expanded(
flex: 1,
child: Container(
height: double.infinity,
margin: const EdgeInsets.on