forked from eatvio/eatvio_app
39 lines
1.2 KiB
Dart
39 lines
1.2 KiB
Dart
import 'package:equatable/equatable.dart';
|
|
import 'package:flutter/material.dart';
|
|
import '/core/app_export.dart';
|
|
import 'package:eatvio_app/presentation/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<WeightEvent, WeightState> {
|
|
WeightBloc(WeightState initialState) : super(initialState) {
|
|
on<WeightInitialEvent>(_onInitialize);
|
|
on<ChangeDropDownEvent>(_changeDropDown);
|
|
}
|
|
|
|
_onInitialize(
|
|
WeightInitialEvent event,
|
|
Emitter<WeightState> emit,
|
|
) async {
|
|
emit(state.copyWith(
|
|
weightModelObj: state.weightModelObj
|
|
?.copyWith(dropdownItemList: fillDropdownItemList())));
|
|
}
|
|
|
|
_changeDropDown(
|
|
ChangeDropDownEvent event,
|
|
Emitter<WeightState> emit,
|
|
) {
|
|
emit(state.copyWith(selectedDropDownValue: event.value));
|
|
}
|
|
|
|
List<SelectionPopupModel> fillDropdownItemList() {
|
|
return [
|
|
SelectionPopupModel(id: 1, title: "Item One", isSelected: true),
|
|
SelectionPopupModel(id: 2, title: "Item Two"),
|
|
SelectionPopupModel(id: 3, title: "Item Three")
|
|
];
|
|
}
|
|
}
|