Skip to content
This repository has been archived by the owner on Sep 23, 2021. It is now read-only.

PR: 扩展能加入自定义前置元素,比如拍照按钮 #129

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

forever-z-133
Copy link

项目中有个需求,能像微信选图片一样,此界面也要有拍照按钮。

因此拓展 previousBuilder 属性来让开发者自定义列表之前的元素,
没想太多其他情况,比如该元素尺寸或多个元素等问题,仅算是个思路吧。

举个例子,利用该属性新加个元素,然后用 image_picker 实现拍照效果。

previousBuilder: (BuildContext context) {
  return new GestureDetector(
    onTap: () async {
      Navigator.of(context).pop();
      PickedFile image = await ImagePicker().getImage(source: ImageSource.camera, imageQuality: 30);
      if (image == null) return;
      print('${image.path}');
    },
    child: new Container(
      width: 64,
      height: 64,
      color: Colors.white,
      child: new Center(child: new Text('拍照')),
    ),
  );
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant