Skip to content

Commit a623687

Browse files
authored
Merge branch 'main' into fix-hangs
2 parents b6ed95b + ca07b70 commit a623687

File tree

24 files changed

+510
-52
lines changed

24 files changed

+510
-52
lines changed

packages/camera/camera_avfoundation/CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
## 0.9.20
2+
3+
* Fixes incorrect types in image stream events.
4+
15
## 0.9.19+3
26

37
* Fixes race condition when starting image stream.
48

5-
69
## 0.9.19+2
710

811
* Adds the `Camera` Swift protocol.

packages/camera/camera_avfoundation/example/ios/RunnerTests/StreamingTests.swift

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,41 @@ final class StreamingTests: XCTestCase {
123123

124124
waitForExpectations(timeout: 30, handler: nil)
125125
}
126+
127+
func testImageStreamEventFormat() {
128+
let (camera, testAudioOutput, sampleBuffer, testAudioConnection) = createCamera()
129+
130+
let expectation = expectation(description: "Received a valid event")
131+
132+
let handlerMock = MockImageStreamHandler()
133+
handlerMock.eventSinkStub = { event in
134+
let imageBuffer = event as! [String: Any]
135+
136+
XCTAssertTrue(imageBuffer["width"] is NSNumber)
137+
XCTAssertTrue(imageBuffer["height"] is NSNumber)
138+
XCTAssertTrue(imageBuffer["format"] is NSNumber)
139+
XCTAssertTrue(imageBuffer["lensAperture"] is NSNumber)
140+
XCTAssertTrue(imageBuffer["sensorExposureTime"] is NSNumber)
141+
XCTAssertTrue(imageBuffer["sensorSensitivity"] is NSNumber)
142+
143+
let planes = imageBuffer["planes"] as! [[String: Any]]
144+
let planeBuffer = planes[0]
145+
146+
XCTAssertTrue(planeBuffer["bytesPerRow"] is NSNumber)
147+
XCTAssertTrue(planeBuffer["width"] is NSNumber)
148+
XCTAssertTrue(planeBuffer["height"] is NSNumber)
149+
XCTAssertTrue(planeBuffer["bytes"] is FlutterStandardTypedData)
150+
151+
expectation.fulfill()
152+
}
153+
let messenger = MockFlutterBinaryMessenger()
154+
camera.startImageStream(with: messenger, imageStreamHandler: handlerMock) { _ in }
155+
156+
waitForQueueRoundTrip(with: DispatchQueue.main)
157+
XCTAssertEqual(camera.isStreamingImages, true)
158+
159+
camera.captureOutput(testAudioOutput, didOutput: sampleBuffer, from: testAudioConnection)
160+
161+
waitForExpectations(timeout: 30, handler: nil)
162+
}
126163
}

packages/camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/DefaultCamera.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,9 @@ final class DefaultCamera: FLTCam, Camera {
105105
"height": imageHeight,
106106
"format": videoFormat,
107107
"planes": planes,
108-
"lensAperture": captureDevice.lensAperture,
109-
"sensorExposureTime": NSNumber(
110-
value: captureDevice.exposureDuration().seconds * 1_000_000_000),
111-
"sensorSensitivity": NSNumber(value: captureDevice.iso()),
108+
"lensAperture": Double(captureDevice.lensAperture()),
109+
"sensorExposureTime": Int(captureDevice.exposureDuration().seconds * 1_000_000_000),
110+
"sensorSensitivity": Double(captureDevice.iso()),
112111
]
113112

