Firebase Flatter应用程序是否有办法在离线应用程序重新启动时保存数据?

Firebase Flatter应用程序是否有办法在离线应用程序重新启动时保存数据?,firebase,flutter,Firebase,Flutter,我正在使用firebase动画列表来显示存储在firebase实时数据库中的项目列表 现在,当我在离线状态下启动应用程序(在应用程序被杀死后),列表不会加载 是否有一种内置方法来离线存储此用例的数据(由firebase提供)?还是需要存储在某个脱机数据库中 我已经检查过了,但是找不到这个特定的用例 相关问题听起来像是FirebaseDatabase.setPersistenceEnabled /// Attempts to sets the database persistence to [

我正在使用firebase动画列表来显示存储在firebase实时数据库中的项目列表

现在,当我在离线状态下启动应用程序(在应用程序被杀死后),列表不会加载

是否有一种内置方法来离线存储此用例的数据(由firebase提供)?还是需要存储在某个脱机数据库中

我已经检查过了,但是找不到这个特定的用例


相关问题

听起来像是
FirebaseDatabase.setPersistenceEnabled

  /// Attempts to sets the database persistence to [enabled].
  ///
  /// This property must be set before calling methods on database references
  /// and only needs to be called once per application. The returned [Future]
  /// will complete with `true` if the operation was successful or `false` if
  /// the persistence could not be set (because database references have
  /// already been created).
  ///
  /// The Firebase Database client will cache synchronized data and keep track
  /// of all writes you’ve initiated while your application is running. It
  /// seamlessly handles intermittent network connections and re-sends write
  /// operations when the network connection is restored.
  ///
  /// However by default your write operations and cached data are only stored
  /// in-memory and will be lost when your app restarts. By setting [enabled]
  /// to `true`, the data will be persisted to on-device (disk) storage and will
  /// thus be available again when the app is restarted (even when there is no
  /// network connectivity at that time).
  Future<bool> setPersistenceEnabled(bool enabled) async {
    // ...
  }
///尝试将数据库持久性设置为[已启用]。
///
///必须在对数据库引用调用方法之前设置此属性
///并且每个应用程序只需要调用一次。回归[未来]
///如果操作成功,将以'true'结尾;如果操作成功,将以'false'结尾
///无法设置持久性(因为数据库引用已被删除)
///已创建)。
///
///Firebase数据库客户端将缓存同步数据并保持跟踪
///在应用程序运行时启动的所有写入操作中。信息技术
///无缝处理间歇性网络连接并重新发送写操作
///恢复网络连接时的操作。
///
///但是,默认情况下,只存储写入操作和缓存数据
///在内存中,并将在应用程序重新启动时丢失。通过设置[启用]
///若为“true”,则数据将持久化到设备(磁盘)存储器中,并将
///因此,当应用程序重新启动时(即使没有
///当时的网络连接)。
Future setPersistenceEnabled(bool enabled)异步{
// ...
}

来自

Firebase实时数据库或Firebase Cloud Firestore?对于Firebase实时数据库,如果“重新启动”被解释为应用程序在后台运行且未被终止,则是,setPersistenceEnabled可以工作,但我的使用案例是,应用程序被终止/终止,然后启动(处于脱机状态)。“在设备(磁盘)上持久化”应该能在终止的应用程序中生存。如果它不工作,请报告一个错误。确保您已尝试使用最新的插件版本,如果可能,还可以尝试使用flift
dev
channel.FirebaseDatabase.instance.setPersistenceEnabled(true);您可能忘记了.instance*before.setPersistenceEnabled。这是不久前更改的。从那以后我就没用过。