chilkat 11.6.1 copy "chilkat: ^11.6.1" to clipboard
chilkat: ^11.6.1 copied to clipboard

The Chilkat class library for Dart and Flutter: HTTP, REST, email (SMTP/POP3/IMAP), FTP, SFTP, SSH, zip, encryption, digital signatures, certificates, XML, JSON and more.

Chilkat for Dart and Flutter #

The Chilkat class library for Dart: HTTP, REST, email (SMTP/POP3/IMAP), FTP, SFTP, SSH, zip, encryption, digital signatures, certificates, XML, JSON and more — the same classes and methods Chilkat offers in 30+ other languages, with a Dart-native surface.

import 'package:chilkat/chilkat.dart';

void main() {
  Chilkat.unlockBundle('Anything for 30-day trial');

  final http = CkHttp();
  http.connectTimeout = 30;
  http.setRequestHeader('Accept', 'application/json');

  final body = http.quickGetStr('https://api.example.com/items');
  print('status ${http.lastStatus}');

  final json = CkJsonObject();
  json.load(body);
  for (var i = 0; i < json.size; i++) {
    final name = json.nameAt(i);
    print('$name = ${json.stringOf(name)}');
  }
}

Install #

dart pub add chilkat      # or: flutter pub add chilkat

The native Chilkat library is a prebuilt shared library that the package's build hook downloads for your target the first time you build, verifies (SHA-256) and caches. Requires Dart 3.10 / Flutter 3.38 or later (build hooks). Supported targets: Android (arm64-v8a, armeabi-v7a, x86_64), iOS (device and simulator), macOS, Windows (x64, arm64), Linux (x64, arm64). Web is not supported.

Offline or air-gapped builds: point the build hook at a directory containing the library for your target (libchilkat_c_bridge.so, libchilkat_c_bridge.dylib or chilkat_c_bridge.dll) with a user-define in your application's pubspec.yaml, and nothing is downloaded:

hooks:
  user_defines:
    chilkat:
      lib_dir: /path/to/chilkat/lib    # relative paths resolve against this pubspec

How the API maps to Dart #

Chilkat Dart
class Http, JsonObject, CkDateTime CkHttp, CkJsonObject, CkDateTime — every class has a Ck prefix
property ConnectTimeout http.connectTimeout getter/setter
method QuickGetStr http.quickGetStr(url) — lowerCamelCase, same arguments
a method returning a success bool returns void; throws [ChilkatException] on failure
a method returning a String or object returns it; throws [ChilkatException] when Chilkat returns null
a method returning a bool that is the answer (HasMember, IsUnlocked, ...) returns bool
byte data Uint8List
LastErrorText obj.lastErrorText, and e.lastErrorText on the exception
try {
  final html = http.quickGetStr(url);
} on ChilkatException catch (e) {
  print(e);                // CkHttp.quickGetStr failed: <reason>
  print(e.lastErrorText);  // the full Chilkat log of the failed call
}

Objects release their native resources when garbage collected; call dispose() to release them immediately (large CkBinData, open sockets).

Flutter: long-running calls #

Every call is synchronous and blocks the calling isolate. Quick operations (JSON, XML, hashing, encoding) are fine on the UI isolate; network and large file operations belong in a worker isolate. Chilkat objects cannot be sent between isolates, so the worker creates its own:

final body = await Isolate.run(() {
  final http = CkHttp()..connectTimeout = 30;
  return http.quickGetStr(url);
});

Progress and cancellation: the 40 event-capable classes (CkHttp, CkFtp2, CkSFtp, CkZip, CkBz2, ...) have onPercentDone, onProgressInfo and onAbortCheck callback properties. They fire on the calling thread, inside the method call; return true from onPercentDone or onAbortCheck to abort. From a worker isolate, forward progress through a SendPort:

final progress = ReceivePort();
progress.listen((pct) => setState(() => _pct = pct as int));
await Isolate.run(() {
  final ftp = CkFtp2()..hostname = host ..username = user ..password = pw;
  ftp.onPercentDone = (pct) { progress.sendPort.send(pct); return _cancelRequested; };
  ftp.connect();
  ftp.getFile('remote.dat', localPath);
});

Reference #

Every class and member carries the Chilkat reference documentation as dartdoc. Online reference: https://www.chilkatsoft.com/refdoc/dart.asp. Examples for every class: https://www.example-code.com/dart/.

License #

Chilkat is commercial software. The 30-day trial is fully functional; see LICENSE and https://www.chilkatsoft.com/purchase2.asp.

0
likes
150
points
0
downloads

Documentation

Documentation
API reference

Publisher

unverified uploader

Weekly Downloads

The Chilkat class library for Dart and Flutter: HTTP, REST, email (SMTP/POP3/IMAP), FTP, SFTP, SSH, zip, encryption, digital signatures, certificates, XML, JSON and more.

Homepage
View/report issues

Topics

#http #email #sftp #crypto #ffi

License

unknown (license)

Dependencies

code_assets, crypto, ffi, hooks

More

Packages that depend on chilkat