12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- import 'package:flutter/material.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
-
- class Search extends StatefulWidget {
- const Search({Key? key}) : super(key: key);
-
- @override
- State<Search> createState() => _SearchState();
- }
-
- class _SearchState extends State<Search> {
- @override
- Widget build(BuildContext context) {
- return LayoutBuilder(
- builder: (BuildContext context, BoxConstraints constraints) {
- return Column(
- children: [
- Container(
- decoration: BoxDecoration(color: Colors.white),
- width: 345.w,
- height: 34,
- alignment: Alignment.center,
- child: TextField(
- onChanged: (value) {
- print('打一个字我搜索一下$value');
- },
- onEditingComplete: () {
- FocusScope.of(context).requestFocus(FocusNode());
- print('点击键盘搜索');
- },
- style: const TextStyle(
- fontSize: 15,
- color: Colors.black,
- textBaseline: TextBaseline.alphabetic),
- decoration: const InputDecoration(
- isDense: true,
- prefixIcon: Padding(
- padding: EdgeInsets.only(left: 0),
- child: Icon(
- Icons.search,
- ),
- ),
- fillColor: Color(0x30cccccc),
- filled: true,
- border: OutlineInputBorder(borderSide: BorderSide.none),
- contentPadding: EdgeInsets.all(0),
- enabledBorder: OutlineInputBorder(
- borderSide: BorderSide(color: Color(0x00FF0000)),
- borderRadius: BorderRadius.all(Radius.circular(100))),
- hintText: '请输入关键字查询',
- hintStyle: TextStyle(
- textBaseline: TextBaseline.alphabetic, //用于提示文字对齐
- ),
- ),
- ),
- ),
- ],
- );
- });
- }
- }
|