我想通过流发送加密密码
我试图先将其更改为uft8,然后再将其加密为md5,以进行发送。不幸的是,我得到的只是错误 'BehaviorSubject'不是'stream
的'Stream'类型的子类型StreamBuilder password() {
return StreamBuilder(
stream: bloc.password,
builder: (context, snapshot) => TextField(
onChanged: (s) => bloc.passwordChanged
.add(md5.convert(utf8.encode(s))),
obscureText: true,
));
}
class Bloc extends Object with Validator {
final _passwordController = BehaviorSubject();
StreamSink get passwordChanged => _passwordController.sink;
Stream get password =>
_passwordController.stream.transform(passwordValidator);
}
var passwordValidator = StreamTransformer<String, String>.fromHandlers(
handleData: (password, sink) {
if (password.isNotEmpty) {
verification from server
sink.add(password);
} else {
sink.addError("Password not given");
}
});
是否有可能将此列表作为单个参数使用,所以我不会因使用不同类型的错误而出错,还是必须创建不同类型的流?