added save image and more feature
This commit is contained in:
@ -14,6 +14,7 @@ import 'dart:ui' as ui;
|
|||||||
|
|
||||||
import '../controller/myCustonPainter.dart';
|
import '../controller/myCustonPainter.dart';
|
||||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||||
|
import 'package:uuid/uuid.dart';
|
||||||
|
|
||||||
import 'package:intl/intl.dart' show toBeginningOfSentenceCase;
|
import 'package:intl/intl.dart' show toBeginningOfSentenceCase;
|
||||||
|
|
||||||
@ -33,6 +34,7 @@ class _Mewarna1PageState extends State<Mewarna1Page> {
|
|||||||
// ui.Image? image;
|
// ui.Image? image;
|
||||||
|
|
||||||
late Map args;
|
late Map args;
|
||||||
|
late String _uuid;
|
||||||
|
|
||||||
final GlobalKey _globalKey = GlobalKey();
|
final GlobalKey _globalKey = GlobalKey();
|
||||||
|
|
||||||
@ -50,7 +52,9 @@ class _Mewarna1PageState extends State<Mewarna1Page> {
|
|||||||
|
|
||||||
Future _saveImage(Uint8List bytes) async {
|
Future _saveImage(Uint8List bytes) async {
|
||||||
final appStorage = await getApplicationDocumentsDirectory();
|
final appStorage = await getApplicationDocumentsDirectory();
|
||||||
final file = File('${appStorage.path}/screenshot.png');
|
final file_name = args['nama']!.toString() + _uuid + '.png';
|
||||||
|
print(file_name);
|
||||||
|
final file = File('${appStorage.path}/${file_name}');
|
||||||
await file.writeAsBytes(bytes);
|
await file.writeAsBytes(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,6 +91,14 @@ class _Mewarna1PageState extends State<Mewarna1Page> {
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
// TODO: implement initState
|
||||||
|
super.initState();
|
||||||
|
_uuid = Uuid().v4();
|
||||||
|
print(_uuid);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void didChangeDependencies() {
|
void didChangeDependencies() {
|
||||||
// ignore: todo
|
// ignore: todo
|
||||||
|
|||||||
@ -1,9 +1,43 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
import 'dart:typed_data';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:mewarna/widgets/ourContainer.dart';
|
import 'package:mewarna/widgets/ourContainer.dart';
|
||||||
|
import 'package:path_provider/path_provider.dart';
|
||||||
|
|
||||||
class Tentang1 extends StatelessWidget {
|
class Tentang1 extends StatefulWidget {
|
||||||
const Tentang1({Key? key}) : super(key: key);
|
const Tentang1({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<Tentang1> createState() => _Tentang1State();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _Tentang1State extends State<Tentang1> {
|
||||||
|
Uint8List? _bytes;
|
||||||
|
|
||||||
|
Future cek_image() async {
|
||||||
|
final appStorage = await getApplicationDocumentsDirectory();
|
||||||
|
print(Directory(appStorage.path).listSync());
|
||||||
|
final file = File(
|
||||||
|
'${appStorage.path}/gajah51b2b453-5f5a-404f-89ab-2dcc46757319.png');
|
||||||
|
if (file.existsSync()) {
|
||||||
|
print("ada");
|
||||||
|
Uint8List bytes = await file.readAsBytes();
|
||||||
|
setState(() {
|
||||||
|
_bytes = bytes;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
print("tidak ada");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
// TODO: implement initState
|
||||||
|
super.initState();
|
||||||
|
cek_image();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
@ -23,8 +57,17 @@ class Tentang1 extends StatelessWidget {
|
|||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: MediaQuery.of(context).size.height * 0.5,
|
height: MediaQuery.of(context).size.height * 0.5,
|
||||||
child: OurContainer(
|
child: OurContainer(
|
||||||
|
child: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
|
_bytes != null
|
||||||
|
? Image.memory(
|
||||||
|
_bytes!,
|
||||||
|
fit: BoxFit.fill,
|
||||||
|
width: 100,
|
||||||
|
height: 100,
|
||||||
|
)
|
||||||
|
: Container(),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: MediaQuery.of(context).size.height * 0.02,
|
height: MediaQuery.of(context).size.height * 0.02,
|
||||||
),
|
),
|
||||||
@ -271,6 +314,7 @@ class Tentang1 extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -590,6 +590,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.0"
|
version: "1.3.0"
|
||||||
|
uuid:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: uuid
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "3.0.6"
|
||||||
vector_math:
|
vector_math:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
@ -46,6 +46,7 @@ dependencies:
|
|||||||
# loading_overlay: ^0.2.1
|
# loading_overlay: ^0.2.1
|
||||||
flutter_easyloading: ^3.0.3
|
flutter_easyloading: ^3.0.3
|
||||||
intl: ^0.17.0
|
intl: ^0.17.0
|
||||||
|
uuid: ^3.0.6
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|||||||
Reference in New Issue
Block a user