From 26b1f13c036feb5b8a9dad6eb303b3a1257315c7 Mon Sep 17 00:00:00 2001 From: Elias Projahn Date: Sun, 5 Apr 2020 20:15:20 +0200 Subject: [PATCH] Work tile: Refactor and add leading widget --- lib/widgets/work_tile.dart | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/lib/widgets/work_tile.dart b/lib/widgets/work_tile.dart index 386caba..3e3dd39 100644 --- a/lib/widgets/work_tile.dart +++ b/lib/widgets/work_tile.dart @@ -4,10 +4,12 @@ import '../backend.dart'; import '../database.dart'; class WorkTile extends StatelessWidget { + final Widget leading; final int workId; final void Function() onTap; WorkTile({ + this.leading, this.workId, this.onTap, }); @@ -24,21 +26,17 @@ class WorkTile extends StatelessWidget { return StreamBuilder>( stream: backend.db.composersByWork(workId).watch(), builder: (context, snapshot) { - if (snapshot.hasData) { - return ListTile( - title: Text(titleText), - subtitle: Text(snapshot.data + final subtitleText = snapshot.hasData + ? snapshot.data .map((p) => '${p.firstName} ${p.lastName}') - .join(', ')), - onTap: onTap ?? null, - ); - } else { - return ListTile( - title: Text(titleText), - subtitle: Text('...'), - onTap: onTap ?? null, - ); - } + .join(', ') + : '...'; + return ListTile( + leading: leading, + title: Text(titleText), + subtitle: Text(subtitleText), + onTap: onTap ?? null, + ); }, ); },