cbor 1.0.2

  • README.md
  • Installing
  • Versions
  • 49


Build Status

A CBOR library for Dart developers.

This package provides an encoding/decoding package for the Concise Binary Object Representation as documented in RFC7049.

CBOR is increasingly used as a line protocol in the IOT world where the overhead of transmitting JSON on constrained devices can be large in packet size and processing overheads.

The Cbor package provides an RFC7049 compliant solution for both the encoding and decoding of CBOR data.

The test suite supports the encoding and decoding examples in Appendix A of RFC7049 amongst others. Specifically :-

  1. Half, Single and Double precision floats are supported.
  2. Tag based encoding is supported(table 3 of the RFC).
  3. Indefinite item encoding/decoding is supported.
  4. Items can be nested to any level.
  5. All Major tag types are supported.
  6. Smallest size first is used, i.e. if an int can be encoded in one byte then this size is used, similarly a double will be encoded into its smallest precision size(unless you specify otherwise);

The implementation of maps restricts map keys to be of either string or integer type, note however that at the moment decoding to JSON will fail if map keys are not strings.

Please examine the files in the examples directory for usage examples and the API docs for greater detail.

In general the package guarantees to decode what it encodes and should decode all well formed CBOR data. Decoded output takes the form of standard Dart types, i.e. floats become doubles, text become String, arrays become Lists etc. This allows a simple interface for encoding from the Dart world and a simple interface to Dart world from the decoder.

Currently the package supports a payload based decoding, i.e. a complete CBOR entity needs to be submitted to the decoder. Streamed decoding may be supported in future versions. Also error handling is somewhat basic, very badly formed CBOR data may trigger exceptions in the decoding process, if you need to protect against this please enclose all decoding operations in try/catch blocks. If you use this package at both ends of your CBOR interchange nodes you will not need to do this.



  • SDK version constraint update


  • Minor update to the README, issue 1.


  • Initial version

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  cbor: "^1.0.2"

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

      import 'package:cbor/cbor.dart';
Version Uploaded Documentation Archive
1.0.4 Feb 16, 2018 Go to the documentation of cbor 1.0.4 Download cbor 1.0.4 archive
1.0.3 Dec 11, 2017 Go to the documentation of cbor 1.0.3 Download cbor 1.0.3 archive
1.0.2 Jul 14, 2017 Go to the documentation of cbor 1.0.2 Download cbor 1.0.2 archive
1.0.1 May 4, 2017 Go to the documentation of cbor 1.0.1 Download cbor 1.0.1 archive
1.0.0 Apr 11, 2017 Go to the documentation of cbor 1.0.0 Download cbor 1.0.0 archive


We analyzed this package on Jul 14, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3


Describes how popular the package is relative to other packages. [more]
0 / 100
Code health derived from static analysis. [more]
99 / 100
Reflects how tidy and up-to-date the package is. [more]
94 / 100
Overall score:
Weighted score of the above. [more]
Learn more about scoring.


Detected platforms: Flutter, web, other

No platform restriction found in primary library package:cbor/cbor.dart.


  • Use constrained dependencies.

    The pubspec.yaml contains 2 dependencies without version constraints. Specify version ranges for the following dependencies: json_mapper, typed_data.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 1 error 7 hints.

    Strong-mode analysis of lib/src/cbor_item_stack.dart failed with the following error:

    line: 21 col: 27
    Couldn't infer type parameter 'E'.\n\nTried to infer 'LinkedListEntry<dynamic>' for 'E' which doesn't work:\n Type parameter 'E' declared to extend 'LinkedListEntry<LinkedListEntry<dynamic>>'.\nThe type 'LinkedListEntry<dynamic>' was inferred from:\n Return type declared as 'LinkedList<E>'\n used where 'LinkedList<LinkedListEntry<dynamic>>' is required.\n\nConsider passing explicit type argument(s) to the generic.\n\n

    Run dartfmt to format lib/src/cbor_encoder.dart.

    Similar analysis of the following files failed:

    • lib/src/cbor_input.dart (hint)
    • lib/src/cbor_listener_stack.dart (hint)
    • lib/src/cbor_numeric_support.dart (hint)
  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Maintain an example.

    None of the files in your example/ directory matches a known example patterns. Common file name patterns include: main.dart, example.dart or you could also use cbor.dart.

  • Package is getting outdated.

    The package was released 52 weeks ago.

  • Use analysis_options.yaml.

    Rename old .analysis_options file to analysis_options.yaml.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.0.0 <2.0.0-dev.infinity
json_mapper >=0.2.0 0.2.0
typed_data >=1.1.3 1.1.5
Transitive dependencies
path 1.6.1
stack_trace 1.9.2
unittest 0.11.7 0.12.4+1
Dev dependencies
coverage ^0.7.3
dart_dev ^1.0.0
dart_style >=0.2.0 <0.3.0
dartdoc >=0.8.0 <=0.10.0
test ^0.12.0