@@ -5,11 +5,17 @@ import '../../translations/toolbar.i18n.dart';
55
66class ImageResizer extends StatefulWidget {
77 const ImageResizer (
8- {required this .imageWidth, required this .imageHeight, Key ? key})
8+ {required this .imageWidth,
9+ required this .imageHeight,
10+ required this .maxWidth,
11+ required this .maxHeight,
12+ Key ? key})
913 : super (key: key);
1014
1115 final double ? imageWidth;
1216 final double ? imageHeight;
17+ final double maxWidth;
18+ final double maxHeight;
1319
1420 @override
1521 _ImageResizerState createState () => _ImageResizerState ();
@@ -18,16 +24,16 @@ class ImageResizer extends StatefulWidget {
1824class _ImageResizerState extends State <ImageResizer > {
1925 late double _width;
2026 late double _height;
21- late double _maxWidth;
22- late double _maxHeight;
2327
2428 @override
25- Widget build ( BuildContext context ) {
26- _maxWidth = MediaQuery . of (context).size.width ;
27- _maxHeight = MediaQuery . of (context).size.height ;
28- _width = widget.imageWidth ?? _maxWidth ;
29- _height = widget.imageHeight ?? _maxHeight;
29+ void initState ( ) {
30+ super . initState () ;
31+ _width = widget.imageWidth ?? widget.maxWidth ;
32+ _height = widget.imageHeight ?? widget.maxHeight ;
33+ }
3034
35+ @override
36+ Widget build (BuildContext context) {
3137 return CupertinoActionSheet (actions: [
3238 CupertinoActionSheetAction (
3339 onPressed: () {},
@@ -36,7 +42,7 @@ class _ImageResizerState extends State<ImageResizer> {
3642 child: Card (
3743 child: Slider (
3844 value: _width,
39- max: _maxWidth ,
45+ max: widget.maxWidth ,
4046 divisions: 100 ,
4147 label: 'Width' .i18n,
4248 onChanged: (val) {
@@ -54,7 +60,7 @@ class _ImageResizerState extends State<ImageResizer> {
5460 child: Card (
5561 child: Slider (
5662 value: _height,
57- max: _maxHeight ,
63+ max: widget.maxHeight ,
5864 divisions: 100 ,
5965 label: 'Height' .i18n,
6066 onChanged: (val) {
0 commit comments