video_storage_query 1.0.0 copy "video_storage_query: ^1.0.0" to clipboard
video_storage_query: ^1.0.0 copied to clipboard

PlatformAndroid

This package provides methods to query for video files on your storage. It is also is to generate thumbnails for videos

example/lib/main.dart

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

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

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

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

class _MyAppState extends State<MyApp> {
  final query = VideoStorageQuery();
  @override
  void initState() {
    super.initState();
    // asking user for storage for missing
    const MethodChannel("channel").invokeMethod("initialize_permissions");
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        backgroundColor: Colors.black,
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: StreamBuilder(
          stream: query.queryVideos().asStream(),
          builder: (context, snapshot) {
            if (snapshot.connectionState == ConnectionState.waiting) {
              return const Center(child: CircularProgressIndicator());
            }

            if (snapshot.data == null) {
              return const Center(
                child: Text(
                  "Error returning data",
                  style: TextStyle(color: Colors.white),
                ),
              );
            }
            final videos = snapshot.data!;
            return GridView.builder(
              gridDelegate:
                  const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3),
              itemCount: videos.length > 10 ? 10 : videos.length,
              itemBuilder: (context, index) {
                final item = videos[index];
                return Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      item.duration,
                      style: const TextStyle(color: Colors.white),
                    ),
                    FutureBuilder<Uint8List>(
                      future: query.getVideoThumbnail(item.path),
                      builder: (context, snap) {
                        if (snap.connectionState == ConnectionState.waiting) {
                          return const CircularProgressIndicator();
                        }
                        return Image.memory(
                          snap.data!,
                          width: 75,
                          height: 75,
                          fit: BoxFit.cover,
                        );
                      },
                    )
                  ],
                );
              },
            );
          },
        ),
      ),
    );
  }
}
5
likes
150
points
7
downloads

Publisher

unverified uploader

Weekly Downloads

This package provides methods to query for video files on your storage. It is also is to generate thumbnails for videos

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on video_storage_query

Packages that implement video_storage_query