resizable_draggable_widget 0.0.5 resizable_draggable_widget: ^0.0.5 copied to clipboard
一个可拖拽来操作大小和位置的控件.
import 'package:flutter/material.dart';
import 'package:resize_drag_widget/resizable_draggable_widget.dart';
import 'package:flutter/foundation.dart';
void main() async {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'resize_drag_widget Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'resize_drag_widget 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> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Container(
child: ResizableDraggableWidget(
initHeight: 300,
initWidth: 300,
showSquare: true,
draggable: true,
bgColor: Colors.blueAccent,
squareColor: Colors.white,
changed: (width, height, tranformOffset) {
print(
"width: $width, height: $height, tranformOffset: $tranformOffset");
},
child: Image.network(
"https://t7.baidu.com/it/u=4198287529,2774471735&fm=193&f=GIF"),
),
));
}
}