media_scanner_scan_file 0.0.4 copy "media_scanner_scan_file: ^0.0.4" to clipboard
media_scanner_scan_file: ^0.0.4 copied to clipboard

A new flutter plugin for Android MediaScanner.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:io';

import 'package:media_scanner_scan_file/media_scanner_scan_file.dart';

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final File f = File('/storage/emulated/0/Pictures/example.png');
  String path = '';

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Text('File path: $path'),
        ),
      ),
    );
  }

  Future<String?> _scanFile(File f) async{
    final result = await MediaScannerScanFile.scanFile(f.path);
    setState(() {
      path = result['filePath'];
    });
    return result['filePath'];
  }

}
4
likes
100
pub points
45%
popularity

Publisher

unverified uploader

A new flutter plugin for Android MediaScanner.

Repository (GitHub)
View/report issues

Documentation

API reference

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on media_scanner_scan_file