Skip to content

Commit d0ff89a

Browse files
committed
✨ Add foregroundBuilder .
1 parent 3a12f7c commit d0ff89a

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

README-ZH.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Flutter SDK:`>=1.20.0` 。
5656
| textDelegate | `CameraPickerTextDelegate` | 控制部件中的文字实现 | `DefaultCameraPickerTextDelegate` |
5757
| resolutionPreset | `ResolutionPreset` | 相机的分辨率预设 | `ResolutionPreset.max` |
5858
| cameraQuarterTurns | `int` | 摄像机视图顺时针旋转次数,每次90度 | `0` |
59+
| foregroundBuilder | `Widget Function(CameraValue)` | 覆盖在相机预览上方的前景构建 | null |
5960

6061
### 简单的使用方法
6162

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ Reference:
8282
| textDelegate | `CameraPickerTextDelegate` | Text delegate that controls text in widgets. | `DefaultCameraPickerTextDelegate` |
8383
| resolutionPreset | `ResolutionPreset` | Present resolution for the camera. | `ResolutionPreset.max` |
8484
| cameraQuarterTurns | `int` | The number of clockwise quarter turns the camera view should be rotated. | `0` |
85+
| foregroundBuilder | `Widget Function(CameraValue)` | The foreground widget builder which will cover the whole camera preview. | null |
8586

8687
### Simple usage
8788

lib/src/widget/camera_picker.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class CameraPicker extends StatefulWidget {
3636
this.theme,
3737
this.resolutionPreset = ResolutionPreset.max,
3838
this.cameraQuarterTurns = 0,
39+
this.foregroundBuilder,
3940
CameraPickerTextDelegate textDelegate,
4041
}) : assert(
4142
isAllowRecording == true || isOnlyAllowRecording != true,
@@ -87,6 +88,10 @@ class CameraPicker extends StatefulWidget {
8788
/// 相机的分辨率预设
8889
final ResolutionPreset resolutionPreset;
8990

91+
/// The foreground widget builder which will cover the whole camera preview.
92+
/// 覆盖在相机预览上方的前景构建
93+
final Widget Function(CameraValue) foregroundBuilder;
94+
9095
/// Static method to create [AssetEntity] through camera.
9196
/// 通过相机创建 [AssetEntity] 的静态方法
9297
static Future<AssetEntity> pickFromCamera(
@@ -100,6 +105,7 @@ class CameraPicker extends StatefulWidget {
100105
int cameraQuarterTurns = 0,
101106
CameraPickerTextDelegate textDelegate,
102107
ResolutionPreset resolutionPreset = ResolutionPreset.max,
108+
Widget Function(CameraValue) foregroundBuilder,
103109
}) async {
104110
if (isAllowRecording != true && isOnlyAllowRecording == true) {
105111
throw ArgumentError('Recording mode error.');
@@ -122,6 +128,7 @@ class CameraPicker extends StatefulWidget {
122128
cameraQuarterTurns: cameraQuarterTurns,
123129
textDelegate: textDelegate,
124130
resolutionPreset: resolutionPreset,
131+
foregroundBuilder: foregroundBuilder,
125132
),
126133
transitionCurve: Curves.easeIn,
127134
transitionDuration: _kRouteDuration,
@@ -949,6 +956,10 @@ class CameraPickerState extends State<CameraPicker>
949956
children: <Widget>[
950957
Positioned.fill(child: _cameraPreview(context)),
951958
_focusingAreaWidget,
959+
if (widget.foregroundBuilder != null)
960+
Positioned.fill(
961+
child: widget.foregroundBuilder(value),
962+
),
952963
],
953964
),
954965
),

0 commit comments

Comments
 (0)