在扑扑中使用typeaheadformfield搜索数据库sqlite

时间:2020-07-09 10:42:06

标签: sqlite flutter search

我正在尝试制作一个typeaheadformfield来选择其他界面中listview的成员。

这是我的代码:

TypeAheadFormField(
              textFieldConfiguration:TextFieldConfiguration(
              controller:c2,
              decoration: InputDecoration(
                labelText: ' Mdicament',
                hintText: 'Select a Mdicament',
                border: OutlineInputBorder(
                  borderRadius: BorderRadius.circular((20.0)),
                ),
              )),
              suggestionsCallback: (pattern){
                return  helper.getMedicamentMapList();
              },
              itemBuilder:(context,suggestion){
                return ListTile(
                  title:Text(suggestion),
                );
              },
              transitionBuilder:(context,suggestionsBox,controller){
                return suggestionsBox;
              },
              onSuggestionSelected:(suggestion){
                c2.text=suggestion;
               // Medicament.getMap(suggestion);
              },
              validator:(val)=>val.isEmpty ? 'please select a medic...' : null,
              onSaved:(val) => setState(
                    ()=> _nom=val,

          )
            ),

我在databasehelper中的未来是:

Future<List<Map<String, dynamic>>> getMedicamentMapList() async {
  Database db = await this.database;

  //var result1 =  await db.rawQuery("SELECT * FROM $tableName ORDER BY $_id ASC");
  var result = await db.query(medicaTable, orderBy: "$colId ASC");
  return result;
}

我收到此错误:

I / SurfaceView(30515):updateWindow-OnPreDrawListener,mHaveFrame = true,此= io.flutter.embedding.android.FlutterSurfaceView {5e96fa0 VE .... ........ 0,0-720 ,1184} D / FeatureProxyBase(30515):FeatureProxyBase类构造函数 D / FeatureProxyBase(30515):getService(),serviceName = multiwindow_service_v1 V / InputMethodManager(30515):开始输入:io.flutter.embedding.android.FlutterView {1a277759 VFE ..... F ...... 0,0-720,1184} ic = io.flutter.plugin .editing.InputConnectionAdaptor @ 3d6ee801 tba = EditorInfo {packageName = example.pharmacyapp,inputType = 0x80081,imeOptions = 0x2000006,privateImeOptions = null} controlFlags =#0 I / InputMethodManager(30515):[startInputInner] EditorInfo {packageName = example.pharmacyapp,inputType = 0x80081,imeOptions = 0x2000006,privateImeOptions = null},windowGainingFocus = null,mServedView = io.flutter.embedding.android.FlutterView {1a277759 VFE。 .... .F ...... 0,0-720,1184},mServedInputConnectionWrapper = android.view.inputmethod.InputMethodManager $ ControlledInputConnectionWrapper @ 24af46a6 I / SurfaceView(30515):updateWindow-setFrame,这= io.flutter.embedding.android.FlutterSurfaceView {5e96fa0 V.E ......... 0,0-720,1184} I / SurfaceView(30515):updateWindow-OnPreDrawListener,mHaveFrame = true,这= io.flutter.embedding.android.FlutterSurfaceView {5e96fa0 V.E ........... 0,0-720,1184} I / SurfaceView(30515):updateWindow-setFrame,这= io.flutter.embedding.android.FlutterSurfaceView {5e96fa0 V.E ......... 0,0-720,1184} I / SurfaceView(30515):updateWindow-OnPreDrawListener,mHaveFrame = true,这= io.flutter.embedding.android.FlutterSurfaceView {5e96fa0 V.E ........... 0,0-720,1184}

0 个答案:

没有答案