Skip to content

A flutter plugin to view and encode avif images.

License

Notifications You must be signed in to change notification settings

mykeskin/flutter_avif

 
 

Repository files navigation

flutter_avif

A flutter plugin to view and encode avif images.

Usage

AvifImage widget has a similar api as Flutter Image widget.

import 'package:flutter_avif/flutter_avif.dart';

AvifImage.file(
    file,
    height: 200,
    fit: BoxFit.contain,
),

AvifImage.asset(
    "test.avif",
    height: 200,
    fit: BoxFit.contain,
),

AvifImage.network(
    "https://test.com/test.avif",
    height: 200,
    fit: BoxFit.contain,
),

For documentation on widget properties, please refer to https://api.flutter.dev/flutter/widgets/Image-class.html.

Encoding

To convert an image to avif:

import 'package:flutter_avif/flutter_avif.dart';

final asset = await rootBundle.load("asset.gif");
final avifBytes = await encodeAvif(asset.buffer.asUint8List());
final outputFile = File('output.avif');
outputFile.writeAsBytes(avifBytes);
import 'package:flutter_avif/flutter_avif.dart';

final inputFile = File('input.png');
final inputBytes = await inputFile.readAsBytes();
final avifBytes = await encodeAvif(inputBytes);
final outputFile = File('output.avif');
outputFile.writeAsBytes(avifBytes);

About

A flutter plugin to view and encode avif images.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dart 51.0%
  • Rust 22.8%
  • C 6.6%
  • C++ 5.4%
  • CMake 3.7%
  • Ruby 2.4%
  • Other 8.1%