FiveDotTwelve / save_in_gallery

MIT License
6 stars 20 forks source link

Doesn't work on Android for me #21

Open chris-rutkowski opened 3 years ago

chris-rutkowski commented 3 years ago

Hello, are you sure your plugin works on Android? It works seamlessly on iOS but on Android it doesn't.

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: Home(),
    );
  }
}

class Home extends StatefulWidget {
  @override
  _HomeState createState() => _HomeState();
}

class _HomeState extends State<Home> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('test')),
      body: ListView(
        children: [
          RaisedButton(
            child: Text('asset'),
            onPressed: () async {
              final url = 'assets/images/img.png';
              final bytes = await rootBundle.load(url);
              final res = await ImageSaver().saveImage(imageBytes: bytes.buffer.asUint8List());
              print('success $res');
            },
          )
        ],
      ),
    );
  }
}

The permission popup is displayed, however the console says

Please advise

donkii commented 3 years ago

What Android version are you using?