dhikshithrm / flutter_avif

A flutter plugin to view and encode avif images.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

flutter_avif

A flutter plugin to view and encode avif images.

Installation

To add the flutter_avif to your Flutter application follow the installation instructions on pub.dev.

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.

License:MIT License


Languages

Language:Dart 52.9%Language:Rust 22.3%Language:C 6.6%Language:C++ 5.0%Language:CMake 3.3%Language:Ruby 2.2%Language:Makefile 2.1%Language:Java 1.5%Language:Kotlin 1.4%Language:Objective-C 1.4%Language:Swift 1.3%