问题标签 [flutter-sharedpreference]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
29 浏览

android - 即使在使用 --no-shrink 标志构建后,shared_preferences 也无法在发布模式下工作

我在我的颤振项目中使用“shared_preferences”插件。问题是应用程序在调试模式下按预期工作,但在发布模式下无法正常工作。我也尝试使用 --no-shrink 标志进行构建,但仍然无法正常工作。以下是我实现逻辑的代码片段:

0 投票
4 回答
86 浏览

flutter - 在构建颤振之前初始化变量?

我正在尝试在 initstate 中初始化一个变量。在我的脚手架中使用了在初始化空值之前。我如何等待一个变量然后加载构建?我正在使用 shared_preference 插件。这是我的初始化状态:

在这里,我正在检查它是否为空并且始终为空:

0 投票
1 回答
27 浏览

android - 无法更改 SimpleSettingsTile 的背景颜色

我将flutter_settings_screens颤振插件用于我的移动应用程序的设置屏幕,我无法更改每个设置的背景。例如,我想更改SimpleSettingsTile的背景。我怎样才能做到这一点 ?

这是我的代码:

0 投票
1 回答
40 浏览

android - 如何存储列表 in Flutter using sharedPreferences?

I want to save list of PlatformFile, with the help of file_picker library and store them using sharedpreferences and then load them back. list -> List


I want to save list of PlatformFile, with the help of file_picker library and store them using sharedpreferences and then load them back. list -> List


How to use the TimeSide Python library on local Machine

I'm trying to use the TimeSide library to do some audio analysis. It seems to be the most comprehensive package for audio analysis I can find in python. However, I can't figure out how to use it. I tried using it like a normal python module, as shown in the docs:

But this gives error:

I see on the project page that we're supposed to use docker for install:

So I got docker setup on my Windows machine, but following those instructions I get:

So looks like there's some issue with docker?

  • Is there anyway I can skip the "docker" part of this library and just use it like a normal module?
  • If not, why am I getting this additional property app is not allowed error?
  • If I was able to follow the provided install instructions, then what would I do next? Could I then just use the library as I would a regular module in my local Pycharm editor?
0 投票
1 回答
41 浏览

flutter - Shared Preference GetInstance() _TypeError(类型 '() => Null' 不是类型 '(dynamic) => dynamic' of 'f' 的子类型)

颤振版本:

我遇到了一个例外SharedPreferences prefs = await SharedPreferences.getInstance();

相同的代码在登录功能中正常工作。

代码:

Flutter 2.8.1 • 通道稳定 • https://github.com/flutter/flutter.git
框架 • 修订版 77d935af4d(4 周前) • 2021-12-16 08:37:33 -0800
引擎 • 修订版 890a5fca2e
工具 • Dart 2.15.1

0 投票
2 回答
20 浏览

flutter - Flutter - 有条件地渲染 cookie 对话框

我是 Flutter 和 Dart 语言的初学者,并试图弄清楚如何在页面加载时有条件地(基于用户偏好)呈现 cookie 设置对话框(弹出)。我已经找到了一些 3rd 方包(sharedpreferences)来存储用户偏好的键值对。我想要做的是检查用户偏好,如果未找到或错误(单击拒绝未给予同意)此弹出窗口将继续出现在所有页面上。我还希望用户能够通过单击链接打开此 cookie 设置弹出窗口。我怎样才能做到这一点?

0 投票
1 回答
39 浏览

flutter - Flutter 应用程序在用户关闭应用程序时丢失本地数据

我的应用程序使用 shared_preferences 和写入本地 json 文件(使用 path_provider 获取路径)来获取它使用的数据。我最近开始对一个更大的小组进行测试(从 22 年 1 月 1 日开始),有些人在关闭应用程序并重新打开它时遇到了数据丢失的问题。我们正在 Android 和 iOS 上进行测试。第一个遇到此问题的用户是在 iOS 上,并且从一开始就遇到了。几天前(22 年 1 月 12 日),所有其他用户都遇到了这个问题,并且主要是 iOS 用户和 1 个 Android 用户的混合体。

数据在应用程序运行时保持不变,因为它在用户导航时是一致的。我自己无法复制这个问题,也无法找出我研究中的问题。对可能发生的事情有任何想法吗?

我发现了一个类似的问题,提到 path_provider 提供了不同的存储路径,但这似乎不是我的问题,因为被调用的第一条数据是 shared_preferences 数据,而且它也丢失了。

0 投票
0 回答
4 浏览

sharedpreferences - flutter 如何使用 Shared_preferences 持久化收藏列表文件?

我没有错误,但数据没有保留,也许我以错误的方式使用它,请花点时间帮助我。请。!

这是我用来存储数据的函数

// 获取文件

在此先感谢您的支持对我非常有用。

错误:类型 'List<Object?>' 不是类型 'String?' 的子类型 在类型转换中

0 投票
0 回答
24 浏览

flutter - 如何在颤动中将您的供应商商店中的数据更新为您的共享偏好

我想更新我的共享首选项,以便每次更新我的提供者时,更新的列表都会自动存储在我的共享首选项中。这是我的代码。

0 投票
2 回答
29 浏览

firebase - 如何在 Flutter 中使用电话身份验证时保持用户登录状态

我有以下代码,我需要在用户重新打开应用程序时让他们保持登录状态。我有来自 firebase 的颤振电话身份验证服务。给出的是验证谷歌手机身份验证的功能。当按下下面提到的 2 个功能时,有一个按钮来获取名为verifyPhoneNumber()&的调用signInWithPhoneNumber()

}

请给我一个解决方案。