@@ -14,44 +14,41 @@ class ContestsScreen extends StatelessWidget {
1414
1515 @override
1616 Widget build (BuildContext context) {
17- return BlocProvider <ContestsBloc >(
18- create: (_) => ContestsBloc ()..init (),
19- child: Scaffold (
20- appBar: const PreferredSize (
21- preferredSize: Size .fromHeight (kToolbarHeight),
22- child: ContestHeader (),
23- ),
24- body: BlocBuilder <ContestsBloc , ContestsState >(
25- builder: (context, state) {
26- if (state.status is Loading || state.status is Error ) {
27- return const LoadingState ();
28- }
29- if (state.contests.isEmpty) {
30- return const EmptyState (
31- description: 'No contests found, please adjust your filters!' ,
32- );
33- }
34- return ListView .builder (
35- itemCount: state.contests.length,
36- itemBuilder: (context, index) {
37- final isReminderSet = context
38- .read <ContestsBloc >()
39- .reminderSet (state.contests[index].name);
40- if (state.contests[index] is Ongoing ) {
41- return ContestCard (
42- isReminderSet: isReminderSet,
43- ongoing: state.contests[index],
44- );
45- }
46-
17+ return Scaffold (
18+ appBar: const PreferredSize (
19+ preferredSize: Size .fromHeight (kToolbarHeight),
20+ child: ContestHeader (),
21+ ),
22+ body: BlocBuilder <ContestsBloc , ContestsState >(
23+ builder: (context, state) {
24+ if (state.status is Loading || state.status is Error ) {
25+ return const LoadingState ();
26+ }
27+ if (state.contests.isEmpty) {
28+ return const EmptyState (
29+ description: 'No contests found, please adjust your filters!' ,
30+ );
31+ }
32+ return ListView .builder (
33+ itemCount: state.contests.length,
34+ itemBuilder: (context, index) {
35+ final isReminderSet = context
36+ .read <ContestsBloc >()
37+ .reminderSet (state.contests[index].name);
38+ if (state.contests[index] is Ongoing ) {
4739 return ContestCard (
4840 isReminderSet: isReminderSet,
49- upcoming : state.contests[index],
41+ ongoing : state.contests[index],
5042 );
51- },
52- );
53- },
54- ),
43+ }
44+
45+ return ContestCard (
46+ isReminderSet: isReminderSet,
47+ upcoming: state.contests[index],
48+ );
49+ },
50+ );
51+ },
5552 ),
5653 );
5754 }
0 commit comments