Flutter Engine
The Flutter Engine
Instance Methods | Class Methods | List of all members
FlutterStandardMethodCodec Class Reference

#import <FlutterCodecs.h>

Inheritance diagram for FlutterStandardMethodCodec:

Instance Methods

(instancetype) - initWithReaderWriter: [implementation]
 
(NSData *) - encodeMethodCall: [implementation]
 
(NSData *) - encodeSuccessEnvelope: [implementation]
 
(NSData *) - encodeErrorEnvelope: [implementation]
 
(FlutterMethodCall *) - decodeMethodCall: [implementation]
 
(id- decodeEnvelope: [implementation]
 

Class Methods

(instancetype) + codecWithReaderWriter:
 
(instancetype) + sharedInstance [implementation]
 

Detailed Description

A FlutterMethodCodec using the Flutter standard binary encoding.

This codec is guaranteed to be compatible with the corresponding StandardMethodCodec on the Dart side. These parts of the Flutter SDK are evolved synchronously.

Values supported as method arguments and result payloads are those supported by FlutterStandardMessageCodec.

Definition at line 469 of file FlutterCodecs.h.

Method Documentation

◆ codecWithReaderWriter:

+ (instancetype) codecWithReaderWriter: (FlutterStandardReaderWriter*)  readerWriter

Create a FlutterStandardMethodCodec who will read and write to readerWriter.

Definition at line 8 of file FlutterStandardCodec.mm.

70 :(FlutterStandardReaderWriter*)readerWriter {
71 return [[FlutterStandardMethodCodec alloc] initWithReaderWriter:readerWriter];
72}

◆ decodeEnvelope:

- (id) decodeEnvelope: (NSData*)  envelope
implementation

Definition at line 8 of file FlutterStandardCodec.mm.

116 :(NSData*)envelope {
117 FlutterStandardReader* reader = [_readerWriter readerWithData:envelope];
118 UInt8 flag = [reader readByte];
119 NSAssert(flag <= 1, @"Corrupted standard envelope");
120 id result;
121 switch (flag) {
122 case 0: {
123 result = [reader readValue];
124 NSAssert(![reader hasMore], @"Corrupted standard envelope");
125 } break;
126 case 1: {
127 id code = [reader readValue];
128 id message = [reader readValue];
129 id details = [reader readValue];
130 NSAssert(![reader hasMore], @"Corrupted standard envelope");
131 NSAssert([code isKindOfClass:[NSString class]], @"Invalid standard envelope");
132 NSAssert(message == nil || [message isKindOfClass:[NSString class]],
133 @"Invalid standard envelope");
134 result = [FlutterError errorWithCode:code message:message details:details];
135 } break;
136 }
137 return result;
138}
FlutterSemanticsFlag flag
GAsyncResult * result
instancetype errorWithCode:message:details:(NSString *code,[message] NSString *_Nullable message,[details] id _Nullable details)
Win32Message message

◆ decodeMethodCall:

- (FlutterMethodCall *) decodeMethodCall: (NSData*)  message
implementation

Definition at line 8 of file FlutterStandardCodec.mm.

107 :(NSData*)message {
108 FlutterStandardReader* reader = [_readerWriter readerWithData:message];
109 id value1 = [reader readValue];
110 id value2 = [reader readValue];
111 NSAssert(![reader hasMore], @"Corrupted standard method call");
112 NSAssert([value1 isKindOfClass:[NSString class]], @"Corrupted standard method call");
114}
instancetype methodCallWithMethodName:arguments:(NSString *method,[arguments] id _Nullable arguments)

◆ encodeErrorEnvelope:

- (NSData *) encodeErrorEnvelope: (FlutterError*)  error
implementation

Definition at line 8 of file FlutterStandardCodec.mm.

98 NSMutableData* data = [NSMutableData dataWithCapacity:32];
99 FlutterStandardWriter* writer = [_readerWriter writerWithData:data];
100 [writer writeByte:1];
101 [writer writeValue:error.code];
102 [writer writeValue:error.message];
103 [writer writeValue:error.details];
104 return data;
105}
const uint8_t uint32_t uint32_t GError ** error
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ encodeMethodCall:

- (NSData *) encodeMethodCall: (FlutterMethodCall*)  call
implementation

Definition at line 8 of file FlutterStandardCodec.mm.

82 NSMutableData* data = [NSMutableData dataWithCapacity:32];
83 FlutterStandardWriter* writer = [_readerWriter writerWithData:data];
84 [writer writeValue:call.method];
85 [writer writeValue:call.arguments];
86 return data;
87}
def call(args)
Definition: dom.py:159

◆ encodeSuccessEnvelope:

- (NSData *) encodeSuccessEnvelope: (id result
implementation

Definition at line 8 of file FlutterStandardCodec.mm.

89 :(id)result {
90 NSMutableData* data = [NSMutableData dataWithCapacity:32];
91 FlutterStandardWriter* writer = [_readerWriter writerWithData:data];
92 [writer writeByte:0];
93 [writer writeValue:result];
94 return data;
95}
const uintptr_t id

◆ initWithReaderWriter:

- (instancetype) initWithReaderWriter: (FlutterStandardReaderWriter*)  readerWriter
implementation

Definition at line 8 of file FlutterStandardCodec.mm.

74 :(FlutterStandardReaderWriter*)readerWriter {
75 self = [super init];
76 NSAssert(self, @"Super init cannot be nil");
77 _readerWriter = readerWriter;
78 return self;
79}

◆ sharedInstance

+ (instancetype) sharedInstance
implementation

Definition at line 8 of file FlutterStandardCodec.mm.

61 {
62 static id _sharedInstance = nil;
63 if (!_sharedInstance) {
64 FlutterStandardReaderWriter* readerWriter = [[FlutterStandardReaderWriter alloc] init];
65 _sharedInstance = [[FlutterStandardMethodCodec alloc] initWithReaderWriter:readerWriter];
66 }
67 return _sharedInstance;
68}

The documentation for this class was generated from the following files: