From 8f9bf91056367f14a9ac2f3981ddbfae7e492bfb Mon Sep 17 00:00:00 2001 From: krawieck Date: Fri, 4 Sep 2020 11:04:10 +0200 Subject: [PATCH] Turn bio into IIFE --- lib/widgets/user_profile.dart | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/widgets/user_profile.dart b/lib/widgets/user_profile.dart index 216058d..30d0b58 100644 --- a/lib/widgets/user_profile.dart +++ b/lib/widgets/user_profile.dart @@ -29,25 +29,25 @@ class UserProfile extends HookWidget { var userViewSnap = useFuture(_userView, preserveState: false); - Widget bio; - - if (userViewSnap.hasData) { - if (userViewSnap.data.bio != null) { - bio = Padding( - padding: const EdgeInsets.all(10), - child: Text(userViewSnap.data.bio), - ); + Widget bio = () { + if (userViewSnap.hasData) { + if (userViewSnap.data.bio != null) { + return Padding( + padding: const EdgeInsets.all(10), + child: Text(userViewSnap.data.bio), + ); + } else { + return Center( + child: Text( + 'no bio', + style: const TextStyle(fontStyle: FontStyle.italic), + ), + ); + } } else { - bio = Center( - child: Text( - 'no bio', - style: const TextStyle(fontStyle: FontStyle.italic), - ), - ); + return Center(child: CircularProgressIndicator()); } - } else { - bio = Center(child: CircularProgressIndicator()); - } + }(); Widget tabs() => DefaultTabController( length: 3,