md5_file_checksum 1.0.3 icon indicating copy to clipboard operation
md5_file_checksum: ^1.0.3 copied to clipboard

Flutter plugin to calculate a file checksum as MD5 hash, using a platform native implementation.

example/lib/main.dart

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:md5_file_checksum/md5_file_checksum.dart';
import 'package:md5_file_checksum_example/gen/assets.gen.dart';
import 'package:md5_file_checksum_example/utils/file.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _fileChecksum = "---";

  @override
  void initState() {
    super.initState();
    _init();
  }

  Future<void> _init() async {
    try {
      final tempFilePath =
          await copyAssetFileToTempDirectory(Assets.file1) ?? "";
      final fileChecksum =
          await Md5FileChecksum.getFileChecksum(filePath: tempFilePath) ??
              "---";

      if (!mounted) return;
      setState(() {
        _fileChecksum = fileChecksum;
      });
    } catch (_) {}
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Text('File checksum: $_fileChecksum'),
        ),
      ),
    );
  }
}
2
likes
130
pub points
81%
popularity

Publisher

verified publisher iconalbemala.me

Flutter plugin to calculate a file checksum as MD5 hash, using a platform native implementation.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on md5_file_checksum