builk_image_draw 0.0.2 builk_image_draw: ^0.0.2 copied to clipboard
draw image
example/lib/main.dart
import 'dart:io';
import 'package:builk_image_draw/image_draw/builk_image_draw.dart';
import 'package:builk_image_draw/image_draw/builk_image_draw_controller.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: ImageDrawWidget(),
);
}
}
class ImageDrawWidget extends StatefulWidget {
ImageDrawWidget({Key? key}) : super(key: key);
@override
_ImageDrawWidgetState createState() {
return _ImageDrawWidgetState();
}
}
class _ImageDrawWidgetState extends State<ImageDrawWidget> {
File? imagefile;
var imageDrawControl = BuilkImageDrawController();
@override
void initState() {
super.initState();
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Container(
alignment: Alignment.center,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
(imagefile != null)
? Container(
alignment: Alignment.center,
width: 200,
child: Image.file(imagefile!),
)
: Container(
alignment: Alignment.center,
width: 200,
child: Icon(Icons.image, size: 200),
)
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: () async {
showDialog(
context: context,
builder: (context) {
return BuilkImageDraw(
deletePin: (value) {},
undoComplete: () {},
clearButton: () {},
drawListView: [],
drawStackBackList: [],
controller: imageDrawControl,
drawComplete: () { },
loadPlanComplete: () {
imageDrawControl.changeColor(Colors.red);
imageDrawControl.selectPen(true);
},
drawImageSuccess: (value) { },
imageUrl: 'https://wpmedia.roomsketcher.com/content/uploads/2022/01/06145940/What-is-a-floor-plan-with-dimensions.png',
);
},
);
},
child: Icon(Icons.edit),
),
);
}
}