<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, user-scalable=no"><meta name="description" content="API docs for the StandardMessageCodec class from the services library, for the Dart programming language."><title>StandardMessageCodec class - services library - Dart API</title><!-- required because all the links are pseudo-absolute --><base href=".."><link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:500,400i,400,300|Source+Sans+Pro:400,300,700" rel="stylesheet"><link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"><link rel="stylesheet" href="static-assets/github.css"><link rel="stylesheet" href="static-assets/styles.css"><link rel="icon" href="static-assets/favicon.png"></head><body><div id="overlay-under-drawer"></div><header id="title"><button id="sidenav-left-toggle" type="button"> </button><ol class="breadcrumbs gt-separated dark hidden-xs"><li><a href="index.html">flutter</a></li><li><a href="services/services-library.html">services</a></li><li class="self-crumb">StandardMessageCodec class</li></ol><div class="self-name">StandardMessageCodec</div><form class="search navbar-right" role="search"><input type="text" id="search-box" autocomplete="off" disabled class="form-control typeahead" placeholder="Loading search..."></form></header><main><div id="dartdoc-sidebar-left" class="col-xs-6 col-sm-3 col-md-2 sidebar sidebar-offcanvas-left"><header id="header-search-sidebar" class="hidden-l"><form class="search-sidebar" role="search"><input type="text" id="search-sidebar" autocomplete="off" disabled class="form-control typeahead" placeholder="Loading search..."></form></header><ol class="breadcrumbs gt-separated dark hidden-l" id="sidebar-nav"><li><a href="index.html">flutter</a></li><li><a href="services/services-library.html">services</a></li><li class="self-crumb">StandardMessageCodec class</li></ol><h5>services library</h5><ol><li class="section-title"><a href="services/services-library.html#classes">Classes</a></li><li><a href="services/AndroidMotionEvent-class.html">AndroidMotionEvent</a></li><li><a href="services/AndroidPointerCoords-class.html">AndroidPointerCoords</a></li><li><a href="services/AndroidPointerProperties-class.html">AndroidPointerProperties</a></li><li><a href="services/AndroidViewController-class.html">AndroidViewController</a></li><li><a href="services/ApplicationSwitcherDescription-class.html">ApplicationSwitcherDescription</a></li><li><a href="services/AssetBundle-class.html">AssetBundle</a></li><li><a href="services/BasicMessageChannel-class.html">BasicMessageChannel</a></li><li><a href="services/BinaryCodec-class.html">BinaryCodec</a></li><li><a class="deprecated" href="services/BinaryMessages-class.html">BinaryMessages</a></li><li><a href="services/BinaryMessenger-class.html">BinaryMessenger</a></li><li><a href="services/BlacklistingTextInputFormatter-class.html">BlacklistingTextInputFormatter</a></li><li><a href="dart-typed_data/ByteData-class.html">ByteData</a></li><li><a href="services/CachingAssetBundle-class.html">CachingAssetBundle</a></li><li><a href="services/Clipboard-class.html">Clipboard</a></li><li><a href="services/ClipboardData-class.html">ClipboardData</a></li><li><a href="services/EventChannel-class.html">EventChannel</a></li><li><a href="services/FontLoader-class.html">FontLoader</a></li><li><a href="services/GLFWKeyHelper-class.html">GLFWKeyHelper</a></li><li><a href="services/HapticFeedback-class.html">HapticFeedback</a></li><li><a href="services/JSONMessageCodec-class.html">JSONMessageCodec</a></li><li><a href="services/JSONMethodCodec-class.html">JSONMethodCodec</a></li><li><a href="services/KeyboardKey-class.html">KeyboardKey</a></li><li><a href="services/KeyHelper-class.html">KeyHelper</a></li><li><a href="services/LengthLimitingTextInputFormatter-class.html">LengthLimitingTextInputFormatter</a></li><li><a href="services/LogicalKeyboardKey-class.html">LogicalKeyboardKey</a></li><li><a href="services/MessageCodec-class.html">MessageCodec</a></li><li><a href="services/MethodCall-class.html">MethodCall</a></li><li><a href="services/MethodChannel-class.html">MethodChannel</a></li><li><a href="services/MethodCodec-class.html">MethodCodec</a></li><li><a href="services/NetworkAssetBundle-class.html">NetworkAssetBundle</a></li><li><a href="services/OptionalMethodChannel-class.html">OptionalMethodChannel</a></li><li><a href="services/PhysicalKeyboardKey-class.html">PhysicalKeyboardKey</a></li><li><a href="services/PlatformAssetBundle-class.html">PlatformAssetBundle</a></li><li><a href="services/PlatformViewController-class.html">PlatformViewController</a></li><li><a href="services/PlatformViewsRegistry-class.html">PlatformViewsRegistry</a></li><li><a href="services/PlatformViewsService-class.html">PlatformViewsService</a></li><li><a href="services/RawFloatingCursorPoint-class.html">RawFloatingCursorPoint</a></li><li><a href="services/RawKeyboard-class.html">RawKeyboard</a></li><li><a href="services/RawKeyDownEvent-class.html">RawKeyDownEvent</a></li><li><a href="services/RawKeyEvent-class.html">RawKeyEvent</a></li><li><a href="services/RawKeyEventData-class.html">RawKeyEventData</a></li><li><a href="services/RawKeyEventDataAndroid-class.html">RawKeyEventDataAndroid</a></li><li><a href="services/RawKeyEventDataFuchsia-class.html">RawKeyEventDataFuchsia</a></li><li><a href="services/RawKeyEventDataLinux-class.html">RawKeyEventDataLinux</a></li><li><a href="services/RawKeyEventDataMacOs-class.html">RawKeyEventDataMacOs</a></li><li><a href="services/RawKeyUpEvent-class.html">RawKeyUpEvent</a></li><li><a href="services/StandardMessageCodec-class.html">StandardMessageCodec</a></li><li><a href="services/StandardMethodCodec-class.html">StandardMethodCodec</a></li><li><a href="services/StringCodec-class.html">StringCodec</a></li><li><a href="services/SystemChannels-class.html">SystemChannels</a></li><li><a href="services/SystemChrome-class.html">SystemChrome</a></li><li><a href="services/SystemNavigator-class.html">SystemNavigator</a></li><li><a href="services/SystemSound-class.html">SystemSound</a></li><li><a href="services/SystemUiOverlayStyle-class.html">SystemUiOverlayStyle</a></li><li><a href="services/TextEditingValue-class.html">TextEditingValue</a></li><li><a href="services/TextInput-class.html">TextInput</a></li><li><a href="services/TextInputClient-class.html">TextInputClient</a></li><li><a href="services/TextInputConfiguration-class.html">TextInputConfiguration</a></li><li><a href="services/TextInputConnection-class.html">TextInputConnection</a></li><li><a href="services/TextInputFormatter-class.html">TextInputFormatter</a></li><li><a href="services/TextInputType-class.html">TextInputType</a></li><li><a href="dart-ui/TextPosition-class.html">TextPosition</a></li><li><a href="services/TextRange-class.html">TextRange</a></li><li><a href="services/TextSelection-class.html">TextSelection</a></li><li><a href="services/TextSelectionDelegate-class.html">TextSelectionDelegate</a></li><li><a href="services/UiKitViewController-class.html">UiKitViewController</a></li><li><a href="services/WhitelistingTextInputFormatter-class.html">WhitelistingTextInputFormatter</a></li><li class="section-title"><a href="services/services-library.html#mixins">Mixins</a></li><li><a href="services/ServicesBinding-mixin.html">ServicesBinding</a></li><li class="section-title"><a href="services/services-library.html#constants">Constants</a></li><li><a href="services/defaultBinaryMessenger-constant.html">defaultBinaryMessenger</a></li><li class="section-title"><a href="services/services-library.html#properties">Properties</a></li><li><a href="services/platformViewsRegistry.html">platformViewsRegistry</a></li><li><a href="services/rootBundle.html">rootBundle</a></li><li class="section-title"><a href="services/services-library.html#enums">Enums</a></li><li><a href="dart-ui/Brightness-class.html">Brightness</a></li><li><a href="services/DeviceOrientation-class.html">DeviceOrientation</a></li><li><a href="services/FloatingCursorDragState-class.html">FloatingCursorDragState</a></li><li><a href="services/KeyboardSide-class.html">KeyboardSide</a></li><li><a href="services/ModifierKey-class.html">ModifierKey</a></li><li><a href="services/SystemSoundType-class.html">SystemSoundType</a></li><li><a href="services/SystemUiOverlay-class.html">SystemUiOverlay</a></li><li><a href="dart-ui/TextAffinity-class.html">TextAffinity</a></li><li><a href="services/TextCapitalization-class.html">TextCapitalization</a></li><li><a href="services/TextInputAction-class.html">TextInputAction</a></li><li class="section-title"><a href="services/services-library.html#typedefs">Typedefs</a></li><li><a href="services/MessageHandler.html">MessageHandler</a></li><li><a href="services/PlatformViewCreatedCallback.html">PlatformViewCreatedCallback</a></li><li><a href="services/TextInputFormatFunction.html">TextInputFormatFunction</a></li><li class="section-title"><a href="services/services-library.html#exceptions">Exceptions</a></li><li><a href="services/MissingPluginException-class.html">MissingPluginException</a></li><li><a href="services/PlatformException-class.html">PlatformException</a></li></ol></div><div id="dartdoc-main-content" class="col-xs-12 col-sm-9 col-md-8 main-content"><div><h1><span class="kind-class">StandardMessageCodec</span> class </h1></div><section class="desc markdown"><p><a href="services/MessageCodec-class.html">MessageCodec</a> using the Flutter standard binary encoding.</p><p>Supported messages are acyclic values of these forms:</p><ul><li>null</li><li><a href="dart-core/bool-class.html">bool</a>s</li><li><a href="dart-core/num-class.html">num</a>s</li><li><a href="dart-core/String-class.html">String</a>s</li><li><a href="dart-typed_data/Uint8List-class.html">Uint8List</a>s, <a href="dart-typed_data/Int32List-class.html">Int32List</a>s, <a href="dart-typed_data/Int64List-class.html">Int64List</a>s, <a href="dart-typed_data/Float64List-class.html">Float64List</a>s</li><li><a href="dart-core/List-class.html">List</a>s of supported values</li><li><a href="dart-core/Map-class.html">Map</a>s from supported values to supported values</li></ul><p>Decoded values will use <code>List<dynamic></code> and <code>Map<dynamic, dynamic></code>irrespective of content.</p><p>On Android, messages are represented as follows:</p><ul><li>null: null</li><li><a href="dart-core/bool-class.html">bool</a>: <code>java.lang.Boolean</code></li><li><a href="dart-core/int-class.html">int</a>: <code>java.lang.Integer</code> for values that are representable using 32-bittwo's complement; <code>java.lang.Long</code> otherwise</li><li><a href="dart-core/double-class.html">double</a>: <code>java.lang.Double</code></li><li><a href="dart-core/String-class.html">String</a>: <code>java.lang.String</code></li><li><a href="dart-typed_data/Uint8List-class.html">Uint8List</a>: <code>byte[]</code></li><li><a href="dart-typed_data/Int32List-class.html">Int32List</a>: <code>int[]</code></li><li><a href="dart-typed_data/Int64List-class.html">Int64List</a>: <code>long[]</code></li><li><a href="dart-typed_data/Float64List-class.html">Float64List</a>: <code>double[]</code></li><li><a href="dart-core/List-class.html">List</a>: <code>java.util.ArrayList</code></li><li><a href="dart-core/Map-class.html">Map</a>: <code>java.util.HashMap</code></li></ul><p>On iOS, messages are represented as follows:</p><ul><li>null: nil</li><li><a href="dart-core/bool-class.html">bool</a>: <code>NSNumber numberWithBool:</code></li><li><a href="dart-core/int-class.html">int</a>: <code>NSNumber numberWithInt:</code> for values that are representable using32-bit two's complement; <code>NSNumber numberWithLong:</code> otherwise</li><li><a href="dart-core/double-class.html">double</a>: <code>NSNumber numberWithDouble:</code></li><li><a href="dart-core/String-class.html">String</a>: <code>NSString</code></li><li><a href="dart-typed_data/Uint8List-class.html">Uint8List</a>, <a href="dart-typed_data/Int32List-class.html">Int32List</a>, <a href="dart-typed_data/Int64List-class.html">Int64List</a>, <a href="dart-typed_data/Float64List-class.html">Float64List</a>:<code>FlutterStandardTypedData</code></li><li><a href="dart-core/List-class.html">List</a>: <code>NSArray</code></li><li><a href="dart-core/Map-class.html">Map</a>: <code>NSDictionary</code></li></ul><p>When sending a <code>java.math.BigInteger</code> from Java, it is converted into a<a href="dart-core/String-class.html">String</a> with the hexadecimal representation of the integer. (The value istagged as being a big integer; subclasses of this class could be made tosupport it natively; see the discussion at <a href="services/StandardMessageCodec/writeValue.html">writeValue</a>.) This codec doesnot support sending big integers from Dart.</p><p>The codec is extensible by subclasses overriding <a href="services/StandardMessageCodec/writeValue.html">writeValue</a> and<a href="services/StandardMessageCodec/readValueOfType.html">readValueOfType</a>.</p></section><section><dl class="dl-horizontal"><dt>Implemented types</dt><dd><ul class="comma-separated clazz-relationships"><li><a href="services/MessageCodec-class.html">MessageCodec</a></li></ul></dd></dl></section><section class="summary offset-anchor" id="constructors"><h2>Constructors</h2><dl class="constructor-summary-list"><dt id="StandardMessageCodec" class="callable"><span class="name"><a href="services/StandardMessageCodec/StandardMessageCodec.html">StandardMessageCodec</a></span><span class="signature">()</span></dt><dd>Creates a <a href="services/MessageCodec-class.html">MessageCodec</a> using the Flutter standard binary encoding.<div class="constructor-modifier features">const</div></dd></dl></section><section class="summary offset-anchor inherited" id="instance-properties"><h2>Properties</h2><dl class="properties"><dt id="hashCode" class="property inherited"><span class="name"><a href="dart-core/Object/hashCode.html">hashCode</a></span><span class="signature">→ <a href="dart-core/int-class.html">int</a></span></dt><dd class="inherited">The hash code for this object. <a href="dart-core/Object/hashCode.html">[...]</a><div class="features">read-only, inherited</div></dd><dt id="runtimeType" class="property inherited"><span class="name"><a href="dart-core/Object/runtimeType.html">runtimeType</a></span><span class="signature">→ <a href="dart-core/Type-class.html">Type</a></span></dt><dd class="inherited">A representation of the runtime type of the object.<div class="features">read-only, inherited</div></dd></dl></section><section class="summary offset-anchor" id="instance-methods"><h2>Methods</h2><dl class="callables"><dt id="decodeMessage" class="callable"><span class="name"><a href="services/StandardMessageCodec/decodeMessage.html">decodeMessage</a></span><span class="signature">(<wbr><span class="parameter" id="decodeMessage-param-message"><span class="type-annotation"><a href="dart-typed_data/ByteData-class.html">ByteData</a></span> <span class="parameter-name">message</span></span>)<span class="returntype parameter">→ dynamic</span></span></dt><dd>Decodes the specified <code>message</code> from binary. <a href="services/StandardMessageCodec/decodeMessage.html">[...]</a><div class="features">override</div></dd><dt id="encodeMessage" class="callable"><span class="name"><a href="services/StandardMessageCodec/encodeMessage.html">encodeMessage</a></span><span class="signature">(<wbr><span class="parameter" id="encodeMessage-param-message"><span class="type-annotation">dynamic</span> <span class="parameter-name">message</span></span>)<span class="returntype parameter">→ <a href="dart-typed_data/ByteData-class.html">ByteData</a></span></span></dt><dd>Encodes the specified <code>message</code> in binary. <a href="services/StandardMessageCodec/encodeMessage.html">[...]</a><div class="features">override</div></dd><dt id="readSize" class="callable"><span class="name"><a href="services/StandardMessageCodec/readSize.html">readSize</a></span><span class="signature">(<wbr><span class="parameter" id="readSize-param-buffer"><span class="type-annotation"><a href="foundation/ReadBuffer-class.html">ReadBuffer</a></span> <span class="parameter-name">buffer</span></span>)<span class="returntype parameter">→ <a href="dart-core/int-class.html">int</a></span></span></dt><dd>Reads a non-negative int from <code>buffer</code> as written by <a href="services/StandardMessageCodec/writeSize.html">writeSize</a>. <a href="services/StandardMessageCodec/readSize.html">[...]</a></dd><dt id="readValue" class="callable"><span class="name"><a href="services/StandardMessageCodec/readValue.html">readValue</a></span><span class="signature">(<wbr><span class="parameter" id="readValue-param-buffer"><span class="type-annotation"><a href="foundation/ReadBuffer-class.html">ReadBuffer</a></span> <span class="parameter-name">buffer</span></span>)<span class="returntype parameter">→ dynamic</span></span></dt><dd>Reads a value from <code>buffer</code> as written by <a href="services/StandardMessageCodec/writeValue.html">writeValue</a>. <a href="services/StandardMessageCodec/readValue.html">[...]</a></dd><dt id="readValueOfType" class="callable"><span class="name"><a href="services/StandardMessageCodec/readValueOfType.html">readValueOfType</a></span><span class="signature">(<wbr><span class="parameter" id="readValueOfType-param-type"><span class="type-annotation"><a href="dart-core/int-class.html">int</a></span> <span class="parameter-name">type</span>, </span> <span class="parameter" id="readValueOfType-param-buffer"><span class="type-annotation"><a href="foundation/ReadBuffer-class.html">ReadBuffer</a></span> <span class="parameter-name">buffer</span></span>)<span class="returntype parameter">→ dynamic</span></span></dt><dd>Reads a value of the indicated <code>type</code> from <code>buffer</code>. <a href="services/StandardMessageCodec/readValueOfType.html">[...]</a></dd><dt id="writeSize" class="callable"><span class="name"><a href="services/StandardMessageCodec/writeSize.html">writeSize</a></span><span class="signature">(<wbr><span class="parameter" id="writeSize-param-buffer"><span class="type-annotation"><a href="foundation/WriteBuffer-class.html">WriteBuffer</a></span> <span class="parameter-name">buffer</span>, </span> <span class="parameter" id="writeSize-param-value"><span class="type-annotation"><a href="dart-core/int-class.html">int</a></span> <span class="parameter-name">value</span></span>)<span class="returntype parameter">→ void</span></span></dt><dd>Writes a non-negative 32-bit integer <code>value</code> to <code>buffer</code>using an expanding 1-5 byte encoding that optimizes for small values. <a href="services/StandardMessageCodec/writeSize.html">[...]</a></dd><dt id="writeValue" class="callable"><span class="name"><a href="services/StandardMessageCodec/writeValue.html">writeValue</a></span><span class="signature">(<wbr><span class="parameter" id="writeValue-param-buffer"><span class="type-annotation"><a href="foundation/WriteBuffer-class.html">WriteBuffer</a></span> <span class="parameter-name">buffer</span>, </span> <span class="parameter" id="writeValue-param-value"><span class="type-annotation">dynamic</span> <span class="parameter-name">value</span></span>)<span class="returntype parameter">→ void</span></span></dt><dd>Writes <code>value</code> to <code>buffer</code> by first writing a type discriminatorbyte, then the value itself. <a href="services/StandardMessageCodec/writeValue.html">[...]</a></dd><dt id="noSuchMethod" class="callable inherited"><span class="name"><a href="dart-core/Object/noSuchMethod.html">noSuchMethod</a></span><span class="signature">(<wbr><span class="parameter" id="noSuchMethod-param-invocation"><span class="type-annotation"><a href="dart-core/Invocation-class.html">Invocation</a></span> <span class="parameter-name">invocation</span></span>)<span class="returntype parameter">→ dynamic</span></span></dt><dd class="inherited">Invoked when a non-existent method or property is accessed. <a href="dart-core/Object/noSuchMethod.html">[...]</a><div class="features">inherited</div></dd><dt id="toString" class="callable inherited"><span class="name"><a href="dart-core/Object/toString.html">toString</a></span><span class="signature">(<wbr>)<span class="returntype parameter">→ <a href="dart-core/String-class.html">String</a></span></span></dt><dd class="inherited">Returns a string representation of this object.<div class="features">inherited</div></dd></dl></section><section class="summary offset-anchor inherited" id="operators"><h2>Operators</h2><dl class="callables"><dt id="operator ==" class="callable inherited"><span class="name"><a href="dart-core/Object/operator_equals.html">operator ==</a></span><span class="signature">(<wbr><span class="parameter" id="==-param-other"><span class="type-annotation">dynamic</span> <span class="parameter-name">other</span></span>)<span class="returntype parameter">→ <a href="dart-core/bool-class.html">bool</a></span></span></dt><dd class="inherited">The equality operator. <a href="dart-core/Object/operator_equals.html">[...]</a><div class="features">inherited</div></dd></dl></section></div> <!-- /.main-content --><div id="dartdoc-sidebar-right" class="col-xs-6 col-sm-6 col-md-2 sidebar sidebar-offcanvas-right"><ol><li class="section-title"><a href="services/StandardMessageCodec-class.html#constructors">Constructors</a></li><li><a href="services/StandardMessageCodec/StandardMessageCodec.html">StandardMessageCodec</a></li><li class="section-title inherited"><a href="services/StandardMessageCodec-class.html#instance-properties">Properties</a></li><li class="inherited"><a href="dart-core/Object/hashCode.html">hashCode</a></li><li class="inherited"><a href="dart-core/Object/runtimeType.html">runtimeType</a></li><li class="section-title"><a href="services/StandardMessageCodec-class.html#instance-methods">Methods</a></li><li><a href="services/StandardMessageCodec/decodeMessage.html">decodeMessage</a></li><li><a href="services/StandardMessageCodec/encodeMessage.html">encodeMessage</a></li><li><a href="services/StandardMessageCodec/readSize.html">readSize</a></li><li><a href="services/StandardMessageCodec/readValue.html">readValue</a></li><li><a href="services/StandardMessageCodec/readValueOfType.html">readValueOfType</a></li><li><a href="services/StandardMessageCodec/writeSize.html">writeSize</a></li><li><a href="services/StandardMessageCodec/writeValue.html">writeValue</a></li><li class="inherited"><a href="dart-core/Object/noSuchMethod.html">noSuchMethod</a></li><li class="inherited"><a href="dart-core/Object/toString.html">toString</a></li><li class="section-title inherited"><a href="services/StandardMessageCodec-class.html#operators">Operators</a></li><li class="inherited"><a href="dart-core/Object/operator_equals.html">operator ==</a></li></ol></div><!--/.sidebar-offcanvas--></main><footer><span class="no-break">flutter 0.0.0-unknown</span></footer><script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script><script src="static-assets/typeahead.bundle.min.js"></script><script src="static-assets/highlight.pack.js"></script><script src="static-assets/URI.js"></script><script src="static-assets/script.js"></script></body></html>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。