Skip to content

Commit

Permalink
chore: changes all BlocProvider.of<T> to context.read<T>
Browse files Browse the repository at this point in the history
  • Loading branch information
am-casper committed Jan 3, 2024
1 parent babab58 commit 44955d3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 25 deletions.
14 changes: 6 additions & 8 deletions lib/presentation/hostel_change/hostel_change_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,8 @@ class HostelChangeScreen extends StatelessWidget {
TextField(
controller: _searchController,
onChanged: (value) {
BlocProvider.of<HostelChangeBloc>(context)
.add(HostelSearchQueryChanged(
query: value));
context.read<HostelChangeBloc>().add(
HostelSearchQueryChanged(query: value));
},
decoration: InputDecoration(
filled: true,
Expand Down Expand Up @@ -167,9 +166,8 @@ class HostelChangeScreen extends StatelessWidget {
onTap: () {
_searchController.text =
hostelMap.values.elementAt(index);
BlocProvider.of<HostelChangeBloc>(
context)
.add(HostelSearchQueryChanged(
context.read<HostelChangeBloc>().add(
HostelSearchQueryChanged(
query: hostelMap.values
.elementAt(index)));
},
Expand Down Expand Up @@ -206,8 +204,8 @@ class HostelChangeScreen extends StatelessWidget {
_searchController.text = hostelMap
.values
.elementAt(index);
BlocProvider.of<HostelChangeBloc>(
context)
context
.read<HostelChangeBloc>()
.add(HostelSearchQueryChanged(
query: hostelMap.values
.elementAt(index)));
Expand Down
34 changes: 17 additions & 17 deletions lib/presentation/login/login_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ class LoginScreen extends StatelessWidget {
),
suffixIcon: IconButton(
onPressed: () {
BlocProvider.of<LoginBloc>(context).add(
ToggleObscureCreatePassword(
showPassword: !state.showPassword,
showConfirmPassword:
state.showConfirmPassword,
),
);
context.read<LoginBloc>().add(
ToggleObscureCreatePassword(
showPassword: !state.showPassword,
showConfirmPassword:
state.showConfirmPassword,
),
);
},
icon: state.showPassword
? const Icon(Icons.visibility,
Expand Down Expand Up @@ -155,13 +155,13 @@ class LoginScreen extends StatelessWidget {
),
suffixIcon: IconButton(
onPressed: () {
BlocProvider.of<LoginBloc>(context).add(
ToggleObscureCreatePassword(
showPassword: state.showPassword,
showConfirmPassword:
!state.showConfirmPassword,
),
);
context.read<LoginBloc>().add(
ToggleObscureCreatePassword(
showPassword: state.showPassword,
showConfirmPassword:
!state.showConfirmPassword,
),
);
},
icon: state.showConfirmPassword
? const Icon(Icons.visibility,
Expand Down Expand Up @@ -235,9 +235,9 @@ class LoginScreen extends StatelessWidget {
suffixIcon: state is EnterPassword
? IconButton(
onPressed: () {
BlocProvider.of<LoginBloc>(context).add(
ShowPasswordPressed(),
);
context.read<LoginBloc>().add(
ShowPasswordPressed(),
);
},
icon: state.showPassword
? const Icon(Icons.visibility,
Expand Down

0 comments on commit 44955d3

Please sign in to comment.