forked from toly1994328/FlutterUnit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass_gen_field.dart
More file actions
112 lines (104 loc) · 3.08 KB
/
class_gen_field.dart
File metadata and controls
112 lines (104 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import 'package:flutter/material.dart';
import 'package:flutter_unit/code_gen/model/class.dart';
import '../code_gen_page.dart';
import '../model/field.dart';
import 'toly_select.dart';
class ClassGenField extends StatelessWidget {
final Class clazz;
const ClassGenField({Key? key,required this.clazz}) : super(key: key);
final List<String> selectData = const [
"final",
"static",
'static const',
];
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
GenInput(
label: '类名',
// controller: clazz.nameCtrl,
hintText: '输入类名',
),
const SizedBox(
width: 20,
),
Wrap(
spacing: 20,
children: [
GenCheckBox(
label: 'toJson', checked: true,onChanged: (v){},
),
GenCheckBox(
label: 'fromJson', checked: true,onChanged: (v){},
),
GenCheckBox(
label: 'copyWith', checked: true,onChanged: (v){},
),
],
)
],
),
const SizedBox(
height: 20,
),
Expanded(
child: ListView.separated(
itemCount: clazz.fields.length,
separatorBuilder: (_,__)=> const SizedBox(height: 10,),
itemBuilder: (_,index) {
Field field = clazz.fields[index];
return Row(
children: [
GenInput(
label: '类型',
// controller: field.typeCtrl,
hintText: '输入字段类型名',
),
const SizedBox(
width: 20,
),
GenInput(
label: '变量名',
// controller: field.nameCtrl,
hintText: '输入字段变量名',
),
const SizedBox(
width: 20,
),
Wrap(
direction: Axis.vertical,
children: [
Padding(
padding: const EdgeInsets.all(6.0),
child: const Text('修饰',style: TextStyle(fontSize: 12),),
),
TolySelect(
height: 30,
width: 120,
change: (int index){
// field.typeCtrl.text = selectData[index];
},
activeIndex: selectData.indexOf(field.modifier)==-1?0:selectData.indexOf(field.modifier),
data: selectData,
)
],
),
const SizedBox(
width: 20,
),
GenCheckBox(
label: 'nullable', checked: field.nullable,onChanged: (v){},
),
],
);
}),
)
,
],
);
}
}