Search.dart 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. class Search extends StatefulWidget {
  4. const Search({Key? key}) : super(key: key);
  5. @override
  6. State<Search> createState() => _SearchState();
  7. }
  8. class _SearchState extends State<Search> {
  9. @override
  10. Widget build(BuildContext context) {
  11. return LayoutBuilder(
  12. builder: (BuildContext context, BoxConstraints constraints) {
  13. return Column(
  14. children: [
  15. Container(
  16. decoration: BoxDecoration(color: Colors.white),
  17. width: 345.w,
  18. height: 34,
  19. alignment: Alignment.center,
  20. child: TextField(
  21. onChanged: (value) {
  22. print('打一个字我搜索一下$value');
  23. },
  24. onEditingComplete: () {
  25. FocusScope.of(context).requestFocus(FocusNode());
  26. print('点击键盘搜索');
  27. },
  28. style: const TextStyle(
  29. fontSize: 15,
  30. color: Colors.black,
  31. textBaseline: TextBaseline.alphabetic),
  32. decoration: const InputDecoration(
  33. isDense: true,
  34. prefixIcon: Padding(
  35. padding: EdgeInsets.only(left: 0),
  36. child: Icon(
  37. Icons.search,
  38. ),
  39. ),
  40. fillColor: Color(0x30cccccc),
  41. filled: true,
  42. border: OutlineInputBorder(borderSide: BorderSide.none),
  43. contentPadding: EdgeInsets.all(0),
  44. enabledBorder: OutlineInputBorder(
  45. borderSide: BorderSide(color: Color(0x00FF0000)),
  46. borderRadius: BorderRadius.all(Radius.circular(100))),
  47. hintText: '请输入关键字查询',
  48. hintStyle: TextStyle(
  49. textBaseline: TextBaseline.alphabetic, //用于提示文字对齐
  50. ),
  51. ),
  52. ),
  53. ),
  54. ],
  55. );
  56. });
  57. }
  58. }