1 // Copyright 2013 The Flutter Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 package io.flutter.plugin.common; 6 7 import java.nio.ByteBuffer; 8 9 /** 10 * A {@link MessageCodec} using unencoded binary messages, represented as 11 * {@link ByteBuffer}s. 12 * 13 * <p>This codec is guaranteed to be compatible with the corresponding 14 * <a href="https://docs.flutter.io/flutter/services/BinaryCodec-class.html">BinaryCodec</a> 15 * on the Dart side. These parts of the Flutter SDK are evolved synchronously.</p> 16 * 17 * <p>On the Dart side, messages are represented using {@code ByteData}.</p> 18 */ 19 public final class BinaryCodec implements MessageCodec<ByteBuffer> { 20 // This codec must match the Dart codec of the same name in package flutter/services. 21 public static final BinaryCodec INSTANCE = new BinaryCodec(); 22 BinaryCodec()23 private BinaryCodec() { 24 } 25 26 @Override encodeMessage(ByteBuffer message)27 public ByteBuffer encodeMessage(ByteBuffer message) { 28 return message; 29 } 30 31 @Override decodeMessage(ByteBuffer message)32 public ByteBuffer decodeMessage(ByteBuffer message) { 33 return message; 34 } 35 } 36