114113
DispatchQueue.main.async {

packages/camera/camera_avfoundation/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: camera_avfoundation
22
description: iOS implementation of the camera plugin.
33
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_avfoundation
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
5-
version: 0.9.19+3
5+
version: 0.9.20
66

77
environment:
88
sdk: ^3.6.0

packages/go_router/CHANGELOG.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,26 @@
55
`RouteInformationState` and `ImperativeRouteMatch`.
66
[flutter#141251](https://github.com/flutter/flutter/issues/141251)
77

8+
## 15.2.3
9+
10+
- Updates Type-safe routes topic documentation to use the mixin from `go_router_builder` 3.0.0.
11+
12+
## 15.2.2
13+
14+
- Fixes calling `PopScope.onPopInvokedWithResult` in branch routes.
15+
16+
## 15.2.1
17+
18+
* Fixes Popping state and re-rendering scaffold at the same time doesn't update the URL on web.
19+
820
## 15.2.0
921

10-
- `GoRouteData` now defines `.location`, `.go(context)`, `.push(context)`, `.pushReplacement(context)`, and `replace(context)` to be used for [Type-safe routing](https://pub.dev/documentation/go_router/latest/topics/Type-safe%20routes-topic.html). **Requires go_router_builder >= 3.0.0**.
22+
* `GoRouteData` now defines `.location`, `.go(context)`, `.push(context)`, `.pushReplacement(context)`, and `replace(context)` to be used for [Type-safe routing](https://pub.dev/documentation/go_router/latest/topics/Type-safe%20routes-topic.html). **Requires go_router_builder >= 3.0.0**.
1123

1224
## 15.1.3
1325

14-
- Updates minimum supported SDK version to Flutter 3.27/Dart 3.6.
15-
- Fixes typo in API docs.
26+
* Updates minimum supported SDK version to Flutter 3.27/Dart 3.6.
27+
* Fixes typo in API docs.
1628

1729
## 15.1.2
1830

packages/go_router/doc/type-safe-routes.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Instead of using URL strings to navigate, go_router supports
2-
type-safe routes using the go_router_builder package.
2+
type-safe routes using the go_router_builder package.
33

44
To get started, add [go_router_builder][], [build_runner][], and
55
[build_verify][] to the dev_dependencies section of your pubspec.yaml:
@@ -28,15 +28,15 @@ part 'go_router_builder.g.dart';
2828
]
2929
)
3030
@immutable
31-
class HomeScreenRoute extends GoRouteData {
31+
class HomeScreenRoute extends GoRouteData with _$HomeScreenRoute {
3232
@override
3333
Widget build(BuildContext context, GoRouterState state) {
3434
return const HomeScreen();
3535
}
3636
}
3737

3838
@immutable
39-
class SongRoute extends GoRouteData {
39+
class SongRoute extends GoRouteData with _$SongRoute {
4040
final int id;
4141

4242
const SongRoute({
@@ -74,4 +74,4 @@ package documentation](https://pub.dev/documentation/go_router_builder/latest/).
7474

7575
[go_router_builder]: https://pub.dev/packages/go_router_builder
7676
[build_runner]: https://pub.dev/packages/build_runner
77-
[build_verify]: https://pub.dev/packages/build_verify
77+
[build_verify]: https://pub.dev/packages/build_verify

packages/go_router/lib/src/delegate.dart

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ class GoRouterDelegate extends RouterDelegate<RouteMatchList>
5555

5656
@override
5757
Future<bool> popRoute() async {
58-
final NavigatorState? state = _findCurrentNavigator();
59-
if (state != null) {
58+
final Iterable<NavigatorState> states = _findCurrentNavigators();
59+
for (final NavigatorState state in states) {
6060
final bool didPop = await state.maybePop(); // Call maybePop() directly
6161
if (didPop) {
6262
return true; // Return true if maybePop handled the pop
@@ -96,17 +96,27 @@ class GoRouterDelegate extends RouterDelegate<RouteMatchList>
9696

9797
/// Pops the top-most route.
9898
void pop<T extends Object?>([T? result]) {
99-
final NavigatorState? state = _findCurrentNavigator();
100-
if (state == null || !state.canPop()) {
99+
final Iterable<NavigatorState> states = _findCurrentNavigators().where(
100+
(NavigatorState element) => element.canPop(),
101+
);
102+
if (states.isEmpty) {
101103
throw GoError('There is nothing to pop');
102104
}
103-
state.pop(result);
105+
states.first.pop(result);
104106
}
105107

106-
NavigatorState? _findCurrentNavigator() {
107-
NavigatorState? state;
108-
state =
109-
navigatorKey.currentState; // Set state directly without canPop check
108+
/// Get a prioritized list of NavigatorStates,
109+
/// which either can pop or are exit routes.
110+
///
111+
/// 1. Sub route within branches of shell navigation
112+
/// 2. Branch route
113+
/// 3. Parent route
114+
Iterable<NavigatorState> _findCurrentNavigators() {
115+
final List<NavigatorState> states = <NavigatorState>[];
116+
if (navigatorKey.currentState != null) {
117+
// Set state directly without canPop check
118+
states.add(navigatorKey.currentState!);
119+
}
110120

111121
RouteMatchBase walker = currentConfiguration.matches.last;
112122
while (walker is ShellRouteMatch) {
@@ -119,13 +129,10 @@ class GoRouterDelegate extends RouterDelegate<RouteMatchList>
119129
// Stop if there is a pageless route on top of the shell route.
120130
break;
121131
}
122-
123-
if (potentialCandidate.canPop()) {
124-
state = walker.navigatorKey.currentState;
125-
}
132+
states.add(potentialCandidate);
126133
walker = walker.matches.last;
127134
}
128-
return state;
135+
return states.reversed;
129136
}
130137

131138
bool _handlePopPageWithRouteMatch(

packages/go_router/lib/src/match.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import 'package:collection/collection.dart';
99
import 'package:flutter/foundation.dart';
1010
import 'package:flutter/widgets.dart';
1111
import 'package:logging/logging.dart';
12-
import 'package:meta/meta.dart';
12+
import 'package:meta/meta.dart' as meta;
1313

1414
import 'configuration.dart';
1515
import 'information_provider.dart';
@@ -403,7 +403,7 @@ class ShellRouteMatch extends RouteMatchBase {
403403
///
404404
/// This is typically used when pushing or popping [RouteMatchBase] from
405405
/// [RouteMatchList].
406-
@internal
406+
@meta.internal
407407
ShellRouteMatch copyWith({
408408
required List<RouteMatchBase>? matches,
409409
}) {
@@ -773,7 +773,7 @@ class RouteMatchList with Diagnosticable {
773773
/// returns false.
774774
///
775775
/// This method visit recursively into shell route matches.
776-
@internal
776+
@meta.internal
777777
void visitRouteMatches(RouteMatchVisitor visitor) {
778778
_visitRouteMatches(matches, visitor);
779779
}
@@ -793,7 +793,7 @@ class RouteMatchList with Diagnosticable {
793793
}
794794

795795
/// Create a new [RouteMatchList] with given parameter replaced.
796-
@internal
796+
@meta.internal
797797
RouteMatchList copyWith({
798798
List<RouteMatchBase>? matches,
799799
Uri? uri,
@@ -848,7 +848,7 @@ class RouteMatchList with Diagnosticable {
848848
/// suitable for using with [StandardMessageCodec].
849849
///
850850
/// The primary use of this class is for state restoration and browser history.
851-
@internal
851+
@meta.internal
852852
class RouteMatchListCodec extends Codec<RouteMatchList, Map<Object?, Object?>> {
853853
/// Creates a new [RouteMatchListCodec] object.
854854
RouteMatchListCodec(RouteConfiguration configuration)

packages/go_router/lib/src/route.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'dart:async';
77
import 'package:collection/collection.dart';
88
import 'package:flutter/foundation.dart';
99
import 'package:flutter/widgets.dart';
10-
import 'package:meta/meta.dart';
10+
import 'package:meta/meta.dart' as meta;
1111

1212
import 'configuration.dart';
1313
import 'match.dart';
@@ -459,7 +459,7 @@ class GoRoute extends RouteBase {
459459
extractPathParameters(pathParameters, match);
460460

461461
/// The path parameters in this route.
462-
@internal
462+
@meta.internal
463463
final List<String> pathParameters = <String>[];
464464

465465
@override

packages/go_router/lib/src/router.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,12 +525,16 @@ class GoRouter implements RouterConfig<RouteMatchList> {
525525
///
526526
/// If the top-most route is a pop up or dialog, this method pops it instead
527527
/// of any GoRoute under it.
528+
///
529+
/// Ensure that the `value` of `routeInformationProvider` is synced
530+
/// with `routerDelegate.currentConfiguration`.
528531
void pop<T extends Object?>([T? result]) {
529532
assert(() {
530533
log('popping ${routerDelegate.currentConfiguration.uri}');
531534
return true;
532535
}());
533536
routerDelegate.pop<T>(result);
537+
restore(routerDelegate.currentConfiguration);
534538
}
535539

536540
/// Refresh the route.

0 commit comments

Comments
 (0)