如何解决为什么 Flutter App 降级会导致数据丢失?
问题:
我有一个使用 sembast
和 shared_preferences
来存储数据的应用。
最近我不小心降级了我的应用,导致它丢失了所有存储的数据。
我在物理设备和模拟器设备上对其进行了测试,两者都导致了相同的问题。 有没有办法解决这个问题?
注意:“修复这个”是指在降级的情况下防止进一步的数据丢失,而不是恢复丢失的数据)
重现步骤:
1)创建项目
2) 在共享引用或 sembast 中存储数据
3)热重启
4) 将版本号更改为比之前版本号更低的编号(例如:1.0.0+110 到 1.0.0+109)
5)热重启
Pubspec.yaml
version: 1.0.0+111
environment:
sdk: ">=2.9.0 <3.0.0"
dependencies:
Flutter:
sdk: Flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.3
excel: ^2.0.0-null-safety-3
shared_preferences: ^2.0.6
permission_handler: ^8.1.1
path_provider: ^2.0.2
sembast: ^3.1.0+2
sembast_web: ^2.0.0+2 #remove web version not being used
intl: ^0.17.0
provider: ^5.0.0
firebase_core: ^1.3.0
firebase_analytics: ^8.1.2
firebase_performance: ^0.7.0+5
firebase_crashlytics: ^2.0.6
firebase_auth: ^1.4.1
get_it: ^7.1.3
open_file: ^3.2.1
Flutter_bloc: ^7.0.1
cloud_firestore: ^2.2.2 #remove and maybe use cloud functions
syncfusion_Flutter_charts: ^19.1.69+1
url_launcher: ^6.0.3
file_picker: ^3.0.3
Flutter_typeahead: ^3.1.3
purchases_Flutter: ^3.3.0
device_info_plus: ^2.0.1
颤振医生:
[√] Flutter (Channel stable,2.2.2,on Microsoft Windows [Version 10.0.19043.1081],locale en-IN)
• Flutter version 2.2.2 at D:\Applications\Flutter
• Framework revision d79295af24 (2 weeks ago),2021-06-11 08:56:01 -0700
• Engine revision 91c9fc8fe0
• Dart version 2.13.3
[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0-rc1)
• Android SDK at D:\Applications\Android-SDK
• Platform android-S,build-tools 31.0.0-rc1
• Java binary at: D:\Applications\Android_studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
[√] Android Studio (version 4.1.0)
• Android Studio at D:\Applications\Android_studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-Flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)
[√] Connected device (3 available)
• sdk gphone x86 (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 91.0.4472.114
• Edge (web) • edge • web-javascript • Microsoft Edge 91.0.864.37
• No issues found!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。