In app, I use stream.transform
and CombineLatestStream.combine3
from RxDart
to combine and merge multiple three streams in app for button validation. It is work well but if app stay in recent and background for long a time. CombineLatestStream.combine3
not work and button not validate even all required fields are validate.
How this can be? How can I fix it? Here is my code for example
Controller code
Function(String) get fillUserId => _userIdController.sink.add;
Function(String) get fillPhoneNumber => _phoneNumberController.sink.add;
Function(String) get fillPassword => _passwordController.sink.add;
Stream<String> get userIdStream =>
_userIdController.stream.transform(validateUserId);
Stream<String> get phoneNumberStream =>
_phoneNumberController.stream.transform(validatephoneNumber);
Stream<String> get passwordStream =>
_passwordController.stream.transform(validatePassword);
Stream<bool> get submitValid => CombineLatestStream.combine3(
userIdStream, phoneNumberStream, passwordStream, (u, p, pas) => true);
UI code
Widget loginButton(
{required LoginBloc loginBloc, required bool isInternetAlive}) {
return StreamBuilder(
stream: loginBloc.submitValid,
builder: (context, AsyncSnapshot loginSnapShot) {
if (loginSnapShot.hasData) {
formKey.currentState?.save();
}
return GradientButton(
onClick: () {
passwordFocusNode.unfocus();
loginBloc.login(
userId: userId!,
password: password!,
phoneNumber: phoneNumber!,
);
// passwordFocusNode.unfocus();
_passCtrl.text = "";
loginBloc.fillPassword("");
},
label: LOGIN_BTN_LABEL,
isBtnDisable: loginSnapShot.hasData ? false : true,
);
},
);
}
And From UI use submitValid
stream withstreamBuilder
like that. But happening the error as above explanation. How can I fix?