Skip to content

Setter of null value is not changing the value #1069

Description

@WissamALSbenaty

In this case the setter works correctly if the parameter is null , so the initial value of the Observable class is null , but if it is initialised by a value , it will not change to null , in my case im deselect the option and the value still not null

Even if I change the value by passing null directly without a variable or parameter


part 'duty_officer_search_controller.g.dart';

@injectable
class DutyOfficerSearchController extends DutyOfficerSearchControllerBase with _$DutyOfficerSearchController {
  DutyOfficerSearchController(
    @factoryParam super.preselectedDutyOfficer,
   
  );
}

abstract class DutyOfficerSearchControllerBase extends BaseController with SearchingMixin, Store {
  final EmployeeModel? preselectedDutyOfficer;

  DutyOfficerSearchControllerBase(
    this.preselectedDutyOfficer,
  );

@observable
  late EmployeeModel? selectedDutyOfficer=preselectedDutyOfficer;

  @action
  void changeSelectedDutyOfficer(final EmployeeModel? value) {
    selectedDutyOfficer = value;
    if(value==null) {
      print('here null');
      selectedDutyOfficer=null;
    }
    print(' $selectedDutyOfficer $value');
  }


}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions