Skip to content

Commit e77c208

Browse files
Modified the samples as per new API structure.
1 parent 15db356 commit e77c208

File tree

1 file changed

+34
-26
lines changed

1 file changed

+34
-26
lines changed

lib/main.dart

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -47,63 +47,70 @@ class _MyHomePageState extends State<MyHomePage> {
4747
columnName: 'id',
4848
label: Container(
4949
padding: const EdgeInsets.symmetric(horizontal: 16.0),
50-
alignment: Alignment.center,
50+
alignment: Alignment.centerRight,
5151
child: Text(
5252
'ID',
5353
))),
5454
GridTextColumn(
5555
columnName: 'name',
5656
label: Container(
5757
padding: const EdgeInsets.symmetric(horizontal: 16.0),
58-
alignment: Alignment.center,
59-
child: Text('Name'))),
58+
alignment: Alignment.centerLeft,
59+
child: Text(
60+
'Name',
61+
))),
6062
GridTextColumn(
61-
columnName: 'designation',
63+
columnName: 'city',
6264
width: 110,
6365
label: Container(
6466
padding: const EdgeInsets.symmetric(horizontal: 16.0),
65-
alignment: Alignment.center,
67+
alignment: Alignment.centerLeft,
6668
child: Text(
67-
'Designation',
69+
'City',
6870
overflow: TextOverflow.ellipsis,
6971
))),
7072
GridTextColumn(
71-
columnName: 'salary',
73+
columnName: 'Freight',
7274
label: Container(
7375
padding: const EdgeInsets.symmetric(horizontal: 16.0),
74-
alignment: Alignment.center,
75-
child: Text('Salary'))),
76+
alignment: Alignment.centerRight,
77+
child: Text('Freight'))),
7678
],
7779
),
7880
);
7981
}
8082

8183
List<Employee> populateData() {
8284
return <Employee>[
83-
Employee(10001, 'James', 'Project Lead', 20000),
84-
Employee(10002, 'Kathryn', 'Manager', 30000),
85-
Employee(10003, 'Lara', 'Developer', 15000),
86-
Employee(10004, 'Michael', 'Designer', 15000),
87-
Employee(10005, 'Martin', 'Developer', 15000),
88-
Employee(10006, 'Newberry', 'Developer', 15000),
89-
Employee(10007, 'Balnc', 'Developer', 15000),
90-
Employee(10008, 'Perry', 'Developer', 15000),
91-
Employee(10009, 'Gable', 'Developer', 15000),
92-
Employee(10010, 'Grimes', 'Developer', 15000),
85+
Employee(10001, 'James', 'Bruxelles', 20000),
86+
Employee(10002, 'Kathryn', 'Rosario', 30000),
87+
Employee(10003, 'Lara', 'Recife', 15000),
88+
Employee(10004, 'Michael', 'Graz', 15000),
89+
Employee(10005, 'Martin', 'Montreal', 15000),
90+
Employee(10006, 'Newberry', 'Tsawassen', 15000),
91+
Employee(10007, 'Balnc', 'Campinas', 15000),
92+
Employee(10008, 'Perry', 'Resende', 15000),
93+
Employee(10009, 'Gable', 'Resende', 15000),
94+
Employee(10010, 'Grimes', 'Recife', 15000),
95+
Employee(10011, 'Newberry', 'Tsawassen', 15000),
96+
Employee(10012, 'Balnc', 'Campinas', 15000),
97+
Employee(10013, 'Perry', 'Resende', 15000),
98+
Employee(10014, 'Gable', 'Resende', 15000),
99+
Employee(10015, 'Grimes', 'Recife', 15000),
93100
];
94101
}
95102
}
96103

97104
class Employee {
98-
Employee(this.id, this.name, this.designation, this.salary);
105+
Employee(this.id, this.name, this.city, this.freight);
99106

100107
final int id;
101108

102109
final String name;
103110

104-
final String designation;
111+
final String city;
105112

106-
final int salary;
113+
final int freight;
107114
}
108115

109116
class EmployeeDataSource extends DataGridSource {
@@ -112,9 +119,8 @@ class EmployeeDataSource extends DataGridSource {
112119
.map<DataGridRow>((e) => DataGridRow(cells: [
113120
DataGridCell<int>(columnName: 'id', value: e.id),
114121
DataGridCell<String>(columnName: 'name', value: e.name),
115-
DataGridCell<String>(
116-
columnName: 'designation', value: e.designation),
117-
DataGridCell<int>(columnName: 'salary', value: e.salary),
122+
DataGridCell<String>(columnName: 'city', value: e.city),
123+
DataGridCell<int>(columnName: 'freight', value: e.freight),
118124
]))
119125
.toList();
120126
}
@@ -162,7 +168,9 @@ class EmployeeDataSource extends DataGridSource {
162168
return DataGridRowAdapter(
163169
cells: row.getCells().map<Widget>((e) {
164170
return Container(
165-
alignment: Alignment.center,
171+
alignment: ['id', 'freight'].contains(e.columnName)
172+
? Alignment.centerRight
173+
: Alignment.centerLeft,
166174
padding: const EdgeInsets.symmetric(horizontal: 16.0),
167175
child: Text(e.value.toString()),
168176
);

0 commit comments

Comments
 (0)