Questions tagged «sqflite»

3
如何使用StreamBuilder更新TextField的值?
我有一个textfield,我sqflite在我的应用程序中使用数据库。该sqflite有,我需要分配给我的价值textfield 这是我的textfield代码 StreamBuilder<String>( stream: patientHealthFormBloc.doctorName, builder: (context, snapshot) { return TextFormField( initialValue: patientHealthFormBloc.doctorNameValue, onChanged: (value) { patientHealthFormBloc.doctorNameChanged(value); }, ... 现在,在initstate我课堂上的方法中,我正在从数据库中获取价值。这是异步操作,因此需要时间。 我的bloc类具有如下代码 Function(String) get doctorNameChanged => _doctorName.sink.add; 因此,一旦我从数据库中获得价值,我就会立即致电 doctorNameChanged("valuefromdatabase"); 但我看不到文本字段中的值。我的数据库中也有一个值。是否可以不使用TextEditingController或来更新值setState。我是个试图避免那些因为我的课是很多chuncks和方式过于复杂,使用任何上述我一直在使用与同样的方法试了划分RadioButton,并CheckBox和他们似乎正确更新。_doctorName.stream.value数据库中存在的值也会更新, 但textfield不会显示任何数据。我也试图改变颜色,textfield所以那里没有问题,以及我能够看到我输入的内容。 我已经对该应用程序做了一个小演示https://github.com/PritishSawant/demo/tree/master/lib sqflite我正在使用shared preferences而不是使用,但是问题仍然存在
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.