Flutter搜索框-创新互联
在大庆等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供做网站、网站制作 网站设计制作按需制作,公司网站建设,企业网站建设,品牌网站设计,网络营销推广,成都外贸网站制作,大庆网站建设费用合理。
当前题目:Flutter搜索框-创新互联
标题网址:http://pwwzsj.com/article/dhcjgs.html
class SearchBar extends StatefulWidget {
SearchBar({Key? key, this.onChanged}) : super(key: key);
final ValueChanged? onChanged;
@override
_SearchBarState createState() =>_SearchBarState();
}
class _SearchBarState extends State{
final TextEditingController _textEditingController = TextEditingController();
List_models = [];
bool _showClear = false;
void _onChanged(String text) {
if (widget.onChanged != null) {
widget.onChanged!(text);
}
setState(() {
_showClear = text.isNotEmpty;
});
}
@override
Widget build(BuildContext context) {
return Container(
height: 84,
color: Colors.indigoAccent,
child: Column(
children: [
const SizedBox(
height: 40,
),
SizedBox(
height: 44,
child: Row(
children: [
Container(
width: 400,
height: 34,
margin: const EdgeInsets.only(left: 5, right: 5),
padding: const EdgeInsets.only(left: 5, right: 5),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(6.0),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: TextField(
controller: _textEditingController,
cursorColor: Colors.green,
autofocus: true,
onChanged: _onChanged,
style: const TextStyle(
fontSize: 18.0,
color: Colors.black,
fontWeight: FontWeight.w300,
),
decoration: const InputDecoration(
contentPadding: EdgeInsets.only(left: 5,bottom: 10),
border:InputBorder.none,
hintText:'搜索',
),
),
),
if (_showClear) GestureDetector(
child: const Icon(
Icons.cancel,
size: 20,
color: Colors.grey,
),
onTap: () {
_textEditingController.clear();
setState(() {
_onChanged("");
});
},
)
],
),
), //圆角背景
GestureDetector(
child: const Text('取消'),
onTap: () {
},
),
],
),
),
],
),
);
}
}
你是否还在寻找稳定的海外服务器提供商?创新互联www.cdcxhl.cn海外机房具备T级流量清洗系统配攻击溯源,准确流量调度确保服务器高可用性,企业级服务器适合批量采购,新人活动首月15元起,快前往官网查看详情吧
当前题目:Flutter搜索框-创新互联
标题网址:http://pwwzsj.com/article/dhcjgs.html