Я использую blo c для получения данных, введенных в textField, и сохранения их в переменной. Я продолжаю получать сообщение об ошибке: «type '_ControllerSubscription' не является подтипом типа 'Stream'» после добавления слушателя в поток.
UI:
/****/
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
var bloc = Bloc();
return Container(
color: Colors.white,
child: Column(children: <Widget>[
SizedBox(height: size.height *.2 ,),
StreamBuilder( stream: bloc.textStream,
builder: (context, snapshot ){
return Container(
width: size.height * .5,
height: size.height *.2,
child: TextField(
onChanged: bloc.changeText,
textAlign: TextAlign.right,
decoration: InputDecoration(
hintStyle: TextStyle(
fontSize: 14,
color: Colors.black,
),),
/****
*****/
Blo c:
import 'dart:async';
class Bloc {
var _text='';
final _textFieldController = StreamController<String>();
get textStream => _textFieldController.stream
.listen( (value){_text = value;});
Function(String) get changeText => _textFieldController.sink.add;
void dispose() {
_textFieldController.close();
}
}