toCallable method
Convert for Firebase callable functions.
Timestamps are kept as milliseconds and server-managed timestamp fields (from getCreateTimestampFields and getUpdateTimestampFields) are removed since the server will add them.
Sending Data
final callable = FirebaseFunctions.instance.httpsCallable('createPost');
await callable.call(post.toCallable());
Receiving Data
To deserialize responses from callable functions, use your model's
fromJson factory. The SmartTimestampConverter automatically handles
all timestamp formats returned by Cloud Functions.
final callable = FirebaseFunctions.instance.httpsCallable('getPost');
final result = await callable.call({'postId': 'abc123'});
final post = PostModel.fromJson(result.data as Map<String, dynamic>);
Supported timestamp formats in responses:
{_seconds: int, _nanoseconds: int}(Cloud Functions format){seconds: int, nanoseconds: int}(standard format)- Milliseconds since epoch (int)
- ISO 8601 strings
Implementation
Map<String, dynamic> toCallable() {
final json = toJson();
return _processForContext(json, SerializationContext.callable);
}