video_editor_free 0.0.1 copy "video_editor_free: ^0.0.1" to clipboard
video_editor_free: ^0.0.1 copied to clipboard

A comprehensive Flutter UI widget to trim, crop, rotate, filter, and add draggable overlay text to videos using FFmpeg Kit Full.

example/lib/main.dart

import 'dart:io';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'package:video_editor_free/video_trim_editor.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Video Trim Editor Example',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        useMaterial3: true,
        colorScheme: ColorScheme.fromSeed(
          seedColor: Colors.deepPurple,
          brightness: Brightness.dark,
        ),
      ),
      home: const HomeScreen(),
    );
  }
}

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

  @override
  State<HomeScreen> createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> {
  File? _originalVideo;
  File? _editedVideo;
  bool _isPicking = false;

  final ImagePicker _picker = ImagePicker();

  Future<void> _pickVideo() async {
    setState(() {
      _isPicking = true;
    });
    try {
      final XFile? file = await _picker.pickVideo(source: ImageSource.gallery);
      if (file != null) {
        setState(() {
          _originalVideo = File(file.path);
          _editedVideo = null;
        });
        if (mounted) {
          _openEditor(File(file.path));
        }
      }
    } catch (e) {
      debugPrint("Error picking video: $e");
    } finally {
      setState(() {
        _isPicking = false;
      });
    }
  }

  void _openEditor(File videoFile) async {
    final File? result = await Navigator.push<File>(
      context,
      MaterialPageRoute(
        builder: (context) => VideoTrimScreen(
          videoFile: videoFile,
          primaryColor: Colors.deepPurpleAccent,
          backgroundColor: const Color(0xFF121212),
          textColor: Colors.white,
        ),
      ),
    );

    if (result != null) {
      setState(() {
        _editedVideo = result;
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Video Trim Editor Demo'),
        centerTitle: true,
      ),
      body: Center(
        child: Padding(
          padding: const EdgeInsets.all(24.0),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              const Icon(
                Icons.video_library_rounded,
                size: 80,
                color: Colors.deepPurpleAccent,
              ),
              const SizedBox(height: 16),
              const Text(
                'Video Trim Editor',
                style: TextStyle(
                  fontSize: 24,
                  fontWeight: FontWeight.bold,
                ),
              ),
              const SizedBox(height: 8),
              Text(
                'Trim, crop, rotate, filter, and add overlays to your videos',
                textAlign: TextAlign.center,
                style: TextStyle(
                  fontSize: 14,
                  color: Colors.grey[400],
                ),
              ),
              const SizedBox(height: 40),
              if (_isPicking)
                const CircularProgressIndicator()
              else
                ElevatedButton.icon(
                  onPressed: _pickVideo,
                  icon: const Icon(Icons.movie_creation_outlined),
                  label: const Text('Select & Edit Video'),
                  style: ElevatedButton.styleFrom(
                    padding: const EdgeInsets.symmetric(
                      horizontal: 24,
                      vertical: 16,
                    ),
                    shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(12),
                    ),
                  ),
                ),
              const SizedBox(height: 40),
              if (_originalVideo != null) ...[
                Card(
                  margin: const EdgeInsets.only(top: 16),
                  shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.circular(12),
                  ),
                  child: Padding(
                    padding: const EdgeInsets.all(16.0),
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        const Text(
                          'Original Video:',
                          style: TextStyle(fontWeight: FontWeight.bold),
                        ),
                        const SizedBox(height: 4),
                        Text(
                          _originalVideo!.path,
                          style: const TextStyle(fontSize: 12, color: Colors.grey),
                          maxLines: 2,
                          overflow: TextOverflow.ellipsis,
                        ),
                      ],
                    ),
                  ),
                ),
              ],
              if (_editedVideo != null) ...[
                Card(
                  margin: const EdgeInsets.only(top: 16),
                  color: Colors.green.withValues(alpha: 0.1),
                  shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.circular(12),
                    side: const BorderSide(color: Colors.green, width: 1),
                  ),
                  child: Padding(
                    padding: const EdgeInsets.all(16.0),
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        const Row(
                          children: [
                            Icon(Icons.check_circle, color: Colors.green),
                            SizedBox(width: 8),
                            Text(
                              'Export Successful!',
                              style: TextStyle(
                                fontWeight: FontWeight.bold,
                                color: Colors.green,
                              ),
                            ),
                          ],
                        ),
                        const SizedBox(height: 8),
                        Text(
                          'Saved to: ${_editedVideo!.path}',
                          style: const TextStyle(fontSize: 12, color: Colors.grey),
                        ),
                        const SizedBox(height: 12),
                        ElevatedButton.icon(
                          onPressed: () => _openEditor(_editedVideo!),
                          icon: const Icon(Icons.edit),
                          label: const Text('Edit Again'),
                          style: ElevatedButton.styleFrom(
                            backgroundColor: Colors.transparent,
                            foregroundColor: Colors.white,
                            elevation: 0,
                            side: const BorderSide(color: Colors.grey),
                          ),
                        ),
                      ],
                    ),
                  ),
                ),
              ],
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
150
points
29
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A comprehensive Flutter UI widget to trim, crop, rotate, filter, and add draggable overlay text to videos using FFmpeg Kit Full.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

chewie, ffmpeg_kit_flutter_new_full, flutter, path_provider, provider, video_player

More

Packages that depend on video_editor_free