media_cache_manager 0.2.0 copy "media_cache_manager: ^0.2.0" to clipboard
media_cache_manager: ^0.2.0 copied to clipboard

This package helps you to cache media (Audio, Video, Image, etc...).

example/lib/main.dart

import 'package:better_player/better_player.dart';
import 'package:flutter/material.dart';
import 'package:media_cache_manager/media_cache_manager.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await MediaCacheManager.instance.init(
    encryptionPassword: 'i love flutter'
  );
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

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

class _MyAppState extends State<MyApp> {
  late DownloadMediaBuilderController controller;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Column(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            DownloadMediaBuilder(
              url: 'https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_5mb.mp4',
              onInit: (controller) => this.controller = controller,
              encryptionPassword: "this is another password",
              onSuccess: (snapshot) {
                return BetterPlayer.file(snapshot.filePath!);
              },
              onLoading: (snapshot) {
                return Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.stretch,
                  children: [
                    LinearProgressIndicator(
                      value: snapshot.progress,
                    ),
                    const SizedBox(height: 20),
                    ElevatedButton(
                      onPressed: controller.cancelDownload,
                      child: const Text('Cancel Download'),
                    ),
                  ],
                );
              },
              onCancel: (snapshot) {
                return ElevatedButton(
                  onPressed: controller.retry,
                  child: const Text('Retry'),
                );
              },
              onDecrypting: (snapshot) {
                return const Center(
                  child: Text('File is under decryption...'),
                );
              },
              onEncrypting: (snapshot) {
                return const Center(
                  child: Text('File is under encryption...'),
                );
              },
              onError: (snapshot) {
                return Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.stretch,
                  children: [
                    const Center(child: Text('Error Occurred!')),
                    const SizedBox(height: 10),
                    ElevatedButton(
                      onPressed: controller.retry,
                      child: const Text('Retry'),
                    ),
                  ],
                );
              },
            ),
          ],
        ),
      ),
    );
  }
}
71
likes
0
pub points
82%
popularity

Publisher

unverified uploader

This package helps you to cache media (Audio, Video, Image, etc...).

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

aes_crypt_null_safe, dio, flutter, get_storage, path_provider

More

Packages that depend on media_cache_manager