gify 1.0.3 copy "gify: ^1.0.3" to clipboard
gify: ^1.0.3 copied to clipboard

outdated

Make GIF with video and images, control speed with fps, set size when create GIF

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'dart:async';

import 'package:gify/gify.dart';
import 'package:image_picker/image_picker.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

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

class _MyAppState extends State<MyApp> {
  final _gifyPlugin = Gify();
  Uint8List? bytes;

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

  Future<List<Uint8List>?> testFrames() async {
    final XFile? videoFile =
        await ImagePicker().pickVideo(source: ImageSource.gallery);
    if (videoFile != null) {
      final result = await _gifyPlugin.getFramesBytes(videoFile, fps: 1);
      // Uncomment below code to see result
      setState(() {
        if (result != null) {
          bytes = result[0];
        }
      });
      return result;
    }
    return null;
  }

  Future<Uint8List?> testVideoToGif() async {
    final XFile? videoFile =
        await ImagePicker().pickVideo(source: ImageSource.gallery);
    if (videoFile != null) {
      final result =
          await _gifyPlugin.createGifFromVideo(videoFile, fps: 1, height: 320);
      // Uncomment below code to see result
      setState(() {
        if (result != null) {
          bytes = result;
        }
      });
      return result;
    }
    return null;
  }

  Future<Uint8List?> testImagesToGif() async {
    final List<XFile> imageFiles = await ImagePicker().pickMultiImage();
    final result =
        await _gifyPlugin.createGifFromImages(imageFiles, fps: 1, height: 480);
    // Uncomment below code to see result
    setState(() {
      if (result != null) {
        bytes = result;
      }
    });
    return result;
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Column(
          children: [
            Center(
              child: InkWell(
                onTap: () => testFrames(),
                child: const Text('test getFramesBytes from video'),
              ),
            ),
            Center(
              child: InkWell(
                onTap: () => testVideoToGif(),
                child: const Text('test createGifFromVideo'),
              ),
            ),
            Center(
              child: InkWell(
                onTap: () => testImagesToGif(),
                child: const Text('test createGifFromImages'),
              ),
            ),
            if (bytes != null) Image.memory(bytes!)
          ],
        ),
      ),
    );
  }
}
9
likes
0
points
68
downloads

Publisher

unverified uploader

Weekly Downloads

Make GIF with video and images, control speed with fps, set size when create GIF

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

cross_file, ffmpeg_kit_flutter, flutter, flutter_web_plugins, js, path_provider, plugin_platform_interface, universal_html

More

Packages that depend on gify

Packages that implement gify