简体   繁体   English

我想单击文档图片并对其进行裁剪(如凸轮扫描仪),这要在用户单击我的 sliverList 时完成。 我是颤振的新手

[英]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 .然后,您可以将ContainerInkWell小部件中,并使用其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_cropflutter_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.

相关问题 我正在使用 BottomNavigationBar 导航到 diff SliverList。 我观察到它没有保留到我滚动的最后一行。 我怎样才能解决这个问题? - I am using BottomNavigationBar to navigate to diff SliverList. I observe that It does not retain to the last row that I scrolled. How can I fix this? 我可以将我的动态 JSON 派生 Listview 与 Flutter 中的 SliverList 集成吗? - Can I integrate my dynamic JSON derived Listview with a SliverList in Flutter? 我是Flutter的新手,我尝试在Android Studio上运行我的项目,但在控制台中出现错误,例如: - I am new to Flutter, I try to run my project on Android Studio but I get an error in the console like: 我是颤振火力基地的新手。 我想打印每个 firebase 文档的名为 amount 的字段的总值 - I am new in flutter firebase. I want to print total value of the field named amount of each firebase document 我想在 flutter 中创建一个带有 firebase 的列表视图,它将显示标题副标题和图像,并且当用户单击将打开 web 视图的列表视图时 - i want to create a listview with firebase in flutter that will show title subtitle and image and when user click on listview that will open a webview 当我使用 Flutter 在 cloud firestore 中检索我的文档数组时,我收到错误,例如 list is not a subtype of string - While I am retrieving my array of document in cloud firestore using Flutter I got error like list is not a sub type of string 当用户单击选项卡时,我想要一个 flutter 选项卡栏使屏幕滚动到特定位置 - I want a flutter tab bar to make screen scroll to a specific location when a user click on the tab 我想将 firebase 添加到我的 flutter 应用程序中,但是当我设置它时,VS Code 中有很多错误 - I want to add firebase into my flutter app but when i set it up, am having a lot of errors in VS Code 我在使用颤振平台方法频道的 kotlin 画中画问题上遇到了问题 - I am facing issue on kotlin picture in picture with flutter platform methodchannel 当我想在 Flutter 中调试我的应用程序时遇到问题 - I have problem when I want debug my app in Flutter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM