Skip to content

Instantly share code, notes, and snippets.

@haidar786
Created February 12, 2020 07:36
Show Gist options
  • Save haidar786/c40617e62ad081e7a215c9dbc2c349bf to your computer and use it in GitHub Desktop.
Save haidar786/c40617e62ad081e7a215c9dbc2c349bf to your computer and use it in GitHub Desktop.
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