图片输入

pub package

一个用于在 Flutter 中进行图片输入的包。

image_input_example

入门

导入 image_input 包

import 'package:image_input/image_input.dart';

个人资料头像

    ProfileAvatar(
        radius: 100,
        allowEdit: true,
        backgroundColor: Colors.grey,
        addImageIcon: Container(
            decoration: BoxDecoration(
            color: Theme.of(context).colorScheme.primaryContainer,
            borderRadius: BorderRadius.circular(100),
            ),
            child: const Padding(
            padding: EdgeInsets.all(8.0),
            child: Icon(Icons.add_a_photo),
            ),
        ),
        removeImageIcon: Container(
            decoration: BoxDecoration(
            color: Theme.of(context).colorScheme.primaryContainer,
            borderRadius: BorderRadius.circular(100),
            ),
            child: const Padding(
            padding: EdgeInsets.all(8.0),
            child: Icon(Icons.close),
            ),
        ),
        onImageChanged: (XFile? image) {
            //save image to cloud and get the url
            //or
            //save image to local storage and get the path
            String? tempPath = image?.path;
            print(tempPath);
        },
    )

个人资料头像的使用

  • 在 ListView 中使用以显示个人资料图片。
  • 在创建新用户时使用,以从用户那里获取个人资料图片输入。

ImageInput

    ImageInput(
        allowEdit: true,
        allowMaxImage: 5,
        onImageSelected: (image, index) {
        //save image to cloud and get the url
        //or
        //save image to local storage and get the path
        String? tempPath = image?.path;
        print(tempPath);
        },
    ),

图片输入的使用

  • 用于显示/预览来自路径的多个图片
  • 用于从用户那里获取多个图片的输入

问题

请在 问题跟踪器 中提交问题、错误或功能请求。

GitHub

查看 Github