Last updated:
0 purchases
convertx
convertx #
Static extension methods for converting between different data representations.
Getting started #
Add this to your package's pubspec.yaml file:
dependencies:
convertx: ^0.2.2
copied to clipboard
Then import the following, so you can use the extensions:
import 'package:convertx/convertx.dart';
copied to clipboard
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!
copied to clipboard
JSON: #
final jsonString = {'answer': 42}.toJsonString();
print(jsonString); // {"answer":42}
final originalMap = jsonString.toDecodedJson() as Map;
print(originalMap); // {answer: 42}
copied to clipboard
Escape HTML: #
final html = '<strong>Romeo & Juliet</strong>'.escapeHtml();
print(html); // <strong>Romeo & Juliet</strong>
copied to clipboard
Common string codecs: #
// ASCII
print('Hello World!'.toAsciiByteList().toAsciiString()); // Hello World!
// Latin1
print('¡Hola Mundo!'.toLatin1ByteList().toLatin1String()); // ¡Hola Mundo!
// UTF-8
print('你好,世界!'.toUtf8ByteList().toUtf8String()); // 你好,世界!
copied to clipboard
Contribute #
To report a bug or request any feature, please create an issue.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.