Sample code for 30+ languages & platforms
Dart

Get Contents of File as Base64

See more Encryption Examples

Demonstrates how to read the contents of a file and convert to a base64 string.

Chilkat Dart Downloads

Dart
import 'package:chilkat/chilkat.dart';

void main() {
  final bd = CkBinData();

  try {
    bd.loadFile('qa_data/jpg/starfish.jpg');
  } on ChilkatException {
    print('Failed to load file.');
    return;
  }

  print(bd.getEncoded('base64'));

  // If you want mult-line base64:
  print('--');
  print(bd.getEncoded('base64_mime'));

  // If you want hex..
  print('--');
  print(bd.getEncoded('hex'));

  // etc..
}