Skip to content

Commit cab6cd2

Browse files
authored
♻️ Break ForegroundBuilder (#100)
1 parent 20c866c commit cab6cd2

File tree

5 files changed

+13
-20
lines changed

5 files changed

+13
-20
lines changed

CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@ that can be found in the LICENSE file. -->
44

55
# Changelog
66

7-
## 3.2.1
7+
## 3.3.0
88

9-
### Improvements
9+
### Breaking Changes
1010

1111
- Allow the foreground builder to be used all the time (#97) .
1212
The signature of the `ForegroundBuilder` has changed
1313
but can be easily migrated.
14+
15+
### Improvements
16+
1417
- Allow text delegates to be obtained by `Locale`. (#99)
1518

1619
## 3.2.0+1

example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: wechat_camera_picker_demo
22
description: A new Flutter project.
3-
version: 3.2.1+11
3+
version: 3.3.0+11
44
publish_to: none
55

66
environment:

lib/src/constants/type_defs.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ typedef CameraErrorHandler = void Function(
4444
/// Build the foreground/overlay widget with the given [CameraValue].
4545
/// 根据给定的 [CameraValue] 构建自定义的前景 widget
4646
///
47-
/// The `cameraValue` will be null until the [CameraController] initialized.
48-
/// 在 [CameraController] 完成初始化前,`cameraValue` 将为空。
47+
/// The `controller` will be null until initialized.
48+
/// 在 [CameraController] 完成初始化前,`controller` 将为空。
4949
/// {@endtemplate}
5050
typedef ForegroundBuilder = Widget Function(
5151
BuildContext context,
52-
CameraValue? cameraValue,
52+
CameraController? controller,
5353
);
5454

5555
/// {@template wechat_camera_picker.PreviewTransformBuilder}

lib/src/widgets/camera_picker.dart

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import '../constants/config.dart';
1818
import '../constants/constants.dart';
1919
import '../constants/enums.dart';
2020
import '../constants/styles.dart';
21-
import '../constants/type_defs.dart';
2221
import '../delegates/camera_picker_text_delegate.dart';
2322
import '../internals/extensions.dart';
2423
import '../internals/methods.dart';
@@ -1388,17 +1387,6 @@ class CameraPickerState extends State<CameraPicker>
13881387
);
13891388
}
13901389

1391-
Widget _foregroundBuilder(BuildContext context) {
1392-
final ForegroundBuilder builder = config.foregroundBuilder!;
1393-
if (_controller == null) {
1394-
return builder(context, null);
1395-
}
1396-
return ValueListenableBuilder<CameraValue>(
1397-
valueListenable: _controller!,
1398-
builder: (BuildContext c, CameraValue v, __) => builder(c, v),
1399-
);
1400-
}
1401-
14021390
@override
14031391
Widget build(BuildContext context) {
14041392
return AnnotatedRegion<SystemUiOverlayStyle>(
@@ -1430,7 +1418,9 @@ class CameraPickerState extends State<CameraPicker>
14301418
),
14311419
_contentBuilder(constraints),
14321420
if (config.foregroundBuilder != null)
1433-
Positioned.fill(child: _foregroundBuilder(context)),
1421+
Positioned.fill(
1422+
child: config.foregroundBuilder!(context, _controller),
1423+
),
14341424
],
14351425
),
14361426
),

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: wechat_camera_picker
22
description: A camera picker which is an extension to wechat_assets_picker, but can be run separately.
3-
version: 3.2.1
3+
version: 3.3.0
44
homepage: https://github.com/fluttercandies/flutter_wechat_camera_picker
55

66
environment:

0 commit comments

Comments
 (0)