Skip to content
This repository was archived by the owner on May 27, 2025. It is now read-only.

Commit ba649d5

Browse files
committed
new dart 2.3.0 features to clean up collections
1 parent aad4036 commit ba649d5

File tree

3 files changed

+25
-32
lines changed

3 files changed

+25
-32
lines changed

flutter-app/lib/labelscreen.dart

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -347,19 +347,6 @@ class _ListLabelsScreenState extends State<ListLabelsScreen> {
347347
.map((document) => document["total_images"] as int)
348348
.any((imageCount) => imageCount < 10);
349349

350-
final List<Widget> messages = [
351-
new OperationProgress(dataset: widget.dataset)
352-
];
353-
354-
// If there are less than 10 images in the dataset, show a warning
355-
if (invalidLabels) {
356-
messages.add(new DismissibleMessageWidget(
357-
msg:
358-
"At least 10 images per label are required to start training",
359-
color: Colors.red[400],
360-
));
361-
}
362-
363350
final labelListView = new ListView(
364351
children: snapshot.data.documents
365352
.map((document) => new Container(
@@ -375,6 +362,17 @@ class _ListLabelsScreenState extends State<ListLabelsScreen> {
375362
)))
376363
.toList());
377364

365+
final List<Widget> messages = [
366+
new OperationProgress(dataset: widget.dataset),
367+
if (invalidLabels)
368+
// If there are less than 10 images in the dataset, show a warning
369+
new DismissibleMessageWidget(
370+
msg:
371+
"At least 10 images per label are required to start training",
372+
color: Colors.red[400],
373+
),
374+
];
375+
378376
if (isOwner || isCollaborator) {
379377
return Column(
380378
children: messages..add(new Expanded(child: labelListView)));

flutter-app/lib/operations_page.dart

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ class OperationsList extends StatelessWidget {
6868
);
6969
}
7070

71+
ListTile header(String text) => ListTile(
72+
key: Key(text),
73+
title: Text(text.toUpperCase(),
74+
style: TextStyle(fontSize: 16, color: Colors.black54)));
75+
7176
@override
7277
Widget build(BuildContext context) {
7378
return new StreamBuilder(
@@ -97,24 +102,14 @@ class OperationsList extends StatelessWidget {
97102
.where((document) => document["done"])
98103
.map(_toListTile);
99104

100-
final List<Widget> listTiles = [];
101-
if (pendingOps.isNotEmpty) {
102-
listTiles.add(ListTile(
103-
key: Key("in-progress"),
104-
title: Text("IN PROGRESS",
105-
style: TextStyle(fontSize: 16, color: Colors.black54)),
106-
));
107-
listTiles.addAll(pendingOps);
108-
}
109-
if (completedOps.isNotEmpty) {
110-
listTiles.add(ListTile(
111-
key: Key("completed"),
112-
title: Text("COMPLETED",
113-
style: TextStyle(fontSize: 16, color: Colors.black54)),
114-
));
115-
listTiles.addAll(completedOps);
116-
}
117-
return ListView(children: listTiles);
105+
return ListView(
106+
children: [
107+
if (pendingOps.isNotEmpty) header("in progress"),
108+
if (pendingOps.isNotEmpty) ...pendingOps,
109+
if (completedOps.isNotEmpty) header("completed"),
110+
if (completedOps.isNotEmpty) ...completedOps,
111+
],
112+
);
118113
}
119114
});
120115
}

flutter-app/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ description: Crowdsource data for ML models
2424
version: 1.0.4
2525

2626
environment:
27-
sdk: ">=2.0.0-dev.68.0 <3.0.0"
27+
sdk: ">=2.2.2 <3.0.0"
2828

2929
dependencies:
3030
flutter:

0 commit comments

Comments
 (0)