【问题标题】:shared_preferences not working in release mode even after building with --no-shrink flag即使在使用 --no-shrink 标志构建后,shared_preferences 也无法在发布模式下工作
【发布时间】:2022-01-25 14:22:43
【问题描述】:

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

SharedPreferences prefs = await SharedPreferences.getInstance();
String notificationID = prefs.getString("notificationID") ?? "";
String messageID = message.data['id'];
if (notificationID == messageID.toString()) {
   print("Notification has been displayed in the past");
} else {
...
}

【问题讨论】:

    标签: android flutter sharedpreferences release flutter-sharedpreference


    【解决方案1】:

    这可能有助于首次运行 flutter build apk --no-shrink
    flutter build appbundle --no-shrink

    来源:https://stackoverflow.com/a/63763638/11519962

    【讨论】:

    • 是的,我试过了,但是没有用
    猜你喜欢
    • 2022-11-02
    • 2021-03-03
    • 2020-09-02
    • 1970-01-01
    • 2013-07-14
    • 1970-01-01
    • 2023-04-05
    • 2017-07-14
    • 2019-10-10
    相关资源
    最近更新 更多