Created
February 12, 2020 07:36
-
-
Save haidar786/c40617e62ad081e7a215c9dbc2c349bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:io'; | |
import 'dart:ui' as ui; | |
import 'package:flutter/material.dart'; | |
import 'package:image_crop_widget/image_crop_widget.dart'; | |
class FinalImagePage extends StatefulWidget { | |
final File image; | |
FinalImagePage(this.image); | |
@override | |
State<StatefulWidget> createState() { | |
return _FinalImageState(); | |
} | |
} | |
class _FinalImageState extends State<FinalImagePage> { | |
final key = GlobalKey<ImageCropState>(); | |
void _onCropPress() async { | |
final croppedImage = await key.currentState.cropImage(); | |
showModalBottomSheet( | |
context: context, | |
builder: (context) => RawImage( | |
image: croppedImage, | |
fit: BoxFit.contain, | |
height: croppedImage.height.toDouble(), | |
), | |
); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Stack( | |
children: <Widget>[ | |
ImageCrop(key: key,image: here wants ui.Image,), | |
AppBar( | |
backgroundColor: Colors.transparent, | |
actions: <Widget>[ | |
FlatButton( | |
child: Text("Crop"), | |
onPressed: _onCropPress, | |
), | |
], | |
), | |
], | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment