1234567891011121314151617181920212223242526272829 |
- class JsonRpcRequest {
- static const String _serverVersion = '2.0';
- final String method;
- final Object? args;
- final bool notify;
- int? get id => !this.notify ? this.hashCode : null;
- JsonRpcRequest(this.method, this.args, {this.notify = false});
- Map<String, dynamic> toJson() {
- var map = <String, dynamic>{};
- map = {
- 'jsonrpc': _serverVersion,
- 'method': method,
- 'params': (args == null)
- ? []
- : (args is List || args is Map)
- ? args
- : [args]
- };
- if (!notify) map['id'] = id;
- return map;
- }
- @override
- String toString() => 'JsonRpcRequest: ${toJson()}';
- }
|