2

typeaheadformfield 的 ListTile 中的建议在底部表中起作用,但在底部表中不起作用。我已经将上下文传递给底部表,它从回调中获取建议,但不会在底部表中呈现。我检查了底页,它返回了建议。

void _postModals(context) {
showModalBottomSheet(
    shape: const RoundedRectangleBorder(
        borderRadius: BorderRadius.vertical(top: Radius.circular(25.0))),
    backgroundColor: Colors.white,
    context: context,
    isScrollControlled: true,
    builder: (context) => Padding(
          padding: const EdgeInsets.symmetric(horizontal: 18),
          child: Obx(() => Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                mainAxisSize: MainAxisSize.min,
                children: <Widget>[
                  const SizedBox(
                    height: 18.0,
                  ),
                  Padding(
                    padding: EdgeInsets.only(
                        bottom: MediaQuery.of(context).viewInsets.bottom),
                    child: Container(
                      height: 400,
                      child: Form(
                        key: postController.CaptionForm,
                        child: Column(
                          children: [
                            Expanded(
                              child: Column(
                                children: [
                                  Padding(
                                    padding: const EdgeInsets.all(8.0),
                                    child: TypeAheadFormField<User?>(
                                      hideOnEmpty: true,
                                      textFieldConfiguration:
                                          TextFieldConfiguration(
                                        controller: postController
                                            .captionController,
                                        decoration:
                                            const InputDecoration.collapsed(
                                                hintText: 'put users',
                                                hintStyle: TextStyle(
                                                  fontSize: 15,
                                                )),
                                      ),
                                      suggestionsCallback:
                                          RemoteServices.fetchFollowers,
                                      itemBuilder:
                                          (context, User? suggestion) {
                                        final user = suggestion!;
                                        return ListTile(
                                          title: Text(user.name),
                                        );
                                      },
                                      onSuggestionSelected:
                                          (User? suggestion) {
                                        final user = suggestion;
                                        ScaffoldMessenger.of(context)
                                          ..removeCurrentSnackBar()
                                          ..showSnackBar(SnackBar(
                                            content: Text(
                                                'Selected user: ${user!.name}'),
                                          ));
                                      },
                                      validator: (value) {
                                        return postController
                                            .validateCaption(value!);
                                      },
                                    ),
                                  ),
                                  SizedBox(
                                    height: 40,
                                  ),
                                ],
                              ),
                            ),
                          ],
                        ),
                      ),
                    ),
                  ),
                ],
              )),
        ));
    }
4

0 回答 0