main.dart 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. import 'package:flutter/material.dart';
  2. import 'package:taskservice/Common/JXColors.dart';
  3. void main() {
  4. runApp(MyApp());
  5. }
  6. class MyApp extends StatelessWidget {
  7. // This widget is the root of your application.
  8. @override
  9. Widget build(BuildContext context) {
  10. return MaterialApp(
  11. title: 'JXZS',
  12. theme: ThemeData(
  13. // This is the theme of your application.
  14. //
  15. // Try running your application with "flutter run". You'll see the
  16. // application has a blue toolbar. Then, without quitting the app, try
  17. // changing the primarySwatch below to Colors.green and then invoke
  18. // "hot reload" (press "r" in the console where you ran "flutter run",
  19. // or simply save your changes to "hot reload" in a Flutter IDE).
  20. // Notice that the counter didn't reset back to zero; the application
  21. // is not restarted.
  22. primarySwatch: Colors.blue,
  23. // This makes the visual density adapt to the platform that you ru
  24. // the app on. For desktop platforms, the controls will be smaller and
  25. // closer together (more dense) than on mobile platforms.
  26. visualDensity: VisualDensity.adaptivePlatformDensity,
  27. ),
  28. home: MyHomePage(title: 'JXZS'),
  29. );
  30. }
  31. }
  32. class MyHomePage extends StatefulWidget {
  33. MyHomePage({Key key, this.title}) : super(key: key);
  34. final String title;
  35. @override
  36. _MyHomePageState createState() => _MyHomePageState();
  37. }
  38. class _MyHomePageState extends State<MyHomePage> {
  39. // 参数
  40. /*空白区域键盘消失控制*/
  41. FocusNode blankNode = FocusNode();
  42. /*搜索值*/
  43. String _searchText;
  44. /*筛选列表数据*/
  45. void filterListView() {
  46. print('筛选:$_searchText');
  47. String text = _searchText;
  48. }
  49. /*显示列表*/
  50. List<Widget> theCellData() {
  51. List<Widget> widgets = [];
  52. for (int i = 0; i < 100; i++) {
  53. widgets.add(Padding(padding: EdgeInsets.all(10.0), child: Text("Row $i")));
  54. }
  55. return widgets;
  56. }
  57. @override
  58. Widget build(BuildContext context) {
  59. return GestureDetector(
  60. onTap: () {
  61. FocusScope.of(context).requestFocus(blankNode);
  62. },
  63. child: Scaffold(
  64. appBar: AppBar(
  65. title: Text(widget.title),
  66. ),
  67. body: SafeArea(
  68. child: Column(
  69. mainAxisAlignment: MainAxisAlignment.start,
  70. children: <Widget>[
  71. Container(
  72. color: JXColors.kF0F0F0,
  73. alignment: Alignment.center,
  74. padding: EdgeInsets.fromLTRB(12.0, 4.0, 12.0, 4.0),
  75. height: 50.0,
  76. child: Row(children: <Widget>[
  77. Container(
  78. width: 44.0,
  79. child: Icon(
  80. Icons.search,
  81. size: 24.0,
  82. )),
  83. Expanded(
  84. child: TextField(
  85. obscureText: false,
  86. cursorColor: JXColors.k1F2529,
  87. decoration: InputDecoration(
  88. border: InputBorder.none,
  89. hintText: '快速筛选',
  90. labelStyle: TextStyle(
  91. color: JXColors.k2E3032,
  92. fontSize: 18,
  93. ),
  94. ),
  95. onSubmitted: (value) {
  96. setState(() {
  97. _searchText = value;
  98. });
  99. filterListView();
  100. },
  101. onEditingComplete: () {
  102. /*键盘消失*/
  103. FocusScope.of(context).requestFocus(blankNode);
  104. },
  105. ),
  106. ),
  107. ])),
  108. Expanded(
  109. flex: 1,
  110. child: Container(
  111. color: Colors.lightBlue,
  112. child: ListView(children: theCellData()),
  113. )),
  114. Container(
  115. color: Colors.red,
  116. height: 44.0,
  117. child: Row(
  118. children: <Widget>[
  119. Expanded(
  120. child: FlatButton(
  121. onPressed: () {
  122. print('新建会员');
  123. },
  124. padding: EdgeInsets.all(0),
  125. color: JXColors.kFFFFFF,
  126. textColor: JXColors.k1F2529,
  127. child: const Text('新建会员',
  128. style: TextStyle(fontSize: 14)),
  129. ),
  130. ),
  131. Expanded(
  132. child: FlatButton(
  133. onPressed: () {
  134. print('会员列表');
  135. },
  136. padding: EdgeInsets.all(0),
  137. color: JXColors.k1F2529,
  138. textColor: JXColors.kFFFFFF,
  139. child: const Text('会员列表',
  140. style: TextStyle(fontSize: 14)),
  141. ),
  142. ),
  143. ],
  144. ),
  145. ),
  146. ],
  147. ),
  148. ),
  149. ));
  150. }
  151. }