cure 0.1.0-nullsafety.0 cure: ^0.1.0-nullsafety.0 copied to clipboard
A library for Dart developers which contains some useful tools and extensions: Signalr, MessagePack, CRC, HTTP, EventSource, WebSocket, etc.
- convert
import 'package:cure/convert.dart';
import 'package:cure/core.dart';
void main() {
// MessagePack
var object = Timestamp.utc(1970);
final data = messagePack.encode(object);
print(data); // [214, 255, 0, 0, 0, 0]
object = messagePack.decode(data) as Timestamp;
print(object); // Timestamp(0, 0)
}
- crypto
import 'dart:convert';
import 'package:cure/crypto.dart';
void main() {
final crc = CRC.crc16MODBUS();
final data = utf8.encode('123456789');
final value = crc.calculate(data);
print(value);
final result = crc.verify(data, value);
print(result);
}
- http
import 'package:cure/http.dart';
void main() async {
var client = Client();
try {
final response = await client.getAsync('url');
print('${response.statusCode}: ${response.content}');
} catch (e) {
print(e);
} finally {
client.close();
}
}
- signalr
import 'package:cure/signalr.dart';
void main() async {
final builder = HubConnectionBuilder()
..url = 'url'
..logLevel = LogLevel.information
..reconnect = true;
final connection = builder.build();
connection.on('send', (args) => print(args));
await connection.startAsync();
await connection.sendAsync('send', ['Hello', 123]);
final obj = await connection.invokeAsync('send', ['Hello', 'World']);
print(obj);
}