import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; import '/core/app_export.dart'; import 'package:eatvio_app/presentation/registration/weight_screen/models/weight_model.dart'; part 'weight_event.dart'; part 'weight_state.dart'; /// A bloc that manages the state of a Weight according to the event that is dispatched to it. class WeightBloc extends Bloc { WeightBloc(WeightState initialState) : super(initialState) { on(_onInitialize); on(_changeDropDown); } _onInitialize( WeightInitialEvent event, Emitter emit, ) async { emit(state.copyWith( weightModelObj: state.weightModelObj ?.copyWith(dropdownItemList: fillDropdownItemList()))); } _changeDropDown( ChangeDropDownEvent event, Emitter emit, ) { emit(state.copyWith(selectedDropDownValue: event.value)); state.weightModelObj?.userRegistrationSheet.weight = event.value.title; } List fillDropdownItemList() { List selectionPopupModels = []; for (int i = 35; i <= 200; i++) { selectionPopupModels .add(SelectionPopupModel(id: i - 34, title: i.toString())); } return selectionPopupModels; } }