debugIsSerializableForRestoration function Null safety

bool debugIsSerializableForRestoration (
  1. Object? object
)

Returns true when the provided object is serializable for state restoration.

Should only be called from within asserts. Always returns false outside of debug builds.

Implementation

bool debugIsSerializableForRestoration(Object? object) {
  bool result = false;

  assert(() {
    try {
      const StandardMessageCodec().encodeMessage(object);
      result = true;
    } catch (_) {
      result = false;
    }
    return true;
  }());

  return result;
}