@@ -31,6 +31,8 @@ class UserProfile extends AbstractPage {
3131}
3232
3333class _UserProfileState extends PageState <UserProfile > {
34+ List <Container > _none = [Container (child: Text ("None." ))];
35+
3436 @override
3537 Widget body (GlobalKey <ScaffoldState > scfKey) {
3638 return Column (
@@ -98,37 +100,44 @@ class _UserProfileState extends PageState<UserProfile> {
98100 }
99101
100102 Container _buildFavSubjects () {
103+ var subjects = widget.userData.favSubjects.isEmpty
104+ ? _none
105+ : widget.userData.favSubjects
106+ .map ((String subj) => Container (
107+ child: StyledText (subj),
108+ padding: EdgeInsets .all (5 ),
109+ margin: EdgeInsets .all (5 ),
110+ decoration: BoxDecoration (
111+ border: Border .all (color: Colors .blue),
112+ borderRadius: BorderRadius .all (Radius .circular (5 )),
113+ ),
114+ ))
115+ .toList ();
116+
101117 return ItemContainer (
102118 title: "Favorite Subjects" ,
103119 color: Colors .lightBlue.withOpacity (0.1 ),
104- items: widget.userData.favSubjects
105- .map ((String subj) => Container (
106- child: StyledText (subj),
107- padding: EdgeInsets .all (5 ),
108- margin: EdgeInsets .all (5 ),
109- decoration: BoxDecoration (
110- border: Border .all (color: Colors .blue),
111- borderRadius: BorderRadius .all (Radius .circular (5 )),
112- ),
113- ))
114- .toList (),
120+ items: subjects,
115121 );
116122 }
117123
118124 Container _buildFavTeachers () {
125+ var teachers = widget.userData.favTeachers.isEmpty
126+ ? _none
127+ : widget.userData.favTeachers
128+ .map ((String subj) => Container (
129+ child: StyledText (subj),
130+ padding: EdgeInsets .all (5 ),
131+ margin: EdgeInsets .all (5 ),
132+ decoration: BoxDecoration (
133+ border: Border .all (color: Colors .grey),
134+ borderRadius: BorderRadius .all (Radius .circular (5 )),
135+ ),
136+ ))
137+ .toList ();
119138 return ItemContainer (
120139 title: "Favorite Teachers" ,
121- items: widget.userData.favTeachers
122- .map ((String subj) => Container (
123- child: StyledText (subj),
124- padding: EdgeInsets .all (5 ),
125- margin: EdgeInsets .all (5 ),
126- decoration: BoxDecoration (
127- border: Border .all (color: Colors .grey),
128- borderRadius: BorderRadius .all (Radius .circular (5 )),
129- ),
130- ))
131- .toList (),
140+ items: teachers,
132141 );
133142 }
134143
0 commit comments