我正在与FLUTTER/DART
和RXDART
做一个小项目。
这是代码的一部分:
class RegisterBloc with UserValidator {
final _username = BehaviorSubject<String>();
final _email = BehaviorSubject<String>();
final _password = BehaviorSubject<String>();
Function(String) get setUsername => _username.sink.add;
Stream<String> get username => _username.stream.transform(usernameValidatorTransformer);
Function(String) get setEmail => _email.sink.add;
Stream<String> get email => _email.stream.transform(emailValidatorTransformer);
Function(String) get setPassword => _password.sink.add;
Stream<String> get password => _password.stream.transform(passwordValidatorTransformer);
Stream<bool> get validForm => CombineLatestStream.combine3<String, String, String, bool>(_username.stream, _email.stream, _password.stream, (u, e, p) => true);
submit() async {
final form = RegisterForm(
username: _username.value,
email: _email.value,
password: _password.value
);
}
dispose() {
_username.close();
_email.close();
_password.close();
}
}
问题是validForm流会发射空数据,并且即使所有流都已经已经发射了至少一个值,合并器也永远不会被调用。 最糟糕的是,这种情况仅发生在Android(mine v.8.1.0)上,代码按预期在iOS 11上运行。
以防万一,我使用StreamBuilder小部件来更新小部件数据。
我在这里错过了什么吗?任何配置都需要事先设置。否则
这里是我的开发环境:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.2.1, on Mac OS X 10.13.6 17G6030, locale en-ID)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
[✓] Android Studio (version 3.3)
[✓] Connected device (1 available)
RxDart:0.21.0 Android设备:8.1.0