Skip to content
dart:convert superpowered by extensions.
Dart
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows
example
lib
test
.gitignore
CHANGELOG.md
LICENSE
README.md
analysis_options.yaml
pubspec.yaml

README.md

convertx

Dart CI codecov pub package dart>=2.6

Static extension methods for converting between different data representations.

Getting started

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

dependencies:
  convertx: ^0.1.4

Then import the following, so you can use the extensions:

import 'package:convertx/convertx.dart';

Overview

Convertx exposes the most common dart:convert functionalities.

base64:

final base64String = 'Hello World!'.toUtf8ByteList().toBase64String();
print(base64String); // SGVsbG8gV29ybGQh

final originalString = base64String.toBase64ByteList().toUtf8String();
print(originalString); // Hello World!

JSON:

final jsonString = {'answer': 42}.toJsonString();
print(jsonString); // {"answer":42}

final originalMap = jsonString.toDecodedJson() as Map;
print(originalMap); // {answer: 42}

Escape HTML:

final html = '<strong>Romeo & Juliet</strong>'.escapeHtml();
print(html); // &lt;strong&gt;Romeo &amp; Juliet&lt;&#47;strong&gt;

Common string codecs:

// ASCII
print('Hello World!'.toAsciiByteList().toAsciiString()); // Hello World!

// Latin1
print('¡Hola Mundo!'.toLatin1ByteList().toLatin1String()); // ¡Hola Mundo!

// UTF-8
print('你好,世界!'.toUtf8ByteList().toUtf8String()); // 你好,世界!

Contribute

To report a bug or request any feature, please create an issue.

You can’t perform that action at this time.