简体   繁体   English

我如何在 flutter 中创建一个圆形搜索栏,它还显示搜索栏中最近的搜索?

[英]How do i create a rounded search bar in flutter that also shows the recent searches from the search bar?

I have been wanting to find a solution to create a rounded search bar in flutter which also shows the list of recent searches underneath it.我一直想找到一种解决方案,在 flutter 中创建一个圆形搜索栏,该搜索栏还在其下方显示最近搜索的列表。 How is it possible to create the previous widget?如何创建以前的小部件?

Using the package below, you can save the information you want to the device memory and then withdraw it from there (username, password, search history, etc.).使用下面的package,您可以将您想要的信息保存到设备memory,然后从那里提取(用户名、密码、搜索历史等)。 The sample code is in the document.示例代码在文档中。

https://pub.dev/packages/shared_preferences https://pub.dev/packages/shared_preferences

like this:像这样:

    void handleRememberMe(bool? value) {
    _isChecked = value!;
    SharedPreferences.getInstance().then(
      (prefs) {
        prefs.setBool("remember_me", value);
        prefs.setString('userName', userNameController.text);
        prefs.setString('password', passwordController.text);
      },
    );
    setState(() {
      _isChecked = value;
    });
  }

  void loadUserEmailPassword() async {
    try {
      SharedPreferences _prefs = await SharedPreferences.getInstance();
      var _email = _prefs.getString("userName") ?? "";
      var password = _prefs.getString("password") ?? "";
      var _remeberMe = _prefs.getBool("remember_me") ?? false;
      if (_remeberMe) {
        setState(() {
          _isChecked = true;
        });
        userNameController.text = _email;
        passwordController.text = password;
      } else {
        userNameController.text = "";
        passwordController.text = "";
        setState(() {
          _isChecked = false;
        });
      }
    } catch (e) {
      debugPrint(e.toString());
    }
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM