flutter_media_scanner 0.0.10 copy "flutter_media_scanner: ^0.0.10" to clipboard
flutter_media_scanner: ^0.0.10 copied to clipboard

Refresh the filesystem after writing a file to Android Gallery

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:flutter_media_scanner/flutter_media_scanner.dart';

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

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

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('FlutterMediaScanner example'),
        ),
        body: Center(
          child: OutlineButton(
            onPressed: () async {
              File originalFile = File("path/to/file");
              List<int> bytes = await originalFile.readAsBytes();
              //save your file to your desired path
              File file = File("desired/path");
              await file.writeAsBytes(bytes);
              //refresh the file system so the file can show in the gallery,
              await FlutterMediaScanner.scan(file.path);
            },
            child: const Text("Save & refresh!"),
          ),
        ),
      ),
    );
  }
}
1
likes
30
pub points
17%
popularity

Publisher

unverified uploader

Refresh the filesystem after writing a file to Android Gallery

Homepage

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_media_scanner