我已经设置了共享首选项,以便在应用程序中单击保存数据按钮后存储ArrayList的值。这部分运行得很好。
我遇到的问题是我有一个回收器视图适配器,它用行填充回收器视图。每行都包含一个复选框,选中该复选框后,该行中的文本将变为绿色,表示已完成。
我的问题是,如何将复选框状态添加到我的共享首选项中,并保存该状态,以便当我重新打开应用程序时,复选框被保存。
在主活动中的oncreate中的保存按钮
//Functionality for save button
final Button saveButton =findViewById(R.id.saveButtonGame);
List<double> timersValuesList = [30.0, 60.0, 90.0, 120.0, 150.0, 180.0];
void saveSharedPreferences() async {
// from List of double to a List of String
List<String> convertedTimerValues = timersValuesList.map((i) => i.toString()).toList();
// getting the instance of sharedPref
你好,我不知道怎么才能让我的应用程序保存开关状态
示例:
我要打开应用程序,在重新启动应用程序之后,我要关闭开关,我希望我的应用程序关闭状态,反之亦然。
public class AlgeriaNotificationsActivity extends AppCompatActivity {
public static final String PREFS_NAME = "MyPrefsFile";
private TextView switchStatus;
private Switch mySwitch;
private static final String TAG
我希望使用以下代码将MobileVersionList和AppInfoList数据从API保存到SharedPreferences中:
全球提供者
//! Save AppInfoList To SharedPreferences
String _encodeAppInfoList = '';
String get encodeAppInfoList => _encodeAppInfoList;
List get decodeAppInfoList => json.decode(_encodeAppInfoList) ?? [];
List<
我在我的颤振应用程序中使用了shared_preferences插件。从一开始(可能在颤振升级之后),它就开始抛出一个异常:
E/flutter (27778): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
E/flutter (27778): type '_InternalLinkedHashMap' is not a subtype of type 'Map<String, Object>' where
E/flutter (27778): _I
我已经研究这个问题将近半天了。我正在尝试使用Flutter的SharedPreferences包在应用程序的存储中存储密钥/值。当我通过SharedPreferences新建一个await SharedPreferences.getInstance()时,它构建和运行正常,但是当应用程序到达该代码行时,它会崩溃,并出现以下错误:
MissingPluginException (MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferen
我正在学习如何在颤振中使用SharedPreferences库。
我创建了下面的代码作为测试,以了解如何保存和加载列表。
当我进行热重新启动时,列表无法正确加载。我有一个错误:
E/flutter (17671): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: type 'Null' is not a subtype of type 'List<Row>'
E/flutter (17671): #0 new Data.fromJson (package:p
我刚开始学习如何使用Dart中的隔离物。当我试图通过隔离来访问共享首选项时,它会抛出给定的错误。当我试图访问Firebase分析和远程配置时,也会出现此错误。我如何解决这个问题,并访问隔离内的SharedPreference、FirebaseRemote配置、FirebaseFirestore?
[ERROR:flutter/runtime/dart_isolate.cc(882)] Unhandled exception:
E/flutter (23694): ServicesBinding.defaultBinaryMessenger was accessed before the bin