1
1
import 'package:dynamicform/business_logic/get_forms_cubit/get_forms_cubit.dart' ;
2
2
import 'package:dynamicform/business_logic/get_forms_cubit/get_forms_state.dart' ;
3
3
import 'package:dynamicform/business_logic/post_form_cubit/post_form_cubit.dart' ;
4
- import 'package:dynamicform/business_logic/post_form_cubit/post_form_state.dart' ;
5
4
import 'package:dynamicform/core/constants/text_constants.dart' ;
6
5
import 'package:dynamicform/core/model/form_model.dart' ;
7
6
import 'package:dynamicform/core/routes/app_routes.dart' ;
8
- import 'package:dynamicform/core/utils/show_flushbar.dart' ;
9
7
import 'package:dynamicform/presentation/widgets/custom_text_widget.dart' ;
10
8
import 'package:flutter/material.dart' ;
11
9
import 'package:flutter_bloc/flutter_bloc.dart' ;
@@ -30,79 +28,69 @@ class _ListOfFormsScreenState extends State<ListOfFormsScreen> {
30
28
31
29
@override
32
30
Widget build (BuildContext context) {
33
- return BlocListener <PostFormCubit , PostFormState >(
34
- listener: (context, postFormState) {
35
- if (postFormState is PostFormSuccessState ) {
36
- showFlushBar (
37
- context,
38
- postFormState.postFormSuccessModel.message ?? TextConstants .nA,
39
- );
40
- }
41
- },
42
- child: Scaffold (
43
- appBar: AppBar (
44
- title: const CustomText (text: TextConstants .formTemplates),
45
- ),
46
- body: RefreshIndicator (
47
- onRefresh: _onRefresh,
48
- child: BlocBuilder <GetFormsCubit , GetFormsState >(
49
- builder: (context, state) {
50
- if (state is GetFormsLoadingState ) {
51
- return const Center (child: CircularProgressIndicator ());
52
- } else if (state is GetFormsFailureState ) {
53
- return Center (
54
- child: SingleChildScrollView (
55
- physics: const AlwaysScrollableScrollPhysics (),
56
- child: Container (
57
- height: MediaQuery .of (context).size.height - 100 ,
58
- alignment: Alignment .center,
59
- child: CustomText (text: state.failure.getErrorMsg ()),
60
- ),
31
+ return Scaffold (
32
+ appBar: AppBar (
33
+ title: const CustomText (text: TextConstants .formTemplates),
34
+ ),
35
+ body: RefreshIndicator (
36
+ onRefresh: _onRefresh,
37
+ child: BlocBuilder <GetFormsCubit , GetFormsState >(
38
+ builder: (context, state) {
39
+ if (state is GetFormsLoadingState ) {
40
+ return const Center (child: CircularProgressIndicator ());
41
+ } else if (state is GetFormsFailureState ) {
42
+ return Center (
43
+ child: SingleChildScrollView (
44
+ physics: const AlwaysScrollableScrollPhysics (),
45
+ child: Container (
46
+ height: MediaQuery .of (context).size.height - 100 ,
47
+ alignment: Alignment .center,
48
+ child: CustomText (text: state.failure.getErrorMsg ()),
61
49
),
62
- );
63
- } else if (state is GetFormsSuccessState ) {
64
- List <DynamicFormModel > forms = state.forms.forms ?? [];
65
- return forms.isEmpty
66
- ? const Center (
67
- child: CustomText (
68
- text: TextConstants .noFormsAvailable,
69
- ),
70
- )
71
- : ListView .builder (
72
- physics: const AlwaysScrollableScrollPhysics (),
73
- itemCount: forms.length,
74
- itemBuilder: (context, index) {
75
- return ListTile (
76
- title: CustomText (
77
- text: forms[index].formName ?? TextConstants .nA,
78
- ),
79
- leading: CustomText (
80
- text: "${index + 1 }." ,
81
- ),
82
- onTap: () {
83
- BlocProvider .of <PostFormCubit >(context)
84
- .formIdInDB = forms[index].formId;
85
- Navigator .pushNamed (
86
- context, AppRoutes .fillFormScreen,
87
- arguments: forms[index]);
88
- },
89
- trailing:
90
- const Icon (Icons .arrow_forward_ios, size: 18 ),
91
- );
92
- },
93
- );
94
- }
95
-
96
- return SingleChildScrollView (
97
- physics: const AlwaysScrollableScrollPhysics (),
98
- child: Container (
99
- height: MediaQuery .of (context).size.height - 100 ,
100
- alignment: Alignment .center,
101
- child: const CustomText (text: TextConstants .noFormsAvailable),
102
50
),
103
51
);
104
- },
105
- ),
52
+ } else if (state is GetFormsSuccessState ) {
53
+ List <DynamicFormModel > forms = state.forms.forms ?? [];
54
+ return forms.isEmpty
55
+ ? const Center (
56
+ child: CustomText (
57
+ text: TextConstants .noFormsAvailable,
58
+ ),
59
+ )
60
+ : ListView .builder (
61
+ physics: const AlwaysScrollableScrollPhysics (),
62
+ itemCount: forms.length,
63
+ itemBuilder: (context, index) {
64
+ return ListTile (
65
+ title: CustomText (
66
+ text: forms[index].formName ?? TextConstants .nA,
67
+ ),
68
+ leading: CustomText (
69
+ text: "${index + 1 }." ,
70
+ ),
71
+ onTap: () {
72
+ BlocProvider .of <PostFormCubit >(context).formIdInDB =
73
+ forms[index].formId;
74
+ Navigator .pushNamed (
75
+ context, AppRoutes .fillFormScreen,
76
+ arguments: forms[index]);
77
+ },
78
+ trailing:
79
+ const Icon (Icons .arrow_forward_ios, size: 18 ),
80
+ );
81
+ },
82
+ );
83
+ }
84
+
85
+ return SingleChildScrollView (
86
+ physics: const AlwaysScrollableScrollPhysics (),
87
+ child: Container (
88
+ height: MediaQuery .of (context).size.height - 100 ,
89
+ alignment: Alignment .center,
90
+ child: const CustomText (text: TextConstants .noFormsAvailable),
91
+ ),
92
+ );
93
+ },
106
94
),
107
95
),
108
96
);
0 commit comments