Skip to content

Commit 44955d3

Browse files
committed
chore: changes all BlocProvider.of<T> to context.read<T>
1 parent babab58 commit 44955d3

2 files changed

Lines changed: 23 additions & 25 deletions

File tree

lib/presentation/hostel_change/hostel_change_screen.dart

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,8 @@ class HostelChangeScreen extends StatelessWidget {
121121
TextField(
122122
controller: _searchController,
123123
onChanged: (value) {
124-
BlocProvider.of<HostelChangeBloc>(context)
125-
.add(HostelSearchQueryChanged(
126-
query: value));
124+
context.read<HostelChangeBloc>().add(
125+
HostelSearchQueryChanged(query: value));
127126
},
128127
decoration: InputDecoration(
129128
filled: true,
@@ -167,9 +166,8 @@ class HostelChangeScreen extends StatelessWidget {
167166
onTap: () {
168167
_searchController.text =
169168
hostelMap.values.elementAt(index);
170-
BlocProvider.of<HostelChangeBloc>(
171-
context)
172-
.add(HostelSearchQueryChanged(
169+
context.read<HostelChangeBloc>().add(
170+
HostelSearchQueryChanged(
173171
query: hostelMap.values
174172
.elementAt(index)));
175173
},
@@ -206,8 +204,8 @@ class HostelChangeScreen extends StatelessWidget {
206204
_searchController.text = hostelMap
207205
.values
208206
.elementAt(index);
209-
BlocProvider.of<HostelChangeBloc>(
210-
context)
207+
context
208+
.read<HostelChangeBloc>()
211209
.add(HostelSearchQueryChanged(
212210
query: hostelMap.values
213211
.elementAt(index)));

lib/presentation/login/login_screen.dart

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,13 @@ class LoginScreen extends StatelessWidget {
118118
),
119119
suffixIcon: IconButton(
120120
onPressed: () {
121-
BlocProvider.of<LoginBloc>(context).add(
122-
ToggleObscureCreatePassword(
123-
showPassword: !state.showPassword,
124-
showConfirmPassword:
125-
state.showConfirmPassword,
126-
),
127-
);
121+
context.read<LoginBloc>().add(
122+
ToggleObscureCreatePassword(
123+
showPassword: !state.showPassword,
124+
showConfirmPassword:
125+
state.showConfirmPassword,
126+
),
127+
);
128128
},
129129
icon: state.showPassword
130130
? const Icon(Icons.visibility,
@@ -155,13 +155,13 @@ class LoginScreen extends StatelessWidget {
155155
),
156156
suffixIcon: IconButton(
157157
onPressed: () {
158-
BlocProvider.of<LoginBloc>(context).add(
159-
ToggleObscureCreatePassword(
160-
showPassword: state.showPassword,
161-
showConfirmPassword:
162-
!state.showConfirmPassword,
163-
),
164-
);
158+
context.read<LoginBloc>().add(
159+
ToggleObscureCreatePassword(
160+
showPassword: state.showPassword,
161+
showConfirmPassword:
162+
!state.showConfirmPassword,
163+
),
164+
);
165165
},
166166
icon: state.showConfirmPassword
167167
? const Icon(Icons.visibility,
@@ -235,9 +235,9 @@ class LoginScreen extends StatelessWidget {
235235
suffixIcon: state is EnterPassword
236236
? IconButton(
237237
onPressed: () {
238-
BlocProvider.of<LoginBloc>(context).add(
239-
ShowPasswordPressed(),
240-
);
238+
context.read<LoginBloc>().add(
239+
ShowPasswordPressed(),
240+
);
241241
},
242242
icon: state.showPassword
243243
? const Icon(Icons.visibility,

0 commit comments

Comments
 (0)