activate method

Future<void> activate(
  1. String code,
  2. String trolleyNo
)

Implementation

Future<void> activate(String code, String trolleyNo) async {
  if (code.isEmpty) {
    state = state.copyWith(error: 'Please enter the activation code');
    return;
  }
  state = state.copyWith(isLoading: true, error: null);

  final result = await _repo.activateDevice(code, trolleyNo);

  switch (result) {
    case NetworkSuccess():
      state = state.copyWith(isLoading: false, isSuccess: true);
    case NetworkError():
      state = state.copyWith(isLoading: false, error: result.message);
  }
}