[英]I want to click a picture of document and crop it (like cam scanner), this to be done when user clicks on my sliverList. I am new to flutter
Remember it is 3rd page where i want my onPressed to open camera and crop image.请记住,这是我希望 onPressed 打开相机和裁剪图像的第 3 页。
Tell me code for both android and Ios.告诉我 android 和 Ios 的代码。
import 'package:flutter/material.dart';
import 'package:telemed/pages/size_config.dart';
import 'strings.dart';
import 'package:camera/camera.dart';
class User extends StatefulWidget {
List<CameraDescription> cameras;
Future<void> main() async {
runApp(); // what to write here instead of all this code.it is my 3rd page of flutter
WidgetsFlutterBinding.ensureInitialized();
final cameras = await availableCameras();
@override
_PatientState createState() => _UserState();
}
class _UserState extends State<User> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: CustomScrollView(
slivers: <Widget>[
Container(
child: SliverList(
delegate: SliverChildBuilderDelegate((context, index) {
return Container(
alignment: Alignment.center,
color: Colors.white,
child: Text('Patient ${index}'),
height: 120,
margin: EdgeInsets.all(1),
);
}, childCount: 20),
),
)
],
));
} // please ignore any extra curly braces...
}
my main aim is that user touches my sliverListview (like whatsapp but opens camera to crop a document clicked via camera instead of chat).我的主要目标是用户触摸我的 sliverListview(如 whatsapp,但打开相机以裁剪通过相机而不是聊天点击的文档)。
Please, read the relevant Flutter documentation about Widgets, then read the camera
package documentation.请阅读有关 Widgets 的相关 Flutter 文档,然后阅读
camera
包文档。
Configure your project to support camera and photo library access as per the documentation.根据文档配置您的项目以支持相机和照片库访问。
Then you can wrap your Container
in an InkWell
widget and use its onTap
callback to then invoke the initialize
method on your CameraController
.然后,您可以将
Container
在InkWell
小部件中,并使用其onTap
回调调用CameraController
上的initialize
方法。
The camera
package is built with support for both Android and iOS, so the Flutter code you write will work on both platforms. camera
包支持 Android 和 iOS,因此您编写的 Flutter 代码可以在两个平台上运行。
You can use either image_crop
or flutter_native_image
packages to crop resulting image.您可以使用
image_crop
或flutter_native_image
包来裁剪结果图像。
I hope you don't expect me (or anyone else) to write the whole app for you.我希望您不要指望我(或其他任何人)为您编写整个应用程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.