custom_image_cutter 1.0.1 custom_image_cutter: ^1.0.1 copied to clipboard
CustomImageCutter is a powerful and versatile package designed to simplify the process of customizing image crops in an intuitive way.
import 'package:custom_image_cutter/custom_image_cutter.dart';
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(primarySwatch: Colors.blue),
home: const MyHomePage(title: 'Flutter Demo Home Page'));
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final cropImage = GlobalKey();
final controller = CustomImageCutterController();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text(widget.title)),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Stack(
children: [
SizedBox(
width: 400,
height: 650,
child: CustomImageCutter(
controller: controller,
cropperKey: cropImage,
backgroundColor: Colors.transparent,
imagePath:
'https://nmwa.org/wp-content/uploads/2020/01/1993.76-GAP.jpg',
image: Image.network(
// 'https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fthumbs.dreamstime.com%2Fb%2Foutdoor-lifestyle-fashion-photo-young-natural-beautiful-lady-winter-landscape-woman-girl-snow-happy-people-female-cold-157057502.jpg&f=1&nofb=1&ipt=de41bf83d61bce8f4522f807371c03436e46e496dda8824cd77f9761cbe6d36b&ipo=images',
// 'https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fthumbs.dreamstime.com%2Fb%2Fwoman-selfie-happily-woman-selfie-happily-beautiful-landscape-shikisai-no-oka-112203662.jpg&f=1&nofb=1&ipt=2720d5e69bab3b6493335f9ba6f733302b384dd348fece18cc6adcdd26308457&ipo=images',
// 'https://play-lh.googleusercontent.com/IeNJWoKYx1waOhfWF6TiuSiWBLfqLb18lmZYXSgsH1fvb8v1IYiZr5aYWe0Gxu-pVZX3',
'https://nmwa.org/wp-content/uploads/2020/01/1993.76-GAP.jpg',
// 'https://st.depositphotos.com/1034986/4574/i/950/depositphotos_45747235-stock-photo-beautiful-woman-selfie.jpg',
// 'https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fmedia.istockphoto.com%2Fphotos%2Fyoung-woman-taking-selfie-with-mountain-camp-picture-id842187462&f=1&nofb=1&ipt=f2f219de1e2a3545975b944d21caad896deb0cf9d7794607db9284c9f525d50c&ipo=images',
),
),
),
],
),
SizedBox(
width: 380,
child: SliderTheme(
data: const SliderThemeData(
overlayColor: Colors.transparent,
activeTickMarkColor: Color.fromARGB(255, 187, 152, 152),
activeTrackColor: Color.fromARGB(255, 146, 3, 3),
inactiveTrackColor: Color.fromARGB(255, 52, 6, 6),
thumbColor: Color.fromARGB(255, 208, 143, 143),
trackHeight: 1.0),
child: Slider(
min: 1,
max: controller.maxScale,
value: controller.scale,
onChanged: (value) =>
setState(() => controller.updateScale(value)))),
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: () async {
final cropped = await controller.crop(cropperKey: cropImage);
Navigator.of(context).push<void>(
MaterialPageRoute(
builder: (context) => Scaffold(
appBar: AppBar(),
body: Center(child: Image.memory(cropped!)),
),
fullscreenDialog: true,
),
);
},
child: const Icon(Icons.add),
),
);
}
}