binary_codec 1.0.4 copy "binary_codec: ^1.0.4" to clipboard
binary_codec: ^1.0.4 copied to clipboard

outdated

Converts null, bools, ints, doubles, Uint8Lists, Strings, Maps and Lists into a binary format and back

example/main.dart

import 'dart:convert';
import 'dart:typed_data';

import 'package:binary_codec/binary_codec.dart';

void main() {
  Map info = {
    'allowedTypes': [
      null,
      true,
      false,
      'Any strings',
      utf8.encode('Any Uint8Lists'),
      12385.12385734,
      -1293573.1324543,
      "'any' ints",
      {
        'sets': 'are also allowed',
      },
      [
        'lists',
        'are also allowed',
      ]
    ],
    'note about ints':
        'Care about the floating-int-mess in javascript (for dart2js only integers in the safe range are handled correctly)',
    'note about keys': {
      'description': 'You can use any of the allowedTypes for keys',
      'example': {
        123: 'asdf',
        124.235: 'qwer',
        true: 'x',
        null: 'y',
        Uint8List.fromList([255, 0, 218, 17]): 'z',
      },
    },
    'note about root type':
        'Note that you can pass any of the allowed types into the decoder, not just maps',
  };
  Uint8List encoded = binaryCodec.encode(info);

  var decoded = binaryCodec.decode(encoded);

  assert(info.toString() == decoded.toString());

  print(decoded.toString());
}
7
likes
20
pub points
67%
popularity

Publisher

unverified uploader

Converts null, bools, ints, doubles, Uint8Lists, Strings, Maps and Lists into a binary format and back

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on binary_codec