Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Revert use of pointerCount property
  • Loading branch information
mvanbeusekom committed Feb 20, 2021
commit 3d1cc98815fc040b51f79e28e2a368a7d7f4c772
31 changes: 19 additions & 12 deletions packages/camera/camera/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
double _currentScale = 1.0;
double _baseScale = 1.0;

// Counting pointers (number of user fingers on screen)
int _pointers = 0;

@override
void initState() {
super.initState();
Expand Down Expand Up @@ -168,17 +171,21 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
),
);
} else {
return CameraPreview(
controller,
child: LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
return GestureDetector(
behavior: HitTestBehavior.opaque,
onScaleStart: _handleScaleStart,
onScaleUpdate: _handleScaleUpdate,
onTapDown: (details) => onViewFinderTap(details, constraints),
);
}),
return Listener(
onPointerDown: (_) => _pointers++,
onPointerUp: (_) => _pointers--,
child: CameraPreview(
controller,
child: LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
return GestureDetector(
behavior: HitTestBehavior.opaque,
onScaleStart: _handleScaleStart,
onScaleUpdate: _handleScaleUpdate,
onTapDown: (details) => onViewFinderTap(details, constraints),
);
}),
),
);
}
}
Expand All @@ -189,7 +196,7 @@ class _CameraExampleHomeState extends State<CameraExampleHome>

Future<void> _handleScaleUpdate(ScaleUpdateDetails details) async {
// When there are not exactly two fingers on screen don't scale
if (details.pointerCount != 2) {
if (_pointers != 2) {
return;
}

Expand Down