DataUri class

A utility to create data URIs

Data URIs are generally of the format

  data:[mimeType][;charset=encoding][;base64],data

Further Reading on Data URI Scheme

Example Usage:

DataUri di = new DataUri(
  data: DataUri.base64EncodeString('test');
  mimeType: 'text/plain';
  encoding: 'utf-8');
di.toString(); # data:text/plain;charset=utf-8;base64,dGVzdA==

Constructors

DataUri({String mimeType = 'application/octet-stream', String encoding = '', String data = '', bool isDataBase64Encoded = true})
Construct a new DataUri. Assume that data is base64 encoded unless isDataBase64Encoded is passed in as false

Properties

data String
The data as a String
getter/setter pair
encoding String
The content encoding of the data. If null or empty it will be omitted
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
isDataBase64Encoded bool
Whether or not the data is base64 encoded
getter/setter pair
mimeType String
The mimetype of the data. If null or empty it will be omitted
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

base64EncodeByteBuffer(ByteBuffer buf) String
Static method to encode a ByteBuffer (which you get back from an HttpRequest) to base64 String
base64EncodeString(String string) String
Static method to encode a string to base64