image_editor_plus 1.0.5
image_editor_plus: ^1.0.5 copied to clipboard
Image Editor Plugin with filters, drawing, text and emoji like stories.
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:image_editor_plus/image_editor_plus.dart';
void main() {
runApp(
const MaterialApp(
home: ImageEditorExample(),
),
);
}
class ImageEditorExample extends StatefulWidget {
const ImageEditorExample({
super.key,
});
@override
createState() => _ImageEditorExampleState();
}
class _ImageEditorExampleState extends State<ImageEditorExample> {
Uint8List? imageData;
@override
void initState() {
super.initState();
loadAsset("image.jpg");
}
void loadAsset(String name) async {
var data = await rootBundle.load('assets/$name');
setState(() => imageData = data.buffer.asUint8List());
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("ImageEditor Example"),
centerTitle: true,
),
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (imageData != null) Image.memory(imageData!),
const SizedBox(height: 16),
ElevatedButton(
child: const Text("Single image editor"),
onPressed: () async {
var editedImage = await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ImageEditor(
image: imageData,
),
),
);
// replace with edited image
if (editedImage != null) {
imageData = editedImage;
setState(() {});
}
},
),
ElevatedButton(
child: const Text("Multiple image editor"),
onPressed: () async {
var editedImage = await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ImageEditor(
images: [
imageData,
imageData,
],
),
),
);
// replace with edited image
if (editedImage != null) {
imageData = editedImage;
setState(() {});
}
},
),
],
),
);
}
}