init method

void init({
  1. required VoidCallback onFinish,
  2. required VoidCallback onError,
})

Implementation

void init({
  required VoidCallback onFinish,
  required VoidCallback onError,
}) {
  if (ULocalStorage.getString(UConstants.token) == null) {
    onError();
  } else {
    UServices.user.readById(
      p: UIdParams(
        id: ULocalStorage.getString(UConstants.userId)!,
      ),
      onOk: (UResponse<UUserResponse> user) {
        U.user = user.result!;
        onFinish();
      },
      onError: (UEmptyResponse r) => onError.call,
      onException: (String e) => onError.call,
      onProgress: (int e) {},
    );
  }
}