Advertisement
rifki_cs29

ImplementBloc

Mar 13th, 2022
1,257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 2.82 KB | None | 0 0
  1. BlocBuilder<CategoryFilterBloc, CategoryFilterState>(
  2.                       builder: (context, state) {
  3.                         return Wrap(
  4.                           alignment: WrapAlignment.start,
  5.                           spacing: 8,
  6.                           runSpacing: 0,
  7.                           children: _valueFilterLocation
  8.                               .map(
  9.                                 (location) => ChoiceChip(
  10.                                   selected:
  11.                                       state.selectedLocation.contains(location),
  12.                                   onSelected: (bool selected) {
  13.                                     if (selected == true) {
  14.                                       context
  15.                                           .read<CategoryFilterBloc>()
  16.                                           .add(OnSelectedLocation(location));
  17.                                     } else if (selected == false) {
  18.                                       context
  19.                                           .read<CategoryFilterBloc>()
  20.                                           .add(UnSelectedLocation(location));
  21.                                     }
  22.                                     print(state.selectedLocation);
  23.                                   },
  24.                                   padding: const EdgeInsets.symmetric(
  25.                                     horizontal: 4,
  26.                                   ),
  27.                                   selectedColor:
  28.                                       state.selectedLocation.contains(location)
  29.                                           ? AppColors.orangeLight
  30.                                           : Colors.white,
  31.                                   backgroundColor: Colors.white,
  32.                                   shape: const StadiumBorder(
  33.                                     side: BorderSide(
  34.                                       color: Colors.grey,
  35.                                       width: 1,
  36.                                     ),
  37.                                   ),
  38.                                   label: Text(
  39.                                     location,
  40.                                     style: GoogleFonts.roboto(
  41.                                       fontSize: 12,
  42.                                       fontWeight: FontWeight.w500,
  43.                                       color: state.selectedLocation
  44.                                               .contains(location)
  45.                                           ? Colors.white
  46.                                           : Colors.grey,
  47.                                     ),
  48.                                   ),
  49.                                 ),
  50.                               )
  51.                               .toList(),
  52.                         );
  53.                       },
  54.                     ),
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement