@@ -9,8 +9,13 @@ class Cells extends StatelessWidget {
99 ///插入分隔线
1010 _insertDivider (BuildContext context) {
1111 List <Widget > newChildren = children;
12- for (int i = children.length - 1 ; i > 0 ; i-- ) {
13- newChildren.insert (i, Divider (height: 1 / MediaQuery .of (context).devicePixelRatio,indent: 15 ,));
12+ for (int i = children.length - 1 ; i > 0 ; i-- ) {
13+ newChildren.insert (
14+ i,
15+ Divider (
16+ height: 1 / MediaQuery .of (context).devicePixelRatio,
17+ indent: 15 ,
18+ ));
1419 }
1520 return newChildren;
1621 }
@@ -32,8 +37,65 @@ class Cells extends StatelessWidget {
3237 }
3338}
3439
40+ enum KeyBoardType { text, number, password }
41+
42+ class CellInput extends StatelessWidget {
43+ CellInput ({Key key, this .placeholder, this .label = "label" , this .onChanged, this .keyBoardType = KeyBoardType .text}) : super (key: key);
44+ final String placeholder;
45+ final String label;
46+ final ValueChanged <String > onChanged;
47+ final KeyBoardType keyBoardType;
48+
49+ _handleChanged (value) {
50+ if (onChanged != null ) onChanged (value);
51+ }
52+
53+ TextInputType _getKeyBorderType () {
54+
55+ Map <KeyBoardType , TextInputType > map = const {
56+ KeyBoardType .text: TextInputType .text,
57+ KeyBoardType .number: TextInputType .number,
58+ KeyBoardType .password: TextInputType .text
59+ };
60+ return map[keyBoardType];
61+ }
62+
63+ @override
64+ Widget build (BuildContext context) {
65+ return Container (
66+ padding: const EdgeInsets .symmetric (vertical: 10 , horizontal: 15 ),
67+ child: Row (
68+ crossAxisAlignment: CrossAxisAlignment .center,
69+ children: < Widget > [
70+ SizedBox (
71+ child: Text (
72+ label,
73+ style: TextStyle (
74+ fontSize: 17 ,
75+ ),
76+ ),
77+ width: 105 ,
78+ ),
79+ Expanded (
80+ child: TextField (
81+ obscureText: keyBoardType == KeyBoardType .password,
82+ onChanged: _handleChanged,
83+ keyboardType: _getKeyBorderType (),
84+ style: TextStyle (
85+ fontSize: 17 ,
86+ color: Colors .black,
87+ ),
88+ decoration: InputDecoration (border: InputBorder .none, hintText: placeholder, contentPadding: const EdgeInsets .all (0 )),
89+ ),
90+ ),
91+ ],
92+ ),
93+ );
94+ }
95+ }
96+
3597class Cell extends StatefulWidget {
36- Cell ({this .title = "" , Key key, this .secondaryText = "" , this .banner, this .access = false , this .onPressed,this .radio,this .checkBox}) : super (key: key);
98+ Cell ({this .title = "" , Key key, this .secondaryText = "" , this .banner, this .access = false , this .onPressed, this .radio, this .checkBox}) : super (key: key);
3799 final String title;
38100 final String secondaryText;
39101 final Widget banner;
0 commit comments