added saved to gallery
This commit is contained in:
BIN
assets/bg.png
Normal file
BIN
assets/bg.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 511 KiB |
@ -14,7 +14,7 @@ class HomePage extends HookWidget {
|
|||||||
fit: StackFit.expand,
|
fit: StackFit.expand,
|
||||||
children: [
|
children: [
|
||||||
Image.asset(
|
Image.asset(
|
||||||
"assets/bg.jpg",
|
"assets/bg.png",
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
color: Colors.black.withOpacity(0.2),
|
color: Colors.black.withOpacity(0.2),
|
||||||
colorBlendMode: BlendMode.darken,
|
colorBlendMode: BlendMode.darken,
|
||||||
|
|||||||
@ -96,7 +96,7 @@ class _KategoriPageState extends State<KategoriPage> {
|
|||||||
fit: StackFit.expand,
|
fit: StackFit.expand,
|
||||||
children: [
|
children: [
|
||||||
Image.asset(
|
Image.asset(
|
||||||
"assets/bg.jpg",
|
"assets/bg.png",
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
color: Colors.black.withOpacity(0.2),
|
color: Colors.black.withOpacity(0.2),
|
||||||
colorBlendMode: BlendMode.darken,
|
colorBlendMode: BlendMode.darken,
|
||||||
|
|||||||
@ -10,7 +10,8 @@ import 'package:audioplayers/audioplayers.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter_colorpicker/flutter_colorpicker.dart';
|
import 'package:flutter_colorpicker/flutter_colorpicker.dart';
|
||||||
import 'package:image_gallery_saver/image_gallery_saver.dart';
|
import 'package:gallery_saver/gallery_saver.dart';
|
||||||
|
// import 'package:image_gallery_saver/image_gallery_saver.dart';
|
||||||
// import 'package:image_gallery_saver/image_gallery_saver.dart';
|
// import 'package:image_gallery_saver/image_gallery_saver.dart';
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
import 'dart:ui' as ui;
|
import 'dart:ui' as ui;
|
||||||
@ -60,12 +61,39 @@ class _Mewarna1PageState extends State<Mewarna1Page> {
|
|||||||
// // GallerySaver.saveImage(path, albumName: "Download");
|
// // GallerySaver.saveImage(path, albumName: "Download");
|
||||||
// }
|
// }
|
||||||
|
|
||||||
Future _saveImage(Uint8List bytes) async {
|
Future _saveImage(Uint8List bytes, String stat) async {
|
||||||
|
log(stat);
|
||||||
final appStorage = await getApplicationDocumentsDirectory();
|
final appStorage = await getApplicationDocumentsDirectory();
|
||||||
final fileName = args['nama']!.toString() + _uuid + '.png';
|
final fileName = args['nama']!.toString() + _uuid + '.png';
|
||||||
log(fileName);
|
log(fileName);
|
||||||
final file = File('${appStorage.path}/$fileName');
|
final file = File('${appStorage.path}/$fileName');
|
||||||
|
log(file.toString());
|
||||||
await file.writeAsBytes(bytes);
|
await file.writeAsBytes(bytes);
|
||||||
|
|
||||||
|
if (stat == 'simpan') {
|
||||||
|
await EasyLoading.show(
|
||||||
|
status: 'Menyimpan...',
|
||||||
|
maskType: EasyLoadingMaskType.black,
|
||||||
|
);
|
||||||
|
await GallerySaver.saveImage(file.path, albumName: "Download");
|
||||||
|
await EasyLoading.dismiss();
|
||||||
|
// create dialog box message "Foto berhasil disimpan"
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => AlertDialog(
|
||||||
|
// title: Text('Foto berhasil disimpan di'),
|
||||||
|
content: const Text('Foto berhasil disimpan di galeri'),
|
||||||
|
actions: <Widget>[
|
||||||
|
ElevatedButton(
|
||||||
|
child: const Text('OK'),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Uint8List> _capturePng(String stat) async {
|
Future<Uint8List> _capturePng(String stat) async {
|
||||||
@ -86,39 +114,39 @@ class _Mewarna1PageState extends State<Mewarna1Page> {
|
|||||||
_ini = 'ada';
|
_ini = 'ada';
|
||||||
points.clear();
|
points.clear();
|
||||||
});
|
});
|
||||||
await _saveImage(base64Decode(bs64));
|
await _saveImage(base64Decode(bs64), stat);
|
||||||
// await _saveNetworkImage();
|
// await _saveNetworkImage();
|
||||||
|
|
||||||
await EasyLoading.dismiss();
|
await EasyLoading.dismiss();
|
||||||
|
|
||||||
if (stat == 'simpan') {
|
// if (stat == 'simpan') {
|
||||||
// log('simpan');
|
// // log('simpan');
|
||||||
await EasyLoading.show(
|
// await EasyLoading.show(
|
||||||
status: 'Menyimpan Ke Galeri',
|
// status: 'Menyimpan Ke Galeri',
|
||||||
maskType: EasyLoadingMaskType.black,
|
// maskType: EasyLoadingMaskType.black,
|
||||||
);
|
// );
|
||||||
await ImageGallerySaver.saveImage(Uint8List.fromList(pngBytes),
|
// await ImageGallerySaver.saveImage(Uint8List.fromList(pngBytes),
|
||||||
quality: 100, name: args['nama']!.toString() + _uuid);
|
// quality: 100, name: args['nama']!.toString() + _uuid);
|
||||||
await EasyLoading.dismiss();
|
// await EasyLoading.dismiss();
|
||||||
// create alert dialog
|
// // create alert dialog
|
||||||
showDialog(
|
// showDialog(
|
||||||
context: context,
|
// context: context,
|
||||||
builder: (BuildContext context) {
|
// builder: (BuildContext context) {
|
||||||
return AlertDialog(
|
// return AlertDialog(
|
||||||
title: const Text('Tersimpan'),
|
// title: const Text('Tersimpan'),
|
||||||
content: const Text('Gambar telah disimpan di galeri'),
|
// content: const Text('Gambar telah disimpan di galeri'),
|
||||||
actions: <Widget>[
|
// actions: <Widget>[
|
||||||
ElevatedButton(
|
// ElevatedButton(
|
||||||
child: const Text('OK'),
|
// child: const Text('OK'),
|
||||||
onPressed: () {
|
// onPressed: () {
|
||||||
Navigator.of(context).pop();
|
// Navigator.of(context).pop();
|
||||||
},
|
// },
|
||||||
),
|
// ),
|
||||||
],
|
// ],
|
||||||
);
|
// );
|
||||||
},
|
// },
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
|
|
||||||
return pngBytes;
|
return pngBytes;
|
||||||
// } catch (e) {
|
// } catch (e) {
|
||||||
@ -206,6 +234,7 @@ class _Mewarna1PageState extends State<Mewarna1Page> {
|
|||||||
// print(colorToHex(color));
|
// print(colorToHex(color));
|
||||||
setState(() {
|
setState(() {
|
||||||
selectedColor = color.withOpacity(0.01);
|
selectedColor = color.withOpacity(0.01);
|
||||||
|
// selectedColor = color.withOpacity(0.5);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@ -16,7 +16,7 @@ class PilihKategori extends HookWidget {
|
|||||||
fit: StackFit.expand,
|
fit: StackFit.expand,
|
||||||
children: [
|
children: [
|
||||||
Image.asset(
|
Image.asset(
|
||||||
"assets/bg.jpg",
|
"assets/bg.png",
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
color: Colors.black.withOpacity(0.2),
|
color: Colors.black.withOpacity(0.2),
|
||||||
colorBlendMode: BlendMode.darken,
|
colorBlendMode: BlendMode.darken,
|
||||||
@ -30,7 +30,7 @@ class PilihKategori extends HookWidget {
|
|||||||
//make the button same width
|
//make the button same width
|
||||||
SizedBox(
|
SizedBox(
|
||||||
// width is half of the screen width
|
// width is half of the screen width
|
||||||
width: MediaQuery.of(context).size.width / 3,
|
width: MediaQuery.of(context).size.width / 2.7,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
child: const Text('Binatang'),
|
child: const Text('Binatang'),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
@ -46,7 +46,7 @@ class PilihKategori extends HookWidget {
|
|||||||
height: 15,
|
height: 15,
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: MediaQuery.of(context).size.width / 3,
|
width: MediaQuery.of(context).size.width / 2.7,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
child: const Text('Kenderaan'),
|
child: const Text('Kenderaan'),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
@ -62,9 +62,12 @@ class PilihKategori extends HookWidget {
|
|||||||
height: 15,
|
height: 15,
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: MediaQuery.of(context).size.width / 3,
|
width: MediaQuery.of(context).size.width / 2.7,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
child: const Text('Sayur-Sayuran'),
|
child: const Text(
|
||||||
|
'Sayur-Sayuran',
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pushNamed(
|
Navigator.pushNamed(
|
||||||
context,
|
context,
|
||||||
@ -78,7 +81,7 @@ class PilihKategori extends HookWidget {
|
|||||||
height: 15,
|
height: 15,
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: MediaQuery.of(context).size.width / 3,
|
width: MediaQuery.of(context).size.width / 2.7,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
child: const Text('Buah-Buahan'),
|
child: const Text('Buah-Buahan'),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
|||||||
@ -49,7 +49,7 @@ class _Tentang1State extends State<Tentang1> {
|
|||||||
fit: StackFit.expand,
|
fit: StackFit.expand,
|
||||||
children: [
|
children: [
|
||||||
Image.asset(
|
Image.asset(
|
||||||
"assets/bg.jpg",
|
"assets/bg.png",
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
color: Colors.black.withOpacity(0.2),
|
color: Colors.black.withOpacity(0.2),
|
||||||
colorBlendMode: BlendMode.darken,
|
colorBlendMode: BlendMode.darken,
|
||||||
|
|||||||
Reference in New Issue
Block a user