main.dart 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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(
  54. Padding(
  55. padding: EdgeInsets.all(10.0),
  56. child: Text("Row $i"),
  57. )
  58. );
  59. }
  60. return widgets;
  61. }
  62. @override
  63. Widget build(BuildContext context) {
  64. return GestureDetector(
  65. onTap: () {
  66. FocusScope.of(context).requestFocus(blankNode);
  67. },
  68. child: Scaffold(
  69. appBar: AppBar(
  70. title: Text(widget.title),
  71. ),
  72. body: SafeArea(
  73. child: Column(
  74. mainAxisAlignment: MainAxisAlignment.start,
  75. children: <Widget>[
  76. Container(
  77. color: JXColors.kF0F0F0,
  78. alignment: Alignment.center,
  79. padding: EdgeInsets.fromLTRB(12.0, 4.0, 12.0, 4.0),
  80. height: 50.0,
  81. child: Row(children: <Widget>[
  82. Container(
  83. width: 44.0,
  84. child: Icon(
  85. Icons.search,
  86. size: 24.0,
  87. )),
  88. Expanded(
  89. child: TextField(
  90. focusNode: blankNode,
  91. obscureText: false,
  92. cursorColor: JXColors.k1F2529,
  93. decoration: InputDecoration(
  94. border: InputBorder.none,
  95. hintText: '快速筛选',
  96. labelStyle: TextStyle(
  97. color: JXColors.k2E3032,
  98. fontSize: 18,
  99. ),
  100. ),
  101. onSubmitted: (value) {
  102. setState(() {
  103. _searchText = value;
  104. });
  105. filterListView();
  106. },
  107. ),
  108. ),
  109. ])),
  110. Expanded(
  111. flex: 1,
  112. child: Container(
  113. color: JXColors.kF0F0F0,
  114. child: ListView(children: theCellData()),
  115. )),
  116. Container(
  117. color: JXColors.kF0F0F0,
  118. height: 44.0,
  119. child: Row(
  120. children: <Widget>[
  121. Expanded(
  122. child: FlatButton(
  123. onPressed: () {
  124. print('新建会员');
  125. },
  126. padding: EdgeInsets.all(0),
  127. color: JXColors.kFFFFFF,
  128. textColor: JXColors.k1F2529,
  129. child: const Text('新建会员',
  130. style: TextStyle(fontSize: 14)),
  131. ),
  132. ),
  133. Expanded(
  134. child: FlatButton(
  135. onPressed: () {
  136. print('会员列表');
  137. },
  138. padding: EdgeInsets.all(0),
  139. color: JXColors.k1F2529,
  140. textColor: JXColors.kFFFFFF,
  141. child: const Text('会员列表',
  142. style: TextStyle(fontSize: 14)),
  143. ),
  144. ),
  145. ],
  146. ),
  147. ),
  148. ],
  149. ),
  150. ),
  151. ));
  152. }
  153. }