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

Commit 5764f26

Browse files
committed
replace empty container with collection operators
1 parent f24f8a6 commit 5764f26

File tree

3 files changed

+46
-48
lines changed

3 files changed

+46
-48
lines changed

flutter-app/lib/label_samples_grid.dart

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,22 @@ class ListLabelSamples extends StatelessWidget {
4545
child: new Hero(
4646
tag: AppBar,
4747
child: new AppBar(
48-
leading: const BackButton(),
49-
title: new Text('${labelName.toUpperCase()}'),
50-
actions: !isOwner
51-
? [Container()]
52-
: [
53-
IconButton(
54-
icon: Icon(Icons.delete_forever),
55-
onPressed: () {
56-
Firestore.instance
57-
.collection('labels')
58-
.document(labelKey)
59-
.delete();
60-
Navigator.pop(context);
61-
},
62-
),
63-
]),
48+
leading: const BackButton(),
49+
title: new Text('${labelName.toUpperCase()}'),
50+
actions: [
51+
if (isOwner)
52+
IconButton(
53+
icon: Icon(Icons.delete_forever),
54+
onPressed: () {
55+
Firestore.instance
56+
.collection('labels')
57+
.document(labelKey)
58+
.delete();
59+
Navigator.pop(context);
60+
},
61+
),
62+
],
63+
),
6464
),
6565
preferredSize: new AppBar().preferredSize,
6666
),
@@ -227,16 +227,16 @@ class ImageViewerDialog extends StatelessWidget {
227227
backgroundColor: Colors.black,
228228
contentPadding: EdgeInsets.all(0),
229229
children: <Widget>[
230-
new Container(
231-
decoration: BoxDecoration(color: Colors.black),
230+
Container(
231+
decoration: const BoxDecoration(color: Colors.black),
232232
child: imageUrl.isNotEmpty
233233
? FadeInImage.memoryNetwork(
234234
fadeInDuration: const Duration(milliseconds: 200),
235235
placeholder: kTransparentImage,
236236
image: imageUrl,
237237
fit: BoxFit.fitWidth,
238238
)
239-
: Icon(Icons.image, size: 200, color: Colors.black12),
239+
: const Icon(Icons.image, size: 200, color: Colors.black12),
240240
),
241241
],
242242
);

flutter-app/lib/labelscreen.dart

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ class _ListLabelsScreenState extends State<ListLabelsScreen> {
293293
builder: (BuildContext context) => LabelsHelpDialog());
294294
},
295295
),
296-
isOwner ? buildPopupMenu() : Container(),
296+
if (isOwner) buildPopupMenu(),
297297
],
298298
),
299299
),
@@ -495,22 +495,20 @@ class LabelEntry extends StatelessWidget {
495495
crossAxisAlignment: CrossAxisAlignment.center,
496496
children: <Widget>[
497497
new Text(labelName),
498-
_canEdit(model)
499-
? new Row(
500-
children: [
501-
Chip(
502-
avatar: CircleAvatar(
503-
backgroundColor: Colors.grey.shade800,
504-
child: Text('$totalImages'),
505-
),
506-
label:
507-
Text(totalImages == 1 ? 'image' : 'images'),
508-
backgroundColor: Colors.white24,
509-
),
510-
const Icon(Icons.navigate_next),
511-
],
512-
)
513-
: Container(),
498+
if (_canEdit(model))
499+
new Row(
500+
children: [
501+
Chip(
502+
avatar: CircleAvatar(
503+
backgroundColor: Colors.grey.shade800,
504+
child: Text('$totalImages'),
505+
),
506+
label: Text(totalImages == 1 ? 'image' : 'images'),
507+
backgroundColor: Colors.white24,
508+
),
509+
const Icon(Icons.navigate_next),
510+
],
511+
),
514512
],
515513
)),
516514
),

flutter-app/lib/main.dart

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -112,18 +112,18 @@ class _MyHomePageState extends State<MyHomePage> {
112112
appBar: new AppBar(
113113
title: new Text("Datasets"),
114114
actions: <Widget>[
115-
model.isLoggedIn()
116-
? Container()
117-
: IconButton(
118-
onPressed: () {
119-
model
120-
.beginSignIn()
121-
.then((user) => model.setLoggedInUser(user))
122-
.catchError((e) => print(e));
123-
},
124-
icon: Icon(
125-
Icons.person_outline,
126-
)),
115+
if (!model.isLoggedIn())
116+
IconButton(
117+
onPressed: () {
118+
model
119+
.beginSignIn()
120+
.then((user) => model.setLoggedInUser(user))
121+
.catchError((e) => print(e));
122+
},
123+
icon: Icon(
124+
Icons.person_outline,
125+
),
126+
),
127127
model.isLoggedIn()
128128
? PopupMenuButton<MainAction>(
129129
onSelected: (MainAction action) {

0 commit comments

Comments
 (0)