From 1884e2c34e6009ef6d64a8273a651692b003709d Mon Sep 17 00:00:00 2001 From: thangmoxielabs Date: Wed, 6 Dec 2023 01:57:52 +0700 Subject: [PATCH 01/14] add `transitionDelegate` to `GoRouter` and penetrate it through layers to pass to `Navigator` --- packages/go_router/lib/src/builder.dart | 51 ++++++++++++++++-------- packages/go_router/lib/src/delegate.dart | 2 + packages/go_router/lib/src/router.dart | 4 ++ 3 files changed, 41 insertions(+), 16 deletions(-) diff --git a/packages/go_router/lib/src/builder.dart b/packages/go_router/lib/src/builder.dart index e3e116fe758..98e018cbf97 100644 --- a/packages/go_router/lib/src/builder.dart +++ b/packages/go_router/lib/src/builder.dart @@ -46,6 +46,7 @@ class RouteBuilder { required this.observers, required this.onPopPageWithRouteMatch, this.requestFocus = true, + this.transitionDelegate, }); /// Builder function for a go router with Navigator. @@ -91,6 +92,9 @@ class RouteBuilder { final Map, HeroController> _goHeroCache = , HeroController>{}; + /// Pass this down to [Navigator.transitionDelegate] + final TransitionDelegate? transitionDelegate; + /// Builds the top-level Navigator for the given [RouteMatchList]. Widget build( BuildContext context, @@ -111,7 +115,8 @@ class RouteBuilder { final Map, GoRouterState> newRegistry = , GoRouterState>{}; final Widget result = tryBuild(context, matchList, routerNeglect, - configuration.navigatorKey, newRegistry); + configuration.navigatorKey, newRegistry, + transitionDelegate: transitionDelegate); _registry.updateRegistry(newRegistry); return GoRouterStateRegistryScope(registry: _registry, child: result); }, @@ -129,8 +134,9 @@ class RouteBuilder { RouteMatchList matchList, bool routerNeglect, GlobalKey navigatorKey, - Map, GoRouterState> registry, - ) { + Map, GoRouterState> registry, { + TransitionDelegate? transitionDelegate, + }) { // TODO(chunhtai): move the state from local scope to a central place. // https://github.com/flutter/flutter/issues/126365 final _PagePopContext pagePopContext = @@ -140,11 +146,13 @@ class RouteBuilder { _buildNavigator( pagePopContext.onPopPage, _buildPages(context, matchList, pagePopContext, routerNeglect, - navigatorKey, registry), + navigatorKey, registry, + transitionDelegate: transitionDelegate), navigatorKey, observers: observers, restorationScopeId: restorationScopeId, requestFocus: requestFocus, + transitionDelegate: transitionDelegate, ), ); } @@ -152,12 +160,14 @@ class RouteBuilder { /// Returns the top-level pages instead of the root navigator. Used for /// testing. List> _buildPages( - BuildContext context, - RouteMatchList matchList, - _PagePopContext pagePopContext, - bool routerNeglect, - GlobalKey navigatorKey, - Map, GoRouterState> registry) { + BuildContext context, + RouteMatchList matchList, + _PagePopContext pagePopContext, + bool routerNeglect, + GlobalKey navigatorKey, + Map, GoRouterState> registry, { + TransitionDelegate? transitionDelegate, + }) { final Map, List>> keyToPage; if (matchList.isError) { keyToPage = , List>>{ @@ -168,7 +178,8 @@ class RouteBuilder { } else { keyToPage = , List>>{}; _buildRecursive(context, matchList, 0, pagePopContext, routerNeglect, - keyToPage, navigatorKey, registry); + keyToPage, navigatorKey, registry, + transitionDelegate: transitionDelegate); // Every Page should have a corresponding RouteMatch. assert(keyToPage.values.flattened.every((Page page) => @@ -206,8 +217,9 @@ class RouteBuilder { bool routerNeglect, Map, List>> keyToPages, GlobalKey navigatorKey, - Map, GoRouterState> registry, - ) { + Map, GoRouterState> registry, { + TransitionDelegate? transitionDelegate, + }) { if (startIndex >= matchList.matches.length) { return; } @@ -220,7 +232,8 @@ class RouteBuilder { page = _buildErrorPage(context, state); keyToPages.putIfAbsent(navigatorKey, () => >[]).add(page); _buildRecursive(context, matchList, startIndex + 1, pagePopContext, - routerNeglect, keyToPages, navigatorKey, registry); + routerNeglect, keyToPages, navigatorKey, registry, + transitionDelegate: transitionDelegate); } else { // If this RouteBase is for a different Navigator, add it to the // list of out of scope pages @@ -237,7 +250,8 @@ class RouteBuilder { } _buildRecursive(context, matchList, startIndex + 1, pagePopContext, - routerNeglect, keyToPages, navigatorKey, registry); + routerNeglect, keyToPages, navigatorKey, registry, + transitionDelegate: transitionDelegate); } else if (route is ShellRouteBase) { assert(startIndex + 1 < matchList.matches.length, 'Shell routes must always have child routes'); @@ -259,7 +273,8 @@ class RouteBuilder { // Build the remaining pages _buildRecursive(context, matchList, startIndex + 1, pagePopContext, - routerNeglect, keyToPages, shellNavigatorKey, registry); + routerNeglect, keyToPages, shellNavigatorKey, registry, + transitionDelegate: transitionDelegate); final HeroController heroController = _goHeroCache.putIfAbsent( shellNavigatorKey, () => _getHeroController(context)); @@ -278,6 +293,7 @@ class RouteBuilder { restorationScopeId: restorationScopeId, heroController: heroController, requestFocus: requestFocus, + transitionDelegate: transitionDelegate, ); } @@ -312,6 +328,7 @@ class RouteBuilder { String? restorationScopeId, HeroController? heroController, bool requestFocus = true, + TransitionDelegate? transitionDelegate, }) { final Widget navigator = Navigator( key: navigatorKey, @@ -320,6 +337,8 @@ class RouteBuilder { observers: observers, onPopPage: onPopPage, requestFocus: requestFocus, + transitionDelegate: + transitionDelegate ?? const DefaultTransitionDelegate(), ); if (heroController != null) { return HeroControllerScope( diff --git a/packages/go_router/lib/src/delegate.dart b/packages/go_router/lib/src/delegate.dart index 756eba28d79..40fb04ab0ab 100644 --- a/packages/go_router/lib/src/delegate.dart +++ b/packages/go_router/lib/src/delegate.dart @@ -28,6 +28,7 @@ class GoRouterDelegate extends RouterDelegate required this.routerNeglect, String? restorationScopeId, bool requestFocus = true, + TransitionDelegate? transitionDelegate, }) : _configuration = configuration { builder = RouteBuilder( configuration: configuration, @@ -38,6 +39,7 @@ class GoRouterDelegate extends RouterDelegate observers: observers, onPopPageWithRouteMatch: _handlePopPageWithRouteMatch, requestFocus: requestFocus, + transitionDelegate: transitionDelegate, ); } diff --git a/packages/go_router/lib/src/router.dart b/packages/go_router/lib/src/router.dart index dc6d88057eb..9d4564eb69c 100644 --- a/packages/go_router/lib/src/router.dart +++ b/packages/go_router/lib/src/router.dart @@ -138,6 +138,7 @@ class GoRouter implements RouterConfig { GlobalKey? navigatorKey, String? restorationScopeId, bool requestFocus = true, + TransitionDelegate? transitionDelegate, }) { return GoRouter.routingConfig( routingConfig: _ConstantRoutingConfig( @@ -160,6 +161,7 @@ class GoRouter implements RouterConfig { navigatorKey: navigatorKey, restorationScopeId: restorationScopeId, requestFocus: requestFocus, + transitionDelegate: transitionDelegate, ); } @@ -182,6 +184,7 @@ class GoRouter implements RouterConfig { GlobalKey? navigatorKey, String? restorationScopeId, bool requestFocus = true, + TransitionDelegate? transitionDelegate, }) : _routingConfig = routingConfig, backButtonDispatcher = RootBackButtonDispatcher(), assert( @@ -242,6 +245,7 @@ class GoRouter implements RouterConfig { ], restorationScopeId: restorationScopeId, requestFocus: requestFocus, + transitionDelegate: transitionDelegate, // wrap the returned Navigator to enable GoRouter.of(context).go() et al, // allowing the caller to wrap the navigator themselves builderWithNav: (BuildContext context, Widget child) => From 50416dd87dbc6058aaea3bef7f0646b6842369e4 Mon Sep 17 00:00:00 2001 From: Thang Date: Tue, 28 May 2024 23:28:50 +0700 Subject: [PATCH 02/14] add [GoRouter.goRelative] and tests. Add TypedRelativeGoRoute and its builder without tests --- .../lib/src/information_provider.dart | 27 ++ .../go_router/lib/src/misc/extensions.dart | 7 + packages/go_router/lib/src/route_data.dart | 11 + packages/go_router/lib/src/router.dart | 9 + packages/go_router/test/go_router_test.dart | 277 ++++++++++++++++++ .../lib/src/go_router_generator.dart | 1 + .../lib/src/route_config.dart | 246 ++++++++++++++++ 7 files changed, 578 insertions(+) diff --git a/packages/go_router/lib/src/information_provider.dart b/packages/go_router/lib/src/information_provider.dart index dc979193b32..999cd530a25 100644 --- a/packages/go_router/lib/src/information_provider.dart +++ b/packages/go_router/lib/src/information_provider.dart @@ -172,6 +172,33 @@ class GoRouteInformationProvider extends RouteInformationProvider ); } + /// Relatively go to [relativeLocation]. + void goRelative(String relativeLocation, {Object? extra}) { + assert( + !relativeLocation.startsWith('/'), + "Relative locations must not start with a '/'.", + ); + + final Uri currentUri = value.uri; + Uri newUri = Uri.parse( + currentUri.path.endsWith('/') + ? '${currentUri.path}$relativeLocation' + : '${currentUri.path}/$relativeLocation', + ); + newUri = newUri.replace(queryParameters: { + ...currentUri.queryParameters, + ...newUri.queryParameters, + }); + + _setValue( + newUri.toString(), + RouteInformationState( + extra: extra, + type: NavigatingType.go, + ), + ); + } + /// Restores the current route matches with the `matchList`. void restore(String location, {required RouteMatchList matchList}) { _setValue( diff --git a/packages/go_router/lib/src/misc/extensions.dart b/packages/go_router/lib/src/misc/extensions.dart index c137022b802..f5f654ce475 100644 --- a/packages/go_router/lib/src/misc/extensions.dart +++ b/packages/go_router/lib/src/misc/extensions.dart @@ -24,6 +24,13 @@ extension GoRouterHelper on BuildContext { void go(String location, {Object? extra}) => GoRouter.of(this).go(location, extra: extra); + /// Navigate relative to a location. + void goRelative(String location, {Object? extra}) => + GoRouter.of(this).goRelative( + location, + extra: extra, + ); + /// Navigate to a named route. void goNamed( String name, { diff --git a/packages/go_router/lib/src/route_data.dart b/packages/go_router/lib/src/route_data.dart index b10f2b11158..6e8716a574d 100644 --- a/packages/go_router/lib/src/route_data.dart +++ b/packages/go_router/lib/src/route_data.dart @@ -365,6 +365,17 @@ class TypedGoRoute extends TypedRoute { final List> routes; } +/// A superclass for each typed go route descendant +@Target({TargetKind.library, TargetKind.classType}) +class TypedRelativeGoRoute extends TypedGoRoute { + /// Default const constructor + const TypedRelativeGoRoute({ + required super.path, + super.name, + super.routes = const >[], + }); +} + /// A superclass for each typed shell route descendant @Target({TargetKind.library, TargetKind.classType}) class TypedShellRoute extends TypedRoute { diff --git a/packages/go_router/lib/src/router.dart b/packages/go_router/lib/src/router.dart index 9d4564eb69c..fa7d48e0c82 100644 --- a/packages/go_router/lib/src/router.dart +++ b/packages/go_router/lib/src/router.dart @@ -344,6 +344,15 @@ class GoRouter implements RouterConfig { routeInformationProvider.go(location, extra: extra); } + /// Navigate to a URI location by appending [relativeLocation] to the current [GoRouterState.matchedLocation] w/ optional query parameters, e.g. + void goRelative( + String relativeLocation, { + Object? extra, + }) { + log('going relative to $relativeLocation'); + routeInformationProvider.goRelative(relativeLocation, extra: extra); + } + /// Restore the RouteMatchList void restore(RouteMatchList matchList) { log('restoring ${matchList.uri}'); diff --git a/packages/go_router/test/go_router_test.dart b/packages/go_router/test/go_router_test.dart index f395faf906f..3598bfe2ade 100644 --- a/packages/go_router/test/go_router_test.dart +++ b/packages/go_router/test/go_router_test.dart @@ -1791,6 +1791,283 @@ void main() { }); }); + group('go relative', () { + testWidgets('from default route', (WidgetTester tester) async { + final List routes = [ + GoRoute( + path: '/', + builder: (BuildContext context, GoRouterState state) => + const HomeScreen(), + routes: [ + GoRoute( + path: 'login', + builder: (BuildContext context, GoRouterState state) => + const LoginScreen(), + ), + ], + ), + ]; + + final GoRouter router = await createRouter(routes, tester); + router.goRelative('login'); + await tester.pumpAndSettle(); + expect(find.byType(LoginScreen), findsOneWidget); + }); + + testWidgets('from non-default route', (WidgetTester tester) async { + final List routes = [ + GoRoute( + path: '/home', + builder: (BuildContext context, GoRouterState state) => + const HomeScreen(), + routes: [ + GoRoute( + path: 'login', + builder: (BuildContext context, GoRouterState state) => + const LoginScreen(), + ), + ], + ), + ]; + + final GoRouter router = await createRouter(routes, tester); + router.go('/home'); + router.goRelative('login'); + await tester.pumpAndSettle(); + expect(find.byType(LoginScreen), findsOneWidget); + }); + + testWidgets('match w/ path params', (WidgetTester tester) async { + const String fid = 'f2'; + const String pid = 'p1'; + + final List routes = [ + GoRoute( + path: '/home', + builder: (BuildContext context, GoRouterState state) => + const HomeScreen(), + routes: [ + GoRoute( + path: 'family/:fid', + builder: (BuildContext context, GoRouterState state) => + const FamilyScreen('dummy'), + routes: [ + GoRoute( + name: 'person', + path: 'person/:pid', + builder: (BuildContext context, GoRouterState state) { + expect(state.pathParameters, + {'fid': fid, 'pid': pid}); + return const PersonScreen('dummy', 'dummy'); + }, + ), + ], + ), + ], + ), + ]; + + final GoRouter router = + await createRouter(routes, tester, initialLocation: '/home'); + router.go('/'); + + router.goRelative('family/$fid'); + await tester.pumpAndSettle(); + expect(find.byType(FamilyScreen), findsOneWidget); + + router.goRelative('person/$pid'); + await tester.pumpAndSettle(); + expect(find.byType(PersonScreen), findsOneWidget); + }); + + testWidgets('match w/ query params', (WidgetTester tester) async { + const String fid = 'f2'; + const String pid = 'p1'; + + final List routes = [ + GoRoute( + path: '/home', + builder: (BuildContext context, GoRouterState state) => + const HomeScreen(), + routes: [ + GoRoute( + path: 'family', + builder: (BuildContext context, GoRouterState state) => + const FamilyScreen('dummy'), + routes: [ + GoRoute( + path: 'person', + builder: (BuildContext context, GoRouterState state) { + expect(state.uri.queryParameters, + {'fid': fid, 'pid': pid}); + return const PersonScreen('dummy', 'dummy'); + }, + ), + ], + ), + ], + ), + ]; + + final GoRouter router = + await createRouter(routes, tester, initialLocation: '/home'); + + router.goRelative('family?fid=$fid'); + await tester.pumpAndSettle(); + expect(find.byType(FamilyScreen), findsOneWidget); + + router.goRelative('person?pid=$pid'); + await tester.pumpAndSettle(); + expect(find.byType(PersonScreen), findsOneWidget); + }); + + testWidgets('too few params', (WidgetTester tester) async { + const String pid = 'p1'; + + final List routes = [ + GoRoute( + path: '/home', + builder: (BuildContext context, GoRouterState state) => + const HomeScreen(), + routes: [ + GoRoute( + path: 'family/:fid', + builder: (BuildContext context, GoRouterState state) => + const FamilyScreen('dummy'), + routes: [ + GoRoute( + path: 'person/:pid', + builder: (BuildContext context, GoRouterState state) => + const PersonScreen('dummy', 'dummy'), + ), + ], + ), + ], + ), + ]; + // await expectLater(() async { + final GoRouter router = await createRouter( + routes, + tester, + initialLocation: '/home', + errorBuilder: (BuildContext context, GoRouterState state) => + TestErrorScreen(state.error!), + ); + router.goRelative('family/person/$pid'); + await tester.pumpAndSettle(); + expect(find.byType(TestErrorScreen), findsOneWidget); + + final List matches = + router.routerDelegate.currentConfiguration.matches; + expect(matches, hasLength(0)); + }); + + testWidgets('match no route', (WidgetTester tester) async { + final List routes = [ + GoRoute( + path: '/home', + builder: (BuildContext context, GoRouterState state) => + const HomeScreen(), + routes: [ + GoRoute( + path: 'family', + builder: (BuildContext context, GoRouterState state) => + const FamilyScreen('dummy'), + routes: [ + GoRoute( + path: 'person', + builder: (BuildContext context, GoRouterState state) => + const PersonScreen('dummy', 'dummy'), + ), + ], + ), + ], + ), + ]; + + final GoRouter router = await createRouter( + routes, + tester, + initialLocation: '/home', + errorBuilder: (BuildContext context, GoRouterState state) => + TestErrorScreen(state.error!), + ); + router.go('person'); + + await tester.pumpAndSettle(); + expect(find.byType(TestErrorScreen), findsOneWidget); + + final List matches = + router.routerDelegate.currentConfiguration.matches; + expect(matches, hasLength(0)); + }); + + testWidgets('preserve path param spaces and slashes', + (WidgetTester tester) async { + const String param1 = 'param w/ spaces and slashes'; + final List routes = [ + GoRoute( + path: '/home', + builder: dummy, + routes: [ + GoRoute( + path: 'page1/:param1', + builder: (BuildContext c, GoRouterState s) { + expect(s.pathParameters['param1'], param1); + return const DummyScreen(); + }, + ), + ], + ) + ]; + + final GoRouter router = + await createRouter(routes, tester, initialLocation: '/home'); + final String loc = 'page1/${Uri.encodeComponent(param1)}'; + router.goRelative(loc); + + await tester.pumpAndSettle(); + expect(find.byType(DummyScreen), findsOneWidget); + + final RouteMatchList matches = router.routerDelegate.currentConfiguration; + expect(matches.pathParameters['param1'], param1); + }); + + testWidgets('preserve query param spaces and slashes', + (WidgetTester tester) async { + const String param1 = 'param w/ spaces and slashes'; + final List routes = [ + GoRoute( + path: '/home', + builder: dummy, + routes: [ + GoRoute( + path: 'page1', + builder: (BuildContext c, GoRouterState s) { + expect(s.uri.queryParameters['param1'], param1); + return const DummyScreen(); + }, + ), + ], + ) + ]; + + final GoRouter router = + await createRouter(routes, tester, initialLocation: '/home'); + + router.goRelative(Uri( + path: 'page1', + queryParameters: {'param1': param1}, + ).toString()); + + await tester.pumpAndSettle(); + expect(find.byType(DummyScreen), findsOneWidget); + + final RouteMatchList matches = router.routerDelegate.currentConfiguration; + expect(matches.uri.queryParameters['param1'], param1); + }); + }); + group('redirects', () { testWidgets('top-level redirect', (WidgetTester tester) async { final List routes = [ diff --git a/packages/go_router_builder/lib/src/go_router_generator.dart b/packages/go_router_builder/lib/src/go_router_generator.dart index e094d1f98ed..1032b78873d 100644 --- a/packages/go_router_builder/lib/src/go_router_generator.dart +++ b/packages/go_router_builder/lib/src/go_router_generator.dart @@ -15,6 +15,7 @@ const String _routeDataUrl = 'package:go_router/src/route_data.dart'; const Map _annotations = { 'TypedGoRoute': 'GoRouteData', + 'TypedRelativeRoute': 'GoRouteData', 'TypedShellRoute': 'ShellRouteData', 'TypedStatefulShellBranch': 'StatefulShellBranchData', 'TypedStatefulShellRoute': 'StatefulShellRouteData', diff --git a/packages/go_router_builder/lib/src/route_config.dart b/packages/go_router_builder/lib/src/route_config.dart index 0cfa7a3928c..f4ca278b908 100644 --- a/packages/go_router_builder/lib/src/route_config.dart +++ b/packages/go_router_builder/lib/src/route_config.dart @@ -424,6 +424,233 @@ extension $_extensionName on $_className { String get dataConvertionFunctionName => r'$route'; } +/// The configuration to generate class declarations for a GoRouteData. +class GoRelativeRouteConfig extends RouteBaseConfig { + GoRelativeRouteConfig._({ + required this.path, + required this.name, + required this.parentNavigatorKey, + required super.routeDataClass, + required super.parent, + }) : super._(); + + /// The path of the GoRoute to be created by this configuration. + final String path; + + /// The name of the GoRoute to be created by this configuration. + final String? name; + + /// The parent navigator key. + final String? parentNavigatorKey; + + late final Set _pathParams = pathParametersFromPattern(path); + + // construct path bits using parent bits + // if there are any queryParam objects, add in the `queryParam` bits + String get _locationArgs { + final Map pathParameters = Map.fromEntries( + _pathParams.map((String pathParameter) { + // Enum types are encoded using a map, so we need a nullability check + // here to ensure it matches Uri.encodeComponent nullability + final DartType? type = _field(pathParameter)?.returnType; + final String value = + '\${Uri.encodeComponent(${_encodeFor(pathParameter)}${type?.isEnum ?? false ? '!' : ''})}'; + return MapEntry(pathParameter, value); + }), + ); + final String location = patternToPath(path, pathParameters); + return "'$location'"; + } + + ParameterElement? get _extraParam => _ctor.parameters + .singleWhereOrNull((ParameterElement element) => element.isExtraField); + + String get _fromStateConstructor { + final StringBuffer buffer = StringBuffer('=>'); + if (_ctor.isConst && + _ctorParams.isEmpty && + _ctorQueryParams.isEmpty && + _extraParam == null) { + buffer.writeln('const '); + } + + buffer.writeln('$_className('); + for (final ParameterElement param in [ + ..._ctorParams, + ..._ctorQueryParams, + if (_extraParam != null) _extraParam!, + ]) { + buffer.write(_decodeFor(param)); + } + buffer.writeln(');'); + + return buffer.toString(); + } + + String _decodeFor(ParameterElement element) { + if (element.isRequired) { + if (element.type.nullabilitySuffix == NullabilitySuffix.question && + _pathParams.contains(element.name)) { + throw InvalidGenerationSourceError( + 'Required parameters in the path cannot be nullable.', + element: element, + ); + } + } + final String fromStateExpression = decodeParameter(element, _pathParams); + + if (element.isPositional) { + return '$fromStateExpression,'; + } + + if (element.isNamed) { + return '${element.name}: $fromStateExpression,'; + } + + throw InvalidGenerationSourceError( + '$likelyIssueMessage (param not named or positional)', + element: element, + ); + } + + String _encodeFor(String fieldName) { + final PropertyAccessorElement? field = _field(fieldName); + if (field == null) { + throw InvalidGenerationSourceError( + 'Could not find a field for the path parameter "$fieldName".', + element: routeDataClass, + ); + } + + return encodeField(field); + } + + String get _locationQueryParams { + if (_ctorQueryParams.isEmpty) { + return ''; + } + + final StringBuffer buffer = StringBuffer('queryParams: {\n'); + + for (final ParameterElement param in _ctorQueryParams) { + final String parameterName = param.name; + + final List conditions = []; + if (param.hasDefaultValue) { + if (param.type.isNullableType) { + throw NullableDefaultValueError(param); + } + conditions.add('$parameterName != ${param.defaultValueCode!}'); + } else if (param.type.isNullableType) { + conditions.add('$parameterName != null'); + } + String line = ''; + if (conditions.isNotEmpty) { + line = 'if (${conditions.join(' && ')}) '; + } + line += '${escapeDartString(parameterName.kebab)}: ' + '${_encodeFor(parameterName)},'; + + buffer.writeln(line); + } + + buffer.writeln('},'); + + return buffer.toString(); + } + + late final List _ctorParams = + _ctor.parameters.where((ParameterElement element) { + if (_pathParams.contains(element.name)) { + return true; + } + return false; + }).toList(); + + late final List _ctorQueryParams = _ctor.parameters + .where((ParameterElement element) => + !_pathParams.contains(element.name) && !element.isExtraField) + .toList(); + + ConstructorElement get _ctor { + final ConstructorElement? ctor = routeDataClass.unnamedConstructor; + + if (ctor == null) { + throw InvalidGenerationSourceError( + 'Missing default constructor', + element: routeDataClass, + ); + } + return ctor; + } + + @override + Iterable classDeclarations() => [ + _extensionDefinition, + ..._enumDeclarations(), + ]; + + String get _extensionDefinition => ''' +extension $_extensionName on $_className { + static $_className _fromState(GoRouterState state) $_fromStateConstructor + + String get location => GoRouteData.\$location($_locationArgs,$_locationQueryParams); + + void goRelative(BuildContext context) => + context.goRelative(location${_extraParam != null ? ', extra: $extraFieldName' : ''}); + + Future push(BuildContext context) => + context.push(location${_extraParam != null ? ', extra: $extraFieldName' : ''}); + + void pushReplacement(BuildContext context) => + context.pushReplacement(location${_extraParam != null ? ', extra: $extraFieldName' : ''}); + + void replace(BuildContext context) => + context.replace(location${_extraParam != null ? ', extra: $extraFieldName' : ''}); +} +'''; + + /// Returns code representing the constant maps that contain the `enum` to + /// [String] mapping for each referenced enum. + Iterable _enumDeclarations() { + final Set enumParamTypes = {}; + + for (final ParameterElement ctorParam in [ + ..._ctorParams, + ..._ctorQueryParams, + ]) { + DartType potentialEnumType = ctorParam.type; + if (potentialEnumType is ParameterizedType && + (ctorParam.type as ParameterizedType).typeArguments.isNotEmpty) { + potentialEnumType = + (ctorParam.type as ParameterizedType).typeArguments.first; + } + + if (potentialEnumType.isEnum) { + enumParamTypes.add(potentialEnumType as InterfaceType); + } + } + return enumParamTypes.map(_enumMapConst); + } + + @override + String get factorConstructorParameters => + 'factory: $_extensionName._fromState,'; + + @override + String get routeConstructorParameters => ''' + path: ${escapeDartString(path)}, + ${name != null ? 'name: ${escapeDartString(name!)},' : ''} + ${parentNavigatorKey == null ? '' : 'parentNavigatorKey: $parentNavigatorKey,'} +'''; + + @override + String get routeDataClassName => 'GoRouteData'; + + @override + String get dataConvertionFunctionName => r'$route'; +} + /// Represents a `TypedGoRoute` annotation to the builder. abstract class RouteBaseConfig { RouteBaseConfig._({ @@ -550,6 +777,25 @@ abstract class RouteBaseConfig { parameterName: r'$parentNavigatorKey', ), ); + case 'TypedRelativeGoRoute': + final ConstantReader pathValue = reader.read('path'); + if (pathValue.isNull) { + throw InvalidGenerationSourceError( + 'Missing `path` value on annotation.', + element: element, + ); + } + final ConstantReader nameValue = reader.read('name'); + value = GoRelativeRouteConfig._( + path: pathValue.stringValue, + name: nameValue.isNull ? null : nameValue.stringValue, + routeDataClass: classElement, + parent: parent, + parentNavigatorKey: _generateParameterGetterCode( + classElement, + parameterName: r'$parentNavigatorKey', + ), + ); default: throw UnsupportedError('Unrecognized type $typeName'); } From f397458026c9525c6971139caa26cc882844089e Mon Sep 17 00:00:00 2001 From: Thang Date: Tue, 28 May 2024 23:56:47 +0700 Subject: [PATCH 03/14] Revert "add `transitionDelegate` to `GoRouter` and penetrate it through layers to pass to `Navigator`" This reverts commit 1884e2c34e6009ef6d64a8273a651692b003709d. --- packages/go_router/lib/src/builder.dart | 10 ---------- packages/go_router/lib/src/delegate.dart | 2 -- packages/go_router/lib/src/router.dart | 4 ---- 3 files changed, 16 deletions(-) diff --git a/packages/go_router/lib/src/builder.dart b/packages/go_router/lib/src/builder.dart index 8a5c7d73349..49b6372c693 100644 --- a/packages/go_router/lib/src/builder.dart +++ b/packages/go_router/lib/src/builder.dart @@ -58,7 +58,6 @@ class RouteBuilder { required this.observers, required this.onPopPageWithRouteMatch, this.requestFocus = true, - this.transitionDelegate, }); /// Builder function for a go router with Navigator. @@ -95,9 +94,6 @@ class RouteBuilder { /// If this method returns false, this builder aborts the pop. final PopPageWithRouteMatchCallback onPopPageWithRouteMatch; - /// Pass this down to [Navigator.transitionDelegate] - final TransitionDelegate? transitionDelegate; - /// Builds the top-level Navigator for the given [RouteMatchList]. Widget build( BuildContext context, @@ -122,7 +118,6 @@ class RouteBuilder { configuration: configuration, errorBuilder: errorBuilder, errorPageBuilder: errorPageBuilder, - transitionDelegate: transitionDelegate, ), ); } @@ -140,7 +135,6 @@ class _CustomNavigator extends StatefulWidget { required this.configuration, required this.errorBuilder, required this.errorPageBuilder, - required this.transitionDelegate, }); final GlobalKey navigatorKey; @@ -158,7 +152,6 @@ class _CustomNavigator extends StatefulWidget { final String? navigatorRestorationId; final GoRouterWidgetBuilder? errorBuilder; final GoRouterPageBuilder? errorPageBuilder; - final TransitionDelegate? transitionDelegate; @override State createState() => _CustomNavigatorState(); @@ -293,7 +286,6 @@ class _CustomNavigatorState extends State<_CustomNavigator> { // This is used to recursively build pages under this shell route. errorBuilder: widget.errorBuilder, errorPageBuilder: widget.errorPageBuilder, - transitionDelegate: widget.transitionDelegate, ); }, ); @@ -440,8 +432,6 @@ class _CustomNavigatorState extends State<_CustomNavigator> { pages: _pages!, observers: widget.observers, onPopPage: _handlePopPage, - transitionDelegate: widget.transitionDelegate ?? - const DefaultTransitionDelegate(), ), ), ); diff --git a/packages/go_router/lib/src/delegate.dart b/packages/go_router/lib/src/delegate.dart index 1dbde6227ce..eba3ef0c801 100644 --- a/packages/go_router/lib/src/delegate.dart +++ b/packages/go_router/lib/src/delegate.dart @@ -28,7 +28,6 @@ class GoRouterDelegate extends RouterDelegate required this.routerNeglect, String? restorationScopeId, bool requestFocus = true, - TransitionDelegate? transitionDelegate, }) : _configuration = configuration { builder = RouteBuilder( configuration: configuration, @@ -39,7 +38,6 @@ class GoRouterDelegate extends RouterDelegate observers: observers, onPopPageWithRouteMatch: _handlePopPageWithRouteMatch, requestFocus: requestFocus, - transitionDelegate: transitionDelegate, ); } diff --git a/packages/go_router/lib/src/router.dart b/packages/go_router/lib/src/router.dart index fa7d48e0c82..0146a1ca29c 100644 --- a/packages/go_router/lib/src/router.dart +++ b/packages/go_router/lib/src/router.dart @@ -138,7 +138,6 @@ class GoRouter implements RouterConfig { GlobalKey? navigatorKey, String? restorationScopeId, bool requestFocus = true, - TransitionDelegate? transitionDelegate, }) { return GoRouter.routingConfig( routingConfig: _ConstantRoutingConfig( @@ -161,7 +160,6 @@ class GoRouter implements RouterConfig { navigatorKey: navigatorKey, restorationScopeId: restorationScopeId, requestFocus: requestFocus, - transitionDelegate: transitionDelegate, ); } @@ -184,7 +182,6 @@ class GoRouter implements RouterConfig { GlobalKey? navigatorKey, String? restorationScopeId, bool requestFocus = true, - TransitionDelegate? transitionDelegate, }) : _routingConfig = routingConfig, backButtonDispatcher = RootBackButtonDispatcher(), assert( @@ -245,7 +242,6 @@ class GoRouter implements RouterConfig { ], restorationScopeId: restorationScopeId, requestFocus: requestFocus, - transitionDelegate: transitionDelegate, // wrap the returned Navigator to enable GoRouter.of(context).go() et al, // allowing the caller to wrap the navigator themselves builderWithNav: (BuildContext context, Widget child) => From f411cebd3fdc21658cfb4b897179da5e16cfffdf Mon Sep 17 00:00:00 2001 From: Thang Date: Wed, 29 May 2024 00:19:28 +0700 Subject: [PATCH 04/14] TypedRelativeGoRoute shouldn't inherit TypedGoRoute, and it should only be goRelative-able --- packages/go_router/lib/src/route_data.dart | 19 +++++++++++++++---- .../lib/src/route_config.dart | 15 ++++----------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/packages/go_router/lib/src/route_data.dart b/packages/go_router/lib/src/route_data.dart index 6e8716a574d..59ff3893052 100644 --- a/packages/go_router/lib/src/route_data.dart +++ b/packages/go_router/lib/src/route_data.dart @@ -367,13 +367,24 @@ class TypedGoRoute extends TypedRoute { /// A superclass for each typed go route descendant @Target({TargetKind.library, TargetKind.classType}) -class TypedRelativeGoRoute extends TypedGoRoute { +class TypedRelativeGoRoute extends TypedRoute { /// Default const constructor const TypedRelativeGoRoute({ - required super.path, - super.name, - super.routes = const >[], + required this.path, + this.routes = const >[], }); + + /// The relative path that corresponds to this route. + /// + /// See [GoRoute.path]. + /// + /// + final String path; + + /// Child route definitions. + /// + /// See [RouteBase.routes]. + final List> routes; } /// A superclass for each typed shell route descendant diff --git a/packages/go_router_builder/lib/src/route_config.dart b/packages/go_router_builder/lib/src/route_config.dart index f4ca278b908..d3724ca42ed 100644 --- a/packages/go_router_builder/lib/src/route_config.dart +++ b/packages/go_router_builder/lib/src/route_config.dart @@ -209,8 +209,10 @@ class GoRouteConfig extends RouteBaseConfig { RouteBaseConfig? config = this; while (config != null) { - if (config is GoRouteConfig) { - pathSegments.add(config.path); + if (config + case GoRouteConfig(:final String path) || + GoRelativeRouteConfig(:final String path)) { + pathSegments.add(path); } config = config.parent; } @@ -598,15 +600,6 @@ extension $_extensionName on $_className { void goRelative(BuildContext context) => context.goRelative(location${_extraParam != null ? ', extra: $extraFieldName' : ''}); - - Future push(BuildContext context) => - context.push(location${_extraParam != null ? ', extra: $extraFieldName' : ''}); - - void pushReplacement(BuildContext context) => - context.pushReplacement(location${_extraParam != null ? ', extra: $extraFieldName' : ''}); - - void replace(BuildContext context) => - context.replace(location${_extraParam != null ? ', extra: $extraFieldName' : ''}); } '''; From c6de77298f06cd80026e76014be09aca396e4689 Mon Sep 17 00:00:00 2001 From: Thang Date: Wed, 29 May 2024 00:43:28 +0700 Subject: [PATCH 05/14] update versions go_router & go_router_builder --- packages/go_router/CHANGELOG.md | 4 ++++ packages/go_router/pubspec.yaml | 2 +- packages/go_router_builder/CHANGELOG.md | 4 ++++ packages/go_router_builder/pubspec.yaml | 2 +- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/go_router/CHANGELOG.md b/packages/go_router/CHANGELOG.md index 7b3e451ba90..96a991198bc 100644 --- a/packages/go_router/CHANGELOG.md +++ b/packages/go_router/CHANGELOG.md @@ -1,5 +1,9 @@ ## 14.1.3 +- Adds `GoRouter.goRelative` + +## 14.1.3 + - Improves the logging of routes when `debugLogDiagnostics` is enabled or `debugKnownRoutes() is called. Explains the position of shell routes in the route tree. Prints the widget name of the routes it is building. ## 14.1.2 diff --git a/packages/go_router/pubspec.yaml b/packages/go_router/pubspec.yaml index 578b394be77..4d8331d16a6 100644 --- a/packages/go_router/pubspec.yaml +++ b/packages/go_router/pubspec.yaml @@ -1,7 +1,7 @@ name: go_router description: A declarative router for Flutter based on Navigation 2 supporting deep linking, data-driven routes and more -version: 14.1.3 +version: 14.1.4 repository: https://github.com/flutter/packages/tree/main/packages/go_router issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+go_router%22 diff --git a/packages/go_router_builder/CHANGELOG.md b/packages/go_router_builder/CHANGELOG.md index 3332a70e1b8..8357de4d3f0 100644 --- a/packages/go_router_builder/CHANGELOG.md +++ b/packages/go_router_builder/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.7.1 + +- Adds `TypedRelativeGoRoute` annotation which supports relative routes. + ## 2.7.0 - Adds an example and a test with `onExit`. diff --git a/packages/go_router_builder/pubspec.yaml b/packages/go_router_builder/pubspec.yaml index 0e6e10b6b3d..6fba2f8dc9f 100644 --- a/packages/go_router_builder/pubspec.yaml +++ b/packages/go_router_builder/pubspec.yaml @@ -2,7 +2,7 @@ name: go_router_builder description: >- A builder that supports generated strongly-typed route helpers for package:go_router -version: 2.7.0 +version: 2.7.1 repository: https://github.com/flutter/packages/tree/main/packages/go_router_builder issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+go_router_builder%22 From 5abfe4a9b904cf4341971cf229b81227a0e4c929 Mon Sep 17 00:00:00 2001 From: Thang Date: Wed, 29 May 2024 13:45:26 +0700 Subject: [PATCH 06/14] Strip away changes in go_router_builder. Update go_router changelog --- packages/go_router/CHANGELOG.md | 1 + packages/go_router_builder/CHANGELOG.md | 4 - .../lib/src/go_router_generator.dart | 1 - .../lib/src/route_config.dart | 243 +----------------- packages/go_router_builder/pubspec.yaml | 2 +- 5 files changed, 4 insertions(+), 247 deletions(-) diff --git a/packages/go_router/CHANGELOG.md b/packages/go_router/CHANGELOG.md index 96a991198bc..35d839ee813 100644 --- a/packages/go_router/CHANGELOG.md +++ b/packages/go_router/CHANGELOG.md @@ -1,6 +1,7 @@ ## 14.1.3 - Adds `GoRouter.goRelative` +- Adds `TypedRelativeGoRoute` ## 14.1.3 diff --git a/packages/go_router_builder/CHANGELOG.md b/packages/go_router_builder/CHANGELOG.md index 8357de4d3f0..3332a70e1b8 100644 --- a/packages/go_router_builder/CHANGELOG.md +++ b/packages/go_router_builder/CHANGELOG.md @@ -1,7 +1,3 @@ -## 2.7.1 - -- Adds `TypedRelativeGoRoute` annotation which supports relative routes. - ## 2.7.0 - Adds an example and a test with `onExit`. diff --git a/packages/go_router_builder/lib/src/go_router_generator.dart b/packages/go_router_builder/lib/src/go_router_generator.dart index 1032b78873d..e094d1f98ed 100644 --- a/packages/go_router_builder/lib/src/go_router_generator.dart +++ b/packages/go_router_builder/lib/src/go_router_generator.dart @@ -15,7 +15,6 @@ const String _routeDataUrl = 'package:go_router/src/route_data.dart'; const Map _annotations = { 'TypedGoRoute': 'GoRouteData', - 'TypedRelativeRoute': 'GoRouteData', 'TypedShellRoute': 'ShellRouteData', 'TypedStatefulShellBranch': 'StatefulShellBranchData', 'TypedStatefulShellRoute': 'StatefulShellRouteData', diff --git a/packages/go_router_builder/lib/src/route_config.dart b/packages/go_router_builder/lib/src/route_config.dart index d3724ca42ed..0cfa7a3928c 100644 --- a/packages/go_router_builder/lib/src/route_config.dart +++ b/packages/go_router_builder/lib/src/route_config.dart @@ -209,10 +209,8 @@ class GoRouteConfig extends RouteBaseConfig { RouteBaseConfig? config = this; while (config != null) { - if (config - case GoRouteConfig(:final String path) || - GoRelativeRouteConfig(:final String path)) { - pathSegments.add(path); + if (config is GoRouteConfig) { + pathSegments.add(config.path); } config = config.parent; } @@ -426,224 +424,6 @@ extension $_extensionName on $_className { String get dataConvertionFunctionName => r'$route'; } -/// The configuration to generate class declarations for a GoRouteData. -class GoRelativeRouteConfig extends RouteBaseConfig { - GoRelativeRouteConfig._({ - required this.path, - required this.name, - required this.parentNavigatorKey, - required super.routeDataClass, - required super.parent, - }) : super._(); - - /// The path of the GoRoute to be created by this configuration. - final String path; - - /// The name of the GoRoute to be created by this configuration. - final String? name; - - /// The parent navigator key. - final String? parentNavigatorKey; - - late final Set _pathParams = pathParametersFromPattern(path); - - // construct path bits using parent bits - // if there are any queryParam objects, add in the `queryParam` bits - String get _locationArgs { - final Map pathParameters = Map.fromEntries( - _pathParams.map((String pathParameter) { - // Enum types are encoded using a map, so we need a nullability check - // here to ensure it matches Uri.encodeComponent nullability - final DartType? type = _field(pathParameter)?.returnType; - final String value = - '\${Uri.encodeComponent(${_encodeFor(pathParameter)}${type?.isEnum ?? false ? '!' : ''})}'; - return MapEntry(pathParameter, value); - }), - ); - final String location = patternToPath(path, pathParameters); - return "'$location'"; - } - - ParameterElement? get _extraParam => _ctor.parameters - .singleWhereOrNull((ParameterElement element) => element.isExtraField); - - String get _fromStateConstructor { - final StringBuffer buffer = StringBuffer('=>'); - if (_ctor.isConst && - _ctorParams.isEmpty && - _ctorQueryParams.isEmpty && - _extraParam == null) { - buffer.writeln('const '); - } - - buffer.writeln('$_className('); - for (final ParameterElement param in [ - ..._ctorParams, - ..._ctorQueryParams, - if (_extraParam != null) _extraParam!, - ]) { - buffer.write(_decodeFor(param)); - } - buffer.writeln(');'); - - return buffer.toString(); - } - - String _decodeFor(ParameterElement element) { - if (element.isRequired) { - if (element.type.nullabilitySuffix == NullabilitySuffix.question && - _pathParams.contains(element.name)) { - throw InvalidGenerationSourceError( - 'Required parameters in the path cannot be nullable.', - element: element, - ); - } - } - final String fromStateExpression = decodeParameter(element, _pathParams); - - if (element.isPositional) { - return '$fromStateExpression,'; - } - - if (element.isNamed) { - return '${element.name}: $fromStateExpression,'; - } - - throw InvalidGenerationSourceError( - '$likelyIssueMessage (param not named or positional)', - element: element, - ); - } - - String _encodeFor(String fieldName) { - final PropertyAccessorElement? field = _field(fieldName); - if (field == null) { - throw InvalidGenerationSourceError( - 'Could not find a field for the path parameter "$fieldName".', - element: routeDataClass, - ); - } - - return encodeField(field); - } - - String get _locationQueryParams { - if (_ctorQueryParams.isEmpty) { - return ''; - } - - final StringBuffer buffer = StringBuffer('queryParams: {\n'); - - for (final ParameterElement param in _ctorQueryParams) { - final String parameterName = param.name; - - final List conditions = []; - if (param.hasDefaultValue) { - if (param.type.isNullableType) { - throw NullableDefaultValueError(param); - } - conditions.add('$parameterName != ${param.defaultValueCode!}'); - } else if (param.type.isNullableType) { - conditions.add('$parameterName != null'); - } - String line = ''; - if (conditions.isNotEmpty) { - line = 'if (${conditions.join(' && ')}) '; - } - line += '${escapeDartString(parameterName.kebab)}: ' - '${_encodeFor(parameterName)},'; - - buffer.writeln(line); - } - - buffer.writeln('},'); - - return buffer.toString(); - } - - late final List _ctorParams = - _ctor.parameters.where((ParameterElement element) { - if (_pathParams.contains(element.name)) { - return true; - } - return false; - }).toList(); - - late final List _ctorQueryParams = _ctor.parameters - .where((ParameterElement element) => - !_pathParams.contains(element.name) && !element.isExtraField) - .toList(); - - ConstructorElement get _ctor { - final ConstructorElement? ctor = routeDataClass.unnamedConstructor; - - if (ctor == null) { - throw InvalidGenerationSourceError( - 'Missing default constructor', - element: routeDataClass, - ); - } - return ctor; - } - - @override - Iterable classDeclarations() => [ - _extensionDefinition, - ..._enumDeclarations(), - ]; - - String get _extensionDefinition => ''' -extension $_extensionName on $_className { - static $_className _fromState(GoRouterState state) $_fromStateConstructor - - String get location => GoRouteData.\$location($_locationArgs,$_locationQueryParams); - - void goRelative(BuildContext context) => - context.goRelative(location${_extraParam != null ? ', extra: $extraFieldName' : ''}); -} -'''; - - /// Returns code representing the constant maps that contain the `enum` to - /// [String] mapping for each referenced enum. - Iterable _enumDeclarations() { - final Set enumParamTypes = {}; - - for (final ParameterElement ctorParam in [ - ..._ctorParams, - ..._ctorQueryParams, - ]) { - DartType potentialEnumType = ctorParam.type; - if (potentialEnumType is ParameterizedType && - (ctorParam.type as ParameterizedType).typeArguments.isNotEmpty) { - potentialEnumType = - (ctorParam.type as ParameterizedType).typeArguments.first; - } - - if (potentialEnumType.isEnum) { - enumParamTypes.add(potentialEnumType as InterfaceType); - } - } - return enumParamTypes.map(_enumMapConst); - } - - @override - String get factorConstructorParameters => - 'factory: $_extensionName._fromState,'; - - @override - String get routeConstructorParameters => ''' - path: ${escapeDartString(path)}, - ${name != null ? 'name: ${escapeDartString(name!)},' : ''} - ${parentNavigatorKey == null ? '' : 'parentNavigatorKey: $parentNavigatorKey,'} -'''; - - @override - String get routeDataClassName => 'GoRouteData'; - - @override - String get dataConvertionFunctionName => r'$route'; -} - /// Represents a `TypedGoRoute` annotation to the builder. abstract class RouteBaseConfig { RouteBaseConfig._({ @@ -770,25 +550,6 @@ abstract class RouteBaseConfig { parameterName: r'$parentNavigatorKey', ), ); - case 'TypedRelativeGoRoute': - final ConstantReader pathValue = reader.read('path'); - if (pathValue.isNull) { - throw InvalidGenerationSourceError( - 'Missing `path` value on annotation.', - element: element, - ); - } - final ConstantReader nameValue = reader.read('name'); - value = GoRelativeRouteConfig._( - path: pathValue.stringValue, - name: nameValue.isNull ? null : nameValue.stringValue, - routeDataClass: classElement, - parent: parent, - parentNavigatorKey: _generateParameterGetterCode( - classElement, - parameterName: r'$parentNavigatorKey', - ), - ); default: throw UnsupportedError('Unrecognized type $typeName'); } diff --git a/packages/go_router_builder/pubspec.yaml b/packages/go_router_builder/pubspec.yaml index 6fba2f8dc9f..0e6e10b6b3d 100644 --- a/packages/go_router_builder/pubspec.yaml +++ b/packages/go_router_builder/pubspec.yaml @@ -2,7 +2,7 @@ name: go_router_builder description: >- A builder that supports generated strongly-typed route helpers for package:go_router -version: 2.7.1 +version: 2.7.0 repository: https://github.com/flutter/packages/tree/main/packages/go_router_builder issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+go_router_builder%22 From 833f83801eef3b597473bcd3806e76217a1a5f90 Mon Sep 17 00:00:00 2001 From: Thang Date: Wed, 29 May 2024 13:51:50 +0700 Subject: [PATCH 07/14] fix changelog title --- packages/go_router/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/go_router/CHANGELOG.md b/packages/go_router/CHANGELOG.md index 35d839ee813..26a426a5687 100644 --- a/packages/go_router/CHANGELOG.md +++ b/packages/go_router/CHANGELOG.md @@ -1,4 +1,4 @@ -## 14.1.3 +## 14.1.4 - Adds `GoRouter.goRelative` - Adds `TypedRelativeGoRoute` From ad6b246b74a6ea928a98be444f83cf701d594342 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 28 May 2024 17:17:25 +0000 Subject: [PATCH 08/14] [webview]: Bump androidx.webkit:webkit from 1.10.0 to 1.11.0 in /packages/webview_flutter/webview_flutter_android/android (#6805) Bumps androidx.webkit:webkit from 1.10.0 to 1.11.0. [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=androidx.webkit:webkit&package-manager=gradle&previous-version=1.10.0&new-version=1.11.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- packages/webview_flutter/webview_flutter_android/CHANGELOG.md | 4 ++++ .../webview_flutter_android/android/build.gradle | 2 +- packages/webview_flutter/webview_flutter_android/pubspec.yaml | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/webview_flutter/webview_flutter_android/CHANGELOG.md b/packages/webview_flutter/webview_flutter_android/CHANGELOG.md index 777741058e1..039efbcf0c9 100644 --- a/packages/webview_flutter/webview_flutter_android/CHANGELOG.md +++ b/packages/webview_flutter/webview_flutter_android/CHANGELOG.md @@ -1,3 +1,7 @@ +## 3.16.3 + +* Bumps androidx.webkit:webkit from 1.10.0 to 1.11.0. + ## 3.16.2 * Bumps androidx.webkit:webkit from 1.7.0 to 1.10.0. diff --git a/packages/webview_flutter/webview_flutter_android/android/build.gradle b/packages/webview_flutter/webview_flutter_android/android/build.gradle index 7aec14fed37..9592d2dec0d 100644 --- a/packages/webview_flutter/webview_flutter_android/android/build.gradle +++ b/packages/webview_flutter/webview_flutter_android/android/build.gradle @@ -41,7 +41,7 @@ android { dependencies { implementation 'androidx.annotation:annotation:1.7.1' - implementation 'androidx.webkit:webkit:1.10.0' + implementation 'androidx.webkit:webkit:1.11.0' testImplementation 'junit:junit:4.13.2' testImplementation 'org.mockito:mockito-inline:5.1.0' testImplementation 'androidx.test:core:1.3.0' diff --git a/packages/webview_flutter/webview_flutter_android/pubspec.yaml b/packages/webview_flutter/webview_flutter_android/pubspec.yaml index a1b11276dc5..b950d8ec5f9 100644 --- a/packages/webview_flutter/webview_flutter_android/pubspec.yaml +++ b/packages/webview_flutter/webview_flutter_android/pubspec.yaml @@ -2,7 +2,7 @@ name: webview_flutter_android description: A Flutter plugin that provides a WebView widget on Android. repository: https://github.com/flutter/packages/tree/main/packages/webview_flutter/webview_flutter_android issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+webview%22 -version: 3.16.2 +version: 3.16.3 environment: sdk: ^3.2.0 From 327bae234ff4a100f21ae5351cc8cf4c75790340 Mon Sep 17 00:00:00 2001 From: Altynbek Aidarbekov <48729942+altynbek132@users.noreply.github.com> Date: Tue, 28 May 2024 22:29:34 +0500 Subject: [PATCH 09/14] [go_router] docs: updated link in navigation.md to correct file path for push_with_shell_route.dart (#6670) [go_router] docs: updated link in navigation.md to correct file path for push_with_shell_route.dart --- packages/go_router/CHANGELOG.md | 6 +++++- packages/go_router/doc/navigation.md | 3 +-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/go_router/CHANGELOG.md b/packages/go_router/CHANGELOG.md index 26a426a5687..5e2bac6cee0 100644 --- a/packages/go_router/CHANGELOG.md +++ b/packages/go_router/CHANGELOG.md @@ -1,8 +1,12 @@ -## 14.1.4 +## 14.1.5 - Adds `GoRouter.goRelative` - Adds `TypedRelativeGoRoute` +## 14.1.4 + +- Fixes a URL in `navigation.md`. + ## 14.1.3 - Improves the logging of routes when `debugLogDiagnostics` is enabled or `debugKnownRoutes() is called. Explains the position of shell routes in the route tree. Prints the widget name of the routes it is building. diff --git a/packages/go_router/doc/navigation.md b/packages/go_router/doc/navigation.md index 74bc86631ca..af7d1b3bb1a 100644 --- a/packages/go_router/doc/navigation.md +++ b/packages/go_router/doc/navigation.md @@ -86,8 +86,7 @@ screen along with the shell is placed entirely on top of the current screen. ![An animation shows pushing a new screen with the different shell as current screen](https://flutter.github.io/assets-for-api-docs/assets/go_router/push_different_shell.gif) To try out the behavior yourself, see -[push_with_shell_route.dart](https://github.com/flutter/packages/blob/main/packages/go_router/example/lib/extra_codec.dart). - +[push_with_shell_route.dart](https://github.com/flutter/packages/blob/main/packages/go_router/example/lib/push_with_shell_route.dart). ## Returning values Waiting for a value to be returned: From af3a3d154f3b66bdb4b3184bebfef1bdc2af796e Mon Sep 17 00:00:00 2001 From: Gray Mackall <34871572+gmackall@users.noreply.github.com> Date: Tue, 28 May 2024 11:25:51 -0700 Subject: [PATCH 10/14] [many] Remove references to v1 embedding (#6494) I have a WIP effort to remove the v1 embedding entirely (https://github.com/flutter/flutter/pull/146523 is the latest pr). `registerWith` references the v1 embedding, which has been deprecated for many years, so this PR removes it from all plugins. Also removes some additional references, see in particular these three commits: 1. Modifies private `ActivityState` class to remove `PluginRegistry.Registrar` member in `image_picker`: https://github.com/flutter/packages/pull/6494/commits/c2e4c872917a32c61d77a72b3f2e8fe25c3d6599 2. Replaces `FlutterMain.getLookupKeyForAsset()` with `FlutterLoader.getLookupKeyForAsset()` in `google_maps` plugin: https://github.com/flutter/packages/pull/6494/commits/73c3de3807dc20333536affb86c87b82ac267bf9 3. Removes deprecated `RegistrarFlutterAssetManager` class in `webview_flutter`: https://github.com/flutter/packages/pull/6494/commits/cc842c69b2ed2a5e5c203d7c9514605823225b07 Fixes https://github.com/flutter/flutter/issues/70923 --- packages/camera/camera_android/CHANGELOG.md | 5 +- .../flutter/plugins/camera/CameraPlugin.java | 21 ------- .../camera_android/example/pubspec.yaml | 4 +- packages/camera/camera_android/pubspec.yaml | 6 +- packages/espresso/CHANGELOG.md | 5 +- .../com/example/espresso/EspressoPlugin.java | 15 ----- packages/espresso/example/pubspec.yaml | 4 +- packages/espresso/pubspec.yaml | 6 +- .../CHANGELOG.md | 5 +- .../FlutterAndroidLifecyclePlugin.java | 5 -- .../example/pubspec.yaml | 4 +- .../pubspec.yaml | 6 +- .../google_maps_flutter_android/CHANGELOG.md | 5 +- .../flutter/plugins/googlemaps/Convert.java | 17 +++--- .../plugins/googlemaps/GoogleMapsPlugin.java | 35 ------------ .../example/pubspec.yaml | 4 +- .../google_maps_flutter_android/pubspec.yaml | 6 +- .../google_sign_in_android/CHANGELOG.md | 5 +- .../googlesignin/GoogleSignInPlugin.java | 8 --- .../example/pubspec.yaml | 4 +- .../google_sign_in_android/pubspec.yaml | 6 +- .../image_picker_android/CHANGELOG.md | 5 ++ .../imagepicker/ImagePickerPlugin.java | 39 +++---------- .../imagepicker/ImagePickerPluginTest.java | 8 --- .../image_picker_android/example/pubspec.yaml | 4 +- .../image_picker_android/pubspec.yaml | 6 +- .../in_app_purchase_android/CHANGELOG.md | 5 ++ .../inapppurchase/InAppPurchasePlugin.java | 11 ---- .../InAppPurchasePluginTest.java | 21 ------- .../example/pubspec.yaml | 4 +- .../in_app_purchase_android/pubspec.yaml | 6 +- .../local_auth_android/CHANGELOG.md | 5 ++ .../plugins/localauth/LocalAuthPlugin.java | 16 ------ .../local_auth_android/example/pubspec.yaml | 4 +- .../local_auth_android/pubspec.yaml | 6 +- .../path_provider_android/CHANGELOG.md | 5 +- .../pathprovider/PathProviderPlugin.java | 7 --- .../example/pubspec.yaml | 4 +- .../path_provider_android/pubspec.yaml | 6 +- .../quick_actions_android/CHANGELOG.md | 5 +- .../quickactions/QuickActionsPlugin.java | 13 ----- .../example/pubspec.yaml | 4 +- .../quick_actions_android/pubspec.yaml | 6 +- .../shared_preferences_android/CHANGELOG.md | 5 +- .../SharedPreferencesPlugin.java | 7 --- .../example/pubspec.yaml | 4 +- .../shared_preferences_android/pubspec.yaml | 6 +- .../url_launcher_android/CHANGELOG.md | 5 ++ .../urllauncher/UrlLauncherPlugin.java | 15 ----- .../url_launcher_android/example/pubspec.yaml | 4 +- .../url_launcher_android/pubspec.yaml | 6 +- .../video_player_android/CHANGELOG.md | 5 +- .../videoplayer/VideoPlayerPlugin.java | 12 ---- .../video_player_android/example/pubspec.yaml | 4 +- .../video_player_android/pubspec.yaml | 6 +- .../webview_flutter_android/CHANGELOG.md | 5 ++ .../webviewflutter/FlutterAssetManager.java | 32 ----------- .../webviewflutter/WebViewFlutterPlugin.java | 26 --------- .../RegistrarFlutterAssetManagerTest.java | 55 ------------------- .../example/pubspec.yaml | 4 +- .../webview_flutter_android/pubspec.yaml | 8 +-- 61 files changed, 140 insertions(+), 435 deletions(-) delete mode 100644 packages/webview_flutter/webview_flutter_android/android/src/test/java/io/flutter/plugins/webviewflutter/RegistrarFlutterAssetManagerTest.java diff --git a/packages/camera/camera_android/CHANGELOG.md b/packages/camera/camera_android/CHANGELOG.md index 74d8e31b8a4..dbf3789b43a 100644 --- a/packages/camera/camera_android/CHANGELOG.md +++ b/packages/camera/camera_android/CHANGELOG.md @@ -1,6 +1,7 @@ -## NEXT +## 0.10.9+3 -* Updates minimum supported SDK version to Flutter 3.16/Dart 3.2. +* Updates minimum supported SDK version to Flutter 3.22/Dart 3.4. +* Removes support for apps using the v1 Android embedding. ## 0.10.9+2 diff --git a/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/CameraPlugin.java b/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/CameraPlugin.java index 308d4283aa2..aff225e2c35 100644 --- a/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/CameraPlugin.java +++ b/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/CameraPlugin.java @@ -19,9 +19,6 @@ * *

Instantiate this in an add to app scenario to gracefully handle activity and context changes. * See {@code io.flutter.plugins.camera.MainActivity} for an example. - * - *

Call {@link #registerWith(io.flutter.plugin.common.PluginRegistry.Registrar)} to register an - * implementation of this that uses the stable {@code io.flutter.plugin.common} package. */ public final class CameraPlugin implements FlutterPlugin, ActivityAware { @@ -36,24 +33,6 @@ public final class CameraPlugin implements FlutterPlugin, ActivityAware { */ public CameraPlugin() {} - /** - * Registers a plugin implementation that uses the stable {@code io.flutter.plugin.common} - * package. - * - *

Calling this automatically initializes the plugin. However plugins initialized this way - * won't react to changes in activity or context, unlike {@link CameraPlugin}. - */ - @SuppressWarnings("deprecation") - public static void registerWith( - @NonNull io.flutter.plugin.common.PluginRegistry.Registrar registrar) { - CameraPlugin plugin = new CameraPlugin(); - plugin.maybeStartListening( - registrar.activity(), - registrar.messenger(), - registrar::addRequestPermissionsResultListener, - registrar.view()); - } - @Override public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) { this.flutterPluginBinding = binding; diff --git a/packages/camera/camera_android/example/pubspec.yaml b/packages/camera/camera_android/example/pubspec.yaml index ee97a09e511..cd212825d74 100644 --- a/packages/camera/camera_android/example/pubspec.yaml +++ b/packages/camera/camera_android/example/pubspec.yaml @@ -3,8 +3,8 @@ description: Demonstrates how to use the camera plugin. publish_to: none environment: - sdk: ^3.2.0 - flutter: ">=3.16.0" + sdk: ^3.4.0 + flutter: ">=3.22.0" dependencies: camera_android: diff --git a/packages/camera/camera_android/pubspec.yaml b/packages/camera/camera_android/pubspec.yaml index 90d32f51d9c..704f64b4f71 100644 --- a/packages/camera/camera_android/pubspec.yaml +++ b/packages/camera/camera_android/pubspec.yaml @@ -3,11 +3,11 @@ description: Android implementation of the camera plugin. repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_android issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22 -version: 0.10.9+2 +version: 0.10.9+3 environment: - sdk: ^3.2.0 - flutter: ">=3.16.0" + sdk: ^3.4.0 + flutter: ">=3.22.0" flutter: plugin: diff --git a/packages/espresso/CHANGELOG.md b/packages/espresso/CHANGELOG.md index 2a86fa94cbf..429f93ae3e9 100644 --- a/packages/espresso/CHANGELOG.md +++ b/packages/espresso/CHANGELOG.md @@ -1,6 +1,7 @@ -## NEXT +## 0.3.0+9 -* Updates minimum supported SDK version to Flutter 3.16/Dart 3.2. +* Updates minimum supported SDK version to Flutter 3.22/Dart 3.4. +* Removes support for apps using the v1 Android embedding. ## 0.3.0+8 diff --git a/packages/espresso/android/src/main/java/com/example/espresso/EspressoPlugin.java b/packages/espresso/android/src/main/java/com/example/espresso/EspressoPlugin.java index 6c8620b3ca1..213e83c22f7 100644 --- a/packages/espresso/android/src/main/java/com/example/espresso/EspressoPlugin.java +++ b/packages/espresso/android/src/main/java/com/example/espresso/EspressoPlugin.java @@ -20,21 +20,6 @@ public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBindin channel.setMethodCallHandler(new EspressoPlugin()); } - // This static function is optional and equivalent to onAttachedToEngine. It supports the old - // pre-Flutter-1.12 Android projects. You are encouraged to continue supporting - // plugin registration via this function while apps migrate to use the new Android APIs - // post-flutter-1.12 via https://flutter.dev/go/android-project-migration. - // - // It is encouraged to share logic between onAttachedToEngine and registerWith to keep - // them functionally equivalent. Only one of onAttachedToEngine or registerWith will be called - // depending on the user's project. onAttachedToEngine or registerWith must both be defined - // in the same class. - @SuppressWarnings("deprecation") - public static void registerWith(io.flutter.plugin.common.PluginRegistry.Registrar registrar) { - final MethodChannel channel = new MethodChannel(registrar.messenger(), "espresso"); - channel.setMethodCallHandler(new EspressoPlugin()); - } - @Override public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) { if (call.method.equals("getPlatformVersion")) { diff --git a/packages/espresso/example/pubspec.yaml b/packages/espresso/example/pubspec.yaml index 8fe0b9271b9..1cafae5d3e1 100644 --- a/packages/espresso/example/pubspec.yaml +++ b/packages/espresso/example/pubspec.yaml @@ -3,8 +3,8 @@ description: Demonstrates how to use the espresso plugin. publish_to: none environment: - sdk: ^3.2.0 - flutter: ">=3.16.0" + sdk: ^3.4.0 + flutter: ">=3.22.0" dependencies: flutter: diff --git a/packages/espresso/pubspec.yaml b/packages/espresso/pubspec.yaml index b8fc32e5459..e4c12398c39 100644 --- a/packages/espresso/pubspec.yaml +++ b/packages/espresso/pubspec.yaml @@ -3,11 +3,11 @@ description: Java classes for testing Flutter apps using Espresso. Allows driving Flutter widgets from a native Espresso test. repository: https://github.com/flutter/packages/tree/main/packages/espresso issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+espresso%22 -version: 0.3.0+8 +version: 0.3.0+9 environment: - sdk: ^3.2.0 - flutter: ">=3.16.0" + sdk: ^3.4.0 + flutter: ">=3.22.0" flutter: plugin: diff --git a/packages/flutter_plugin_android_lifecycle/CHANGELOG.md b/packages/flutter_plugin_android_lifecycle/CHANGELOG.md index 60b37e2776c..b7082c02255 100644 --- a/packages/flutter_plugin_android_lifecycle/CHANGELOG.md +++ b/packages/flutter_plugin_android_lifecycle/CHANGELOG.md @@ -1,6 +1,7 @@ -## NEXT +## 2.0.20 -* Updates minimum supported SDK version to Flutter 3.16/Dart 3.2. +* Updates minimum supported SDK version to Flutter 3.22/Dart 3.4. +* Removes support for apps using the v1 Android embedding. ## 2.0.19 diff --git a/packages/flutter_plugin_android_lifecycle/android/src/main/java/io/flutter/plugins/flutter_plugin_android_lifecycle/FlutterAndroidLifecyclePlugin.java b/packages/flutter_plugin_android_lifecycle/android/src/main/java/io/flutter/plugins/flutter_plugin_android_lifecycle/FlutterAndroidLifecyclePlugin.java index 800f3b594d6..cf6972da15b 100644 --- a/packages/flutter_plugin_android_lifecycle/android/src/main/java/io/flutter/plugins/flutter_plugin_android_lifecycle/FlutterAndroidLifecyclePlugin.java +++ b/packages/flutter_plugin_android_lifecycle/android/src/main/java/io/flutter/plugins/flutter_plugin_android_lifecycle/FlutterAndroidLifecyclePlugin.java @@ -14,11 +14,6 @@ *

DO NOT USE THIS CLASS. */ public class FlutterAndroidLifecyclePlugin implements FlutterPlugin { - @SuppressWarnings("deprecation") - public static void registerWith( - @NonNull io.flutter.plugin.common.PluginRegistry.Registrar registrar) { - // no-op - } @Override public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) { diff --git a/packages/flutter_plugin_android_lifecycle/example/pubspec.yaml b/packages/flutter_plugin_android_lifecycle/example/pubspec.yaml index ab7d57eb2cf..98ca0aebd4d 100644 --- a/packages/flutter_plugin_android_lifecycle/example/pubspec.yaml +++ b/packages/flutter_plugin_android_lifecycle/example/pubspec.yaml @@ -3,8 +3,8 @@ description: Demonstrates how to use the flutter_plugin_android_lifecycle plugin publish_to: none environment: - sdk: ^3.2.0 - flutter: ">=3.16.0" + sdk: ^3.4.0 + flutter: ">=3.22.0" dependencies: flutter: diff --git a/packages/flutter_plugin_android_lifecycle/pubspec.yaml b/packages/flutter_plugin_android_lifecycle/pubspec.yaml index 7d70e4aa84d..30e358ac15b 100644 --- a/packages/flutter_plugin_android_lifecycle/pubspec.yaml +++ b/packages/flutter_plugin_android_lifecycle/pubspec.yaml @@ -2,11 +2,11 @@ name: flutter_plugin_android_lifecycle description: Flutter plugin for accessing an Android Lifecycle within other plugins. repository: https://github.com/flutter/packages/tree/main/packages/flutter_plugin_android_lifecycle issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+flutter_plugin_android_lifecycle%22 -version: 2.0.19 +version: 2.0.20 environment: - sdk: ^3.2.0 - flutter: ">=3.16.0" + sdk: ^3.4.0 + flutter: ">=3.22.0" flutter: plugin: diff --git a/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md index b68da08cafe..4c003ec9eaa 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md @@ -1,6 +1,7 @@ -## NEXT +## 2.8.1 -* Updates minimum supported SDK version to Flutter 3.16/Dart 3.2. +* Updates minimum supported SDK version to Flutter 3.22/Dart 3.4. +* Removes support for apps using the v1 Android embedding. ## 2.8.0 diff --git a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java index 28449b81f3e..ccf474ab1e2 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java +++ b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java @@ -26,6 +26,7 @@ import com.google.android.gms.maps.model.SquareCap; import com.google.android.gms.maps.model.Tile; import com.google.maps.android.clustering.Cluster; +import io.flutter.FlutterInjector; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -36,9 +37,6 @@ /** Conversions between JSON-like values and GoogleMaps data types. */ class Convert { - // TODO(hamdikahloun): FlutterMain has been deprecated and should be replaced with FlutterLoader - // when it's available in Stable channel: https://github.com/flutter/flutter/issues/70923. - @SuppressWarnings("deprecation") private static BitmapDescriptor toBitmapDescriptor(Object o) { final List data = toList(o); switch (toString(data.get(0))) { @@ -51,16 +49,21 @@ private static BitmapDescriptor toBitmapDescriptor(Object o) { case "fromAsset": if (data.size() == 2) { return BitmapDescriptorFactory.fromAsset( - io.flutter.view.FlutterMain.getLookupKeyForAsset(toString(data.get(1)))); + FlutterInjector.instance() + .flutterLoader() + .getLookupKeyForAsset(toString(data.get(1)))); } else { return BitmapDescriptorFactory.fromAsset( - io.flutter.view.FlutterMain.getLookupKeyForAsset( - toString(data.get(1)), toString(data.get(2)))); + FlutterInjector.instance() + .flutterLoader() + .getLookupKeyForAsset(toString(data.get(1)), toString(data.get(2)))); } case "fromAssetImage": if (data.size() == 3) { return BitmapDescriptorFactory.fromAsset( - io.flutter.view.FlutterMain.getLookupKeyForAsset(toString(data.get(1)))); + FlutterInjector.instance() + .flutterLoader() + .getLookupKeyForAsset(toString(data.get(1)))); } else { throw new IllegalArgumentException( "'fromAssetImage' Expected exactly 3 arguments, got: " + data.size()); diff --git a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapsPlugin.java b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapsPlugin.java index 5d0a5ebdda8..36b20cfe909 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapsPlugin.java +++ b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapsPlugin.java @@ -30,41 +30,6 @@ public class GoogleMapsPlugin implements FlutterPlugin, ActivityAware { private static final String VIEW_TYPE = "plugins.flutter.dev/google_maps_android"; - @SuppressWarnings("deprecation") - public static void registerWith( - @NonNull final io.flutter.plugin.common.PluginRegistry.Registrar registrar) { - final Activity activity = registrar.activity(); - if (activity == null) { - // When a background flutter view tries to register the plugin, the registrar has no activity. - // We stop the registration process as this plugin is foreground only. - return; - } - if (activity instanceof LifecycleOwner) { - registrar - .platformViewRegistry() - .registerViewFactory( - VIEW_TYPE, - new GoogleMapFactory( - registrar.messenger(), - registrar.context(), - new LifecycleProvider() { - @Override - public Lifecycle getLifecycle() { - return ((LifecycleOwner) activity).getLifecycle(); - } - })); - } else { - registrar - .platformViewRegistry() - .registerViewFactory( - VIEW_TYPE, - new GoogleMapFactory( - registrar.messenger(), - registrar.context(), - new ProxyLifecycleProvider(activity))); - } - } - public GoogleMapsPlugin() {} // FlutterPlugin diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_android/example/pubspec.yaml index 3b71087215d..62c94d4d2fc 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/pubspec.yaml @@ -3,8 +3,8 @@ description: Demonstrates how to use the google_maps_flutter plugin. publish_to: none environment: - sdk: ^3.2.0 - flutter: ">=3.16.0" + sdk: ^3.4.0 + flutter: ">=3.22.0" dependencies: cupertino_icons: ^1.0.5 diff --git a/packages/google_maps_flutter/google_maps_flutter_android/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_android/pubspec.yaml index 629e61f3879..73625d79421 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_android/pubspec.yaml @@ -2,11 +2,11 @@ name: google_maps_flutter_android description: Android implementation of the google_maps_flutter plugin. repository: https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter_android issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22 -version: 2.8.0 +version: 2.8.1 environment: - sdk: ^3.2.0 - flutter: ">=3.16.0" + sdk: ^3.4.0 + flutter: ">=3.22.0" flutter: plugin: diff --git a/packages/google_sign_in/google_sign_in_android/CHANGELOG.md b/packages/google_sign_in/google_sign_in_android/CHANGELOG.md index a19bbebc04f..68ed7d6b90c 100644 --- a/packages/google_sign_in/google_sign_in_android/CHANGELOG.md +++ b/packages/google_sign_in/google_sign_in_android/CHANGELOG.md @@ -1,6 +1,7 @@ -## NEXT +## 6.1.24 -* Updates minimum supported SDK version to Flutter 3.16/Dart 3.2. +* Updates minimum supported SDK version to Flutter 3.22/Dart 3.4. +* Removes support for apps using the v1 Android embedding. ## 6.1.23 diff --git a/packages/google_sign_in/google_sign_in_android/android/src/main/java/io/flutter/plugins/googlesignin/GoogleSignInPlugin.java b/packages/google_sign_in/google_sign_in_android/android/src/main/java/io/flutter/plugins/googlesignin/GoogleSignInPlugin.java index eb4635a8179..9efe45f6535 100644 --- a/packages/google_sign_in/google_sign_in_android/android/src/main/java/io/flutter/plugins/googlesignin/GoogleSignInPlugin.java +++ b/packages/google_sign_in/google_sign_in_android/android/src/main/java/io/flutter/plugins/googlesignin/GoogleSignInPlugin.java @@ -49,14 +49,6 @@ public class GoogleSignInPlugin implements FlutterPlugin, ActivityAware { private @Nullable BinaryMessenger messenger; private ActivityPluginBinding activityPluginBinding; - @SuppressWarnings("deprecation") - public static void registerWith( - @NonNull io.flutter.plugin.common.PluginRegistry.Registrar registrar) { - GoogleSignInPlugin instance = new GoogleSignInPlugin(); - instance.initInstance(registrar.messenger(), registrar.context(), new GoogleSignInWrapper()); - instance.setUpRegistrar(registrar); - } - @VisibleForTesting public void initInstance( @NonNull BinaryMessenger messenger, diff --git a/packages/google_sign_in/google_sign_in_android/example/pubspec.yaml b/packages/google_sign_in/google_sign_in_android/example/pubspec.yaml index b39b56343c4..11b6f074272 100644 --- a/packages/google_sign_in/google_sign_in_android/example/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in_android/example/pubspec.yaml @@ -3,8 +3,8 @@ description: Example of Google Sign-In plugin. publish_to: none environment: - sdk: ^3.2.0 - flutter: ">=3.16.0" + sdk: ^3.4.0 + flutter: ">=3.22.0" dependencies: flutter: diff --git a/packages/google_sign_in/google_sign_in_android/pubspec.yaml b/packages/google_sign_in/google_sign_in_android/pubspec.yaml index 61f9204f0cd..faf2641122b 100644 --- a/packages/google_sign_in/google_sign_in_android/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in_android/pubspec.yaml @@ -2,11 +2,11 @@ name: google_sign_in_android description: Android implementation of the google_sign_in plugin. repository: https://github.com/flutter/packages/tree/main/packages/google_sign_in/google_sign_in_android issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_sign_in%22 -version: 6.1.23 +version: 6.1.24 environment: - sdk: ^3.2.0 - flutter: ">=3.16.0" + sdk: ^3.4.0 + flutter: ">=3.22.0" flutter: plugin: diff --git a/packages/image_picker/image_picker_android/CHANGELOG.md b/packages/image_picker/image_picker_android/CHANGELOG.md index 99781bd917b..0d91ddddcdd 100644 --- a/packages/image_picker/image_picker_android/CHANGELOG.md +++ b/packages/image_picker/image_picker_android/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.8.12+2 + +* Updates minimum supported SDK version to Flutter 3.22/Dart 3.4. +* Removes support for apps using the v1 Android embedding. + ## 0.8.12+1 * Fixes another app crash case on Android 12+, and refactors getting of paths from intents. diff --git a/packages/image_picker/image_picker_android/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java b/packages/image_picker/image_picker_android/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java index 8096930e7d7..264921db4f4 100644 --- a/packages/image_picker/image_picker_android/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java +++ b/packages/image_picker/image_picker_android/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java @@ -18,7 +18,6 @@ import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding; import io.flutter.embedding.engine.plugins.lifecycle.FlutterLifecycleAdapter; import io.flutter.plugin.common.BinaryMessenger; -import io.flutter.plugin.common.PluginRegistry; import io.flutter.plugins.imagepicker.Messages.CacheRetrievalResult; import io.flutter.plugins.imagepicker.Messages.FlutterError; import io.flutter.plugins.imagepicker.Messages.GeneralOptions; @@ -117,7 +116,6 @@ private class ActivityState { final Activity activity, final BinaryMessenger messenger, final ImagePickerApi handler, - final PluginRegistry.Registrar registrar, final ActivityPluginBinding activityBinding) { this.application = application; this.activity = activity; @@ -127,18 +125,12 @@ private class ActivityState { delegate = constructDelegate(activity); ImagePickerApi.setUp(messenger, handler); observer = new LifeCycleObserver(activity); - if (registrar != null) { - // V1 embedding setup for activity listeners. - application.registerActivityLifecycleCallbacks(observer); - registrar.addActivityResultListener(delegate); - registrar.addRequestPermissionsResultListener(delegate); - } else { - // V2 embedding setup for activity listeners. - activityBinding.addActivityResultListener(delegate); - activityBinding.addRequestPermissionsResultListener(delegate); - lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(activityBinding); - lifecycle.addObserver(observer); - } + + // V2 embedding setup for activity listeners. + activityBinding.addActivityResultListener(delegate); + activityBinding.addRequestPermissionsResultListener(delegate); + lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(activityBinding); + lifecycle.addObserver(observer); } // Only invoked by {@link #ImagePickerPlugin(ImagePickerDelegate, Activity)} for testing. @@ -183,20 +175,6 @@ ImagePickerDelegate getDelegate() { private FlutterPluginBinding pluginBinding; ActivityState activityState; - @SuppressWarnings("deprecation") - public static void registerWith( - @NonNull io.flutter.plugin.common.PluginRegistry.Registrar registrar) { - if (registrar.activity() == null) { - // If a background flutter view tries to register the plugin, there will be no activity from the registrar, - // we stop the registering process immediately because the ImagePicker requires an activity. - return; - } - Activity activity = registrar.activity(); - Application application = (Application) (registrar.context().getApplicationContext()); - ImagePickerPlugin plugin = new ImagePickerPlugin(); - plugin.setup(registrar.messenger(), application, activity, registrar, null); - } - /** * Default constructor for the plugin. * @@ -231,7 +209,6 @@ public void onAttachedToActivity(@NonNull ActivityPluginBinding binding) { pluginBinding.getBinaryMessenger(), (Application) pluginBinding.getApplicationContext(), binding.getActivity(), - null, binding); } @@ -254,10 +231,8 @@ private void setup( final BinaryMessenger messenger, final Application application, final Activity activity, - final PluginRegistry.Registrar registrar, final ActivityPluginBinding activityBinding) { - activityState = - new ActivityState(application, activity, messenger, this, registrar, activityBinding); + activityState = new ActivityState(application, activity, messenger, this, activityBinding); } private void tearDown() { diff --git a/packages/image_picker/image_picker_android/android/src/test/java/io/flutter/plugins/imagepicker/ImagePickerPluginTest.java b/packages/image_picker/image_picker_android/android/src/test/java/io/flutter/plugins/imagepicker/ImagePickerPluginTest.java index cf088b59b19..e759c21e35d 100644 --- a/packages/image_picker/image_picker_android/android/src/test/java/io/flutter/plugins/imagepicker/ImagePickerPluginTest.java +++ b/packages/image_picker/image_picker_android/android/src/test/java/io/flutter/plugins/imagepicker/ImagePickerPluginTest.java @@ -304,14 +304,6 @@ public void pickVideos_whenSourceIsCamera_invokesTakeImageWithCamera_FrontCamera verify(mockImagePickerDelegate).setCameraDevice(eq(ImagePickerDelegate.CameraDevice.FRONT)); } - @Test - public void onRegister_whenActivityIsNull_shouldNotCrash() { - when(mockRegistrar.activity()).thenReturn(null); - ImagePickerPlugin.registerWith((mockRegistrar)); - assertTrue( - "No exception thrown when ImagePickerPlugin.registerWith ran with activity = null", true); - } - @Test public void onConstructor_whenContextTypeIsActivity_shouldNotCrash() { new ImagePickerPlugin(mockImagePickerDelegate, mockActivity); diff --git a/packages/image_picker/image_picker_android/example/pubspec.yaml b/packages/image_picker/image_picker_android/example/pubspec.yaml index 500b47c3578..0c7181f68ab 100644 --- a/packages/image_picker/image_picker_android/example/pubspec.yaml +++ b/packages/image_picker/image_picker_android/example/pubspec.yaml @@ -3,8 +3,8 @@ description: Demonstrates how to use the image_picker plugin. publish_to: none environment: - sdk: ^3.3.0 - flutter: ">=3.19.0" + sdk: ^3.4.0 + flutter: ">=3.22.0" dependencies: flutter: diff --git a/packages/image_picker/image_picker_android/pubspec.yaml b/packages/image_picker/image_picker_android/pubspec.yaml index 3e15b4366c2..4e4980c581c 100755 --- a/packages/image_picker/image_picker_android/pubspec.yaml +++ b/packages/image_picker/image_picker_android/pubspec.yaml @@ -2,11 +2,11 @@ name: image_picker_android description: Android implementation of the image_picker plugin. repository: https://github.com/flutter/packages/tree/main/packages/image_picker/image_picker_android issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+image_picker%22 -version: 0.8.12+1 +version: 0.8.12+2 environment: - sdk: ^3.3.0 - flutter: ">=3.19.0" + sdk: ^3.4.0 + flutter: ">=3.22.0" flutter: plugin: diff --git a/packages/in_app_purchase/in_app_purchase_android/CHANGELOG.md b/packages/in_app_purchase/in_app_purchase_android/CHANGELOG.md index 440c322c4a0..ea9332cbe96 100644 --- a/packages/in_app_purchase/in_app_purchase_android/CHANGELOG.md +++ b/packages/in_app_purchase/in_app_purchase_android/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.3.6+1 + +* Updates minimum supported SDK version to Flutter 3.22/Dart 3.4. +* Removes support for apps using the v1 Android embedding. + ## 0.3.6 * Introduces new `ReplacementMode` for Android's billing client as `ProrationMode` is being deprecated. diff --git a/packages/in_app_purchase/in_app_purchase_android/android/src/main/java/io/flutter/plugins/inapppurchase/InAppPurchasePlugin.java b/packages/in_app_purchase/in_app_purchase_android/android/src/main/java/io/flutter/plugins/inapppurchase/InAppPurchasePlugin.java index cc153dc4309..965ed43beff 100644 --- a/packages/in_app_purchase/in_app_purchase_android/android/src/main/java/io/flutter/plugins/inapppurchase/InAppPurchasePlugin.java +++ b/packages/in_app_purchase/in_app_purchase_android/android/src/main/java/io/flutter/plugins/inapppurchase/InAppPurchasePlugin.java @@ -4,7 +4,6 @@ package io.flutter.plugins.inapppurchase; -import android.app.Application; import android.content.Context; import androidx.annotation.NonNull; import androidx.annotation.VisibleForTesting; @@ -26,16 +25,6 @@ public class InAppPurchasePlugin implements FlutterPlugin, ActivityAware { private MethodCallHandlerImpl methodCallHandler; - /** Plugin registration. */ - @SuppressWarnings("deprecation") - public static void registerWith( - @NonNull io.flutter.plugin.common.PluginRegistry.Registrar registrar) { - InAppPurchasePlugin plugin = new InAppPurchasePlugin(); - registrar.activity().getIntent().putExtra(PROXY_PACKAGE_KEY, PROXY_VALUE); - ((Application) registrar.context().getApplicationContext()) - .registerActivityLifecycleCallbacks(plugin.methodCallHandler); - } - @Override public void onAttachedToEngine(@NonNull FlutterPlugin.FlutterPluginBinding binding) { setUpMethodChannel(binding.getBinaryMessenger(), binding.getApplicationContext()); diff --git a/packages/in_app_purchase/in_app_purchase_android/android/src/test/java/io/flutter/plugins/inapppurchase/InAppPurchasePluginTest.java b/packages/in_app_purchase/in_app_purchase_android/android/src/test/java/io/flutter/plugins/inapppurchase/InAppPurchasePluginTest.java index f7908c09b01..b2af5e12b5c 100644 --- a/packages/in_app_purchase/in_app_purchase_android/android/src/test/java/io/flutter/plugins/inapppurchase/InAppPurchasePluginTest.java +++ b/packages/in_app_purchase/in_app_purchase_android/android/src/test/java/io/flutter/plugins/inapppurchase/InAppPurchasePluginTest.java @@ -57,27 +57,6 @@ public void tearDown() throws Exception { mockCloseable.close(); } - @Test - public void registerWith_doNotCrashWhenRegisterContextIsActivity_V1Embedding() { - when(mockRegistrar.context()).thenReturn(activity); - when(activity.getApplicationContext()).thenReturn(mockApplication); - InAppPurchasePlugin.registerWith(mockRegistrar); - } - - // The PROXY_PACKAGE_KEY value of this test (io.flutter.plugins.inapppurchase) should never be changed. - // In case there's a strong reason to change it, please inform the current code owner of the plugin. - @Test - public void registerWith_proxyIsSet_V1Embedding() { - when(mockRegistrar.context()).thenReturn(activity); - when(activity.getApplicationContext()).thenReturn(mockApplication); - InAppPurchasePlugin.registerWith(mockRegistrar); - // The `PROXY_PACKAGE_KEY` value is hard coded in the plugin code as "io.flutter.plugins.inapppurchase". - // We cannot use `BuildConfig.LIBRARY_PACKAGE_NAME` directly in the plugin code because whether to read BuildConfig.APPLICATION_ID or LIBRARY_PACKAGE_NAME - // depends on the "APP's" Android Gradle plugin version. Newer versions of AGP use LIBRARY_PACKAGE_NAME, whereas older ones use BuildConfig.APPLICATION_ID. - Mockito.verify(mockIntent).putExtra(PROXY_PACKAGE_KEY, "io.flutter.plugins.inapppurchase"); - assertEquals("io.flutter.plugins.inapppurchase", BuildConfig.LIBRARY_PACKAGE_NAME); - } - // The PROXY_PACKAGE_KEY value of this test (io.flutter.plugins.inapppurchase) should never be changed. // In case there's a strong reason to change it, please inform the current code owner of the plugin. @Test diff --git a/packages/in_app_purchase/in_app_purchase_android/example/pubspec.yaml b/packages/in_app_purchase/in_app_purchase_android/example/pubspec.yaml index 2289cba9946..a22c81be11f 100644 --- a/packages/in_app_purchase/in_app_purchase_android/example/pubspec.yaml +++ b/packages/in_app_purchase/in_app_purchase_android/example/pubspec.yaml @@ -3,8 +3,8 @@ description: Demonstrates how to use the in_app_purchase_android plugin. publish_to: none environment: - sdk: ^3.2.0 - flutter: ">=3.16.0" + sdk: ^3.4.0 + flutter: ">=3.22.0" dependencies: flutter: diff --git a/packages/in_app_purchase/in_app_purchase_android/pubspec.yaml b/packages/in_app_purchase/in_app_purchase_android/pubspec.yaml index d12eeeb7baf..29961fcfe4c 100644 --- a/packages/in_app_purchase/in_app_purchase_android/pubspec.yaml +++ b/packages/in_app_purchase/in_app_purchase_android/pubspec.yaml @@ -2,11 +2,11 @@ name: in_app_purchase_android description: An implementation for the Android platform of the Flutter `in_app_purchase` plugin. This uses the Android BillingClient APIs. repository: https://github.com/flutter/packages/tree/main/packages/in_app_purchase/in_app_purchase_android issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+in_app_purchase%22 -version: 0.3.6 +version: 0.3.6+1 environment: - sdk: ^3.2.0 - flutter: ">=3.16.0" + sdk: ^3.4.0 + flutter: ">=3.22.0" flutter: plugin: diff --git a/packages/local_auth/local_auth_android/CHANGELOG.md b/packages/local_auth/local_auth_android/CHANGELOG.md index b6441c94e12..ce4871b665c 100644 --- a/packages/local_auth/local_auth_android/CHANGELOG.md +++ b/packages/local_auth/local_auth_android/CHANGELOG.md @@ -1,3 +1,8 @@ +## 1.0.39 + +* Updates minimum supported SDK version to Flutter 3.22/Dart 3.4. +* Removes support for apps using the v1 Android embedding. + ## 1.0.38 * Updates minSdkVersion to 19. diff --git a/packages/local_auth/local_auth_android/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java b/packages/local_auth/local_auth_android/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java index 7ed2c04a8f6..5d1fe195449 100644 --- a/packages/local_auth/local_auth_android/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java +++ b/packages/local_auth/local_auth_android/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java @@ -67,22 +67,6 @@ public boolean onActivityResult(int requestCode, int resultCode, Intent data) { } }; - /** - * Registers a plugin with the v1 embedding api {@code io.flutter.plugin.common}. - * - *

Calling this will register the plugin with the passed registrar. However, plugins - * initialized this way won't react to changes in activity or context. - * - * @param registrar provides access to necessary plugin context. - */ - @SuppressWarnings("deprecation") - public static void registerWith(@NonNull PluginRegistry.Registrar registrar) { - final LocalAuthPlugin plugin = new LocalAuthPlugin(); - plugin.activity = registrar.activity(); - LocalAuthApi.setup(registrar.messenger(), plugin); - registrar.addActivityResultListener(plugin.resultListener); - } - /** * Default constructor for LocalAuthPlugin. * diff --git a/packages/local_auth/local_auth_android/example/pubspec.yaml b/packages/local_auth/local_auth_android/example/pubspec.yaml index 125ca89a2e8..36b392ed098 100644 --- a/packages/local_auth/local_auth_android/example/pubspec.yaml +++ b/packages/local_auth/local_auth_android/example/pubspec.yaml @@ -3,8 +3,8 @@ description: Demonstrates how to use the local_auth_android plugin. publish_to: none environment: - sdk: ^3.2.0 - flutter: ">=3.16.0" + sdk: ^3.4.0 + flutter: ">=3.22.0" dependencies: flutter: diff --git a/packages/local_auth/local_auth_android/pubspec.yaml b/packages/local_auth/local_auth_android/pubspec.yaml index 5b4b57a74d2..3e5feb787f2 100644 --- a/packages/local_auth/local_auth_android/pubspec.yaml +++ b/packages/local_auth/local_auth_android/pubspec.yaml @@ -2,11 +2,11 @@ name: local_auth_android description: Android implementation of the local_auth plugin. repository: https://github.com/flutter/packages/tree/main/packages/local_auth/local_auth_android issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+local_auth%22 -version: 1.0.38 +version: 1.0.39 environment: - sdk: ^3.2.0 - flutter: ">=3.16.0" + sdk: ^3.4.0 + flutter: ">=3.22.0" flutter: plugin: diff --git a/packages/path_provider/path_provider_android/CHANGELOG.md b/packages/path_provider/path_provider_android/CHANGELOG.md index c6a6eb1c410..4800df6d1e4 100644 --- a/packages/path_provider/path_provider_android/CHANGELOG.md +++ b/packages/path_provider/path_provider_android/CHANGELOG.md @@ -1,6 +1,7 @@ -## NEXT +## 2.2.5 -* Updates minimum supported SDK version to Flutter 3.16/Dart 3.2. +* Updates minimum supported SDK version to Flutter 3.22/Dart 3.4. +* Removes support for apps using the v1 Android embedding. ## 2.2.4 diff --git a/packages/path_provider/path_provider_android/android/src/main/java/io/flutter/plugins/pathprovider/PathProviderPlugin.java b/packages/path_provider/path_provider_android/android/src/main/java/io/flutter/plugins/pathprovider/PathProviderPlugin.java index a29fe9b9044..ce23e545d61 100644 --- a/packages/path_provider/path_provider_android/android/src/main/java/io/flutter/plugins/pathprovider/PathProviderPlugin.java +++ b/packages/path_provider/path_provider_android/android/src/main/java/io/flutter/plugins/pathprovider/PathProviderPlugin.java @@ -32,13 +32,6 @@ private void setup(BinaryMessenger messenger, Context context) { this.context = context; } - @SuppressWarnings("deprecation") - public static void registerWith( - @NonNull io.flutter.plugin.common.PluginRegistry.Registrar registrar) { - PathProviderPlugin instance = new PathProviderPlugin(); - instance.setup(registrar.messenger(), registrar.context()); - } - @Override public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) { setup(binding.getBinaryMessenger(), binding.getApplicationContext()); diff --git a/packages/path_provider/path_provider_android/example/pubspec.yaml b/packages/path_provider/path_provider_android/example/pubspec.yaml index 06b8e22a796..54601fb67d7 100644 --- a/packages/path_provider/path_provider_android/example/pubspec.yaml +++ b/packages/path_provider/path_provider_android/example/pubspec.yaml @@ -3,8 +3,8 @@ description: Demonstrates how to use the path_provider plugin. publish_to: none environment: - sdk: ^3.2.0 - flutter: ">=3.16.0" + sdk: ^3.4.0 + flutter: ">=3.22.0" dependencies: flutter: diff --git a/packages/path_provider/path_provider_android/pubspec.yaml b/packages/path_provider/path_provider_android/pubspec.yaml index eed16592e60..0aa1da9b373 100644 --- a/packages/path_provider/path_provider_android/pubspec.yaml +++ b/packages/path_provider/path_provider_android/pubspec.yaml @@ -2,11 +2,11 @@ name: path_provider_android description: Android implementation of the path_provider plugin. repository: https://github.com/flutter/packages/tree/main/packages/path_provider/path_provider_android issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+path_provider%22 -version: 2.2.4 +version: 2.2.5 environment: - sdk: ^3.2.0 - flutter: ">=3.16.0" + sdk: ^3.4.0 + flutter: ">=3.22.0" flutter: plugin: diff --git a/packages/quick_actions/quick_actions_android/CHANGELOG.md b/packages/quick_actions/quick_actions_android/CHANGELOG.md index edf3b9249c9..04a2ed9c52a 100644 --- a/packages/quick_actions/quick_actions_android/CHANGELOG.md +++ b/packages/quick_actions/quick_actions_android/CHANGELOG.md @@ -1,6 +1,7 @@ -## NEXT +## 1.0.13 -* Updates minimum supported SDK version to Flutter 3.16/Dart 3.2. +* Updates minimum supported SDK version to Flutter 3.22/Dart 3.4. +* Removes support for apps using the v1 Android embedding. ## 1.0.12 diff --git a/packages/quick_actions/quick_actions_android/android/src/main/java/io/flutter/plugins/quickactions/QuickActionsPlugin.java b/packages/quick_actions/quick_actions_android/android/src/main/java/io/flutter/plugins/quickactions/QuickActionsPlugin.java index eed613347d7..9dd701054ad 100644 --- a/packages/quick_actions/quick_actions_android/android/src/main/java/io/flutter/plugins/quickactions/QuickActionsPlugin.java +++ b/packages/quick_actions/quick_actions_android/android/src/main/java/io/flutter/plugins/quickactions/QuickActionsPlugin.java @@ -43,19 +43,6 @@ public QuickActionsPlugin() { this.sdkChecker = capabilityChecker; } - /** - * Plugin registration. - * - *

Must be called when the application is created. - */ - @SuppressWarnings("deprecation") - public static void registerWith( - @NonNull io.flutter.plugin.common.PluginRegistry.Registrar registrar) { - QuickActions quickActions = new QuickActions(registrar.context()); - quickActions.setActivity(registrar.activity()); - Messages.AndroidQuickActionsApi.setup(registrar.messenger(), quickActions); - } - @Override public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) { this.quickActions = new QuickActions(binding.getApplicationContext()); diff --git a/packages/quick_actions/quick_actions_android/example/pubspec.yaml b/packages/quick_actions/quick_actions_android/example/pubspec.yaml index 6166b64f391..632624f697f 100644 --- a/packages/quick_actions/quick_actions_android/example/pubspec.yaml +++ b/packages/quick_actions/quick_actions_android/example/pubspec.yaml @@ -3,8 +3,8 @@ description: Demonstrates how to use the quick_actions plugin. publish_to: none environment: - sdk: ^3.2.0 - flutter: ">=3.16.0" + sdk: ^3.4.0 + flutter: ">=3.22.0" dependencies: flutter: diff --git a/packages/quick_actions/quick_actions_android/pubspec.yaml b/packages/quick_actions/quick_actions_android/pubspec.yaml index 83065658ba1..5e089257b2c 100644 --- a/packages/quick_actions/quick_actions_android/pubspec.yaml +++ b/packages/quick_actions/quick_actions_android/pubspec.yaml @@ -2,11 +2,11 @@ name: quick_actions_android description: An implementation for the Android platform of the Flutter `quick_actions` plugin. repository: https://github.com/flutter/packages/tree/main/packages/quick_actions/quick_actions_android issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+in_app_purchase%22 -version: 1.0.12 +version: 1.0.13 environment: - sdk: ^3.2.0 - flutter: ">=3.16.0" + sdk: ^3.4.0 + flutter: ">=3.22.0" flutter: plugin: diff --git a/packages/shared_preferences/shared_preferences_android/CHANGELOG.md b/packages/shared_preferences/shared_preferences_android/CHANGELOG.md index 3b6e8d2d5be..aa4279ede83 100644 --- a/packages/shared_preferences/shared_preferences_android/CHANGELOG.md +++ b/packages/shared_preferences/shared_preferences_android/CHANGELOG.md @@ -1,6 +1,7 @@ -## NEXT +## 2.2.3 -* Updates minimum supported SDK version to Flutter 3.16/Dart 3.2. +* Updates minimum supported SDK version to Flutter 3.22/Dart 3.4. +* Removes support for apps using the v1 Android embedding. ## 2.2.2 diff --git a/packages/shared_preferences/shared_preferences_android/android/src/main/java/io/flutter/plugins/sharedpreferences/SharedPreferencesPlugin.java b/packages/shared_preferences/shared_preferences_android/android/src/main/java/io/flutter/plugins/sharedpreferences/SharedPreferencesPlugin.java index aecc43991cc..6bfa4e285a6 100644 --- a/packages/shared_preferences/shared_preferences_android/android/src/main/java/io/flutter/plugins/sharedpreferences/SharedPreferencesPlugin.java +++ b/packages/shared_preferences/shared_preferences_android/android/src/main/java/io/flutter/plugins/sharedpreferences/SharedPreferencesPlugin.java @@ -47,13 +47,6 @@ public SharedPreferencesPlugin() { this.listEncoder = listEncoder; } - @SuppressWarnings("deprecation") - public static void registerWith( - @NonNull io.flutter.plugin.common.PluginRegistry.Registrar registrar) { - final SharedPreferencesPlugin plugin = new SharedPreferencesPlugin(); - plugin.setUp(registrar.messenger(), registrar.context()); - } - private void setUp(@NonNull BinaryMessenger messenger, @NonNull Context context) { preferences = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE); try { diff --git a/packages/shared_preferences/shared_preferences_android/example/pubspec.yaml b/packages/shared_preferences/shared_preferences_android/example/pubspec.yaml index d9fb73c2452..0bdf6908628 100644 --- a/packages/shared_preferences/shared_preferences_android/example/pubspec.yaml +++ b/packages/shared_preferences/shared_preferences_android/example/pubspec.yaml @@ -3,8 +3,8 @@ description: Demonstrates how to use the shared_preferences plugin. publish_to: none environment: - sdk: ^3.2.0 - flutter: ">=3.16.0" + sdk: ^3.4.0 + flutter: ">=3.22.0" dependencies: flutter: diff --git a/packages/shared_preferences/shared_preferences_android/pubspec.yaml b/packages/shared_preferences/shared_preferences_android/pubspec.yaml index 647d87796cc..201f30884c9 100644 --- a/packages/shared_preferences/shared_preferences_android/pubspec.yaml +++ b/packages/shared_preferences/shared_preferences_android/pubspec.yaml @@ -2,11 +2,11 @@ name: shared_preferences_android description: Android implementation of the shared_preferences plugin repository: https://github.com/flutter/packages/tree/main/packages/shared_preferences/shared_preferences_android issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+shared_preferences%22 -version: 2.2.2 +version: 2.2.3 environment: - sdk: ^3.2.0 - flutter: ">=3.16.0" + sdk: ^3.4.0 + flutter: ">=3.22.0" flutter: plugin: diff --git a/packages/url_launcher/url_launcher_android/CHANGELOG.md b/packages/url_launcher/url_launcher_android/CHANGELOG.md index 846ee637343..73af3ff94af 100644 --- a/packages/url_launcher/url_launcher_android/CHANGELOG.md +++ b/packages/url_launcher/url_launcher_android/CHANGELOG.md @@ -1,3 +1,8 @@ +## 6.3.3 + +* Updates minimum supported SDK version to Flutter 3.22/Dart 3.4. +* Removes support for apps using the v1 Android embedding. + ## 6.3.2 * Bumps androidx.annotation:annotation from 1.7.1 to 1.8.0. diff --git a/packages/url_launcher/url_launcher_android/android/src/main/java/io/flutter/plugins/urllauncher/UrlLauncherPlugin.java b/packages/url_launcher/url_launcher_android/android/src/main/java/io/flutter/plugins/urllauncher/UrlLauncherPlugin.java index f2160ec4df2..34bf08f9f30 100644 --- a/packages/url_launcher/url_launcher_android/android/src/main/java/io/flutter/plugins/urllauncher/UrlLauncherPlugin.java +++ b/packages/url_launcher/url_launcher_android/android/src/main/java/io/flutter/plugins/urllauncher/UrlLauncherPlugin.java @@ -20,21 +20,6 @@ public final class UrlLauncherPlugin implements FlutterPlugin, ActivityAware { private static final String TAG = "UrlLauncherPlugin"; @Nullable private UrlLauncher urlLauncher; - /** - * Registers a plugin implementation that uses the stable {@code io.flutter.plugin.common} - * package. - * - *

Calling this automatically initializes the plugin. However plugins initialized this way - * won't react to changes in activity or context, unlike {@link UrlLauncherPlugin}. - */ - @SuppressWarnings("deprecation") - public static void registerWith( - @NonNull io.flutter.plugin.common.PluginRegistry.Registrar registrar) { - UrlLauncher handler = new UrlLauncher(registrar.context()); - handler.setActivity(registrar.activity()); - Messages.UrlLauncherApi.setup(registrar.messenger(), handler); - } - @Override public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) { urlLauncher = new UrlLauncher(binding.getApplicationContext()); diff --git a/packages/url_launcher/url_launcher_android/example/pubspec.yaml b/packages/url_launcher/url_launcher_android/example/pubspec.yaml index 883966920bb..256861b7250 100644 --- a/packages/url_launcher/url_launcher_android/example/pubspec.yaml +++ b/packages/url_launcher/url_launcher_android/example/pubspec.yaml @@ -3,8 +3,8 @@ description: Demonstrates how to use the url_launcher plugin. publish_to: none environment: - sdk: ^3.2.0 - flutter: ">=3.16.0" + sdk: ^3.4.0 + flutter: ">=3.22.0" dependencies: flutter: diff --git a/packages/url_launcher/url_launcher_android/pubspec.yaml b/packages/url_launcher/url_launcher_android/pubspec.yaml index 030c8a12e16..e3c65d4cd7a 100644 --- a/packages/url_launcher/url_launcher_android/pubspec.yaml +++ b/packages/url_launcher/url_launcher_android/pubspec.yaml @@ -2,10 +2,10 @@ name: url_launcher_android description: Android implementation of the url_launcher plugin. repository: https://github.com/flutter/packages/tree/main/packages/url_launcher/url_launcher_android issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+url_launcher%22 -version: 6.3.2 +version: 6.3.3 environment: - sdk: ^3.2.0 - flutter: ">=3.16.0" + sdk: ^3.4.0 + flutter: ">=3.22.0" flutter: plugin: diff --git a/packages/video_player/video_player_android/CHANGELOG.md b/packages/video_player/video_player_android/CHANGELOG.md index e48bd824747..cc9d5ceaa17 100644 --- a/packages/video_player/video_player_android/CHANGELOG.md +++ b/packages/video_player/video_player_android/CHANGELOG.md @@ -1,6 +1,7 @@ -## NEXT +## 2.4.15 -* Updates minimum supported SDK version to Flutter 3.16/Dart 3.2. +* Updates minimum supported SDK version to Flutter 3.22/Dart 3.4. +* Removes support for apps using the v1 Android embedding. ## 2.4.14 diff --git a/packages/video_player/video_player_android/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayerPlugin.java b/packages/video_player/video_player_android/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayerPlugin.java index aa9b5bdaa1b..5259e1ad3fe 100644 --- a/packages/video_player/video_player_android/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayerPlugin.java +++ b/packages/video_player/video_player_android/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayerPlugin.java @@ -50,18 +50,6 @@ private VideoPlayerPlugin(io.flutter.plugin.common.PluginRegistry.Registrar regi flutterState.startListening(this, registrar.messenger()); } - /** Registers this with the stable v1 embedding. Will not respond to lifecycle events. */ - @SuppressWarnings("deprecation") - public static void registerWith( - @NonNull io.flutter.plugin.common.PluginRegistry.Registrar registrar) { - final VideoPlayerPlugin plugin = new VideoPlayerPlugin(registrar); - registrar.addViewDestroyListener( - view -> { - plugin.onDestroy(); - return false; // We are not interested in assuming ownership of the NativeView. - }); - } - @Override public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) { if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { diff --git a/packages/video_player/video_player_android/example/pubspec.yaml b/packages/video_player/video_player_android/example/pubspec.yaml index d325708825f..a6c57dc8d8b 100644 --- a/packages/video_player/video_player_android/example/pubspec.yaml +++ b/packages/video_player/video_player_android/example/pubspec.yaml @@ -3,8 +3,8 @@ description: Demonstrates how to use the video_player plugin. publish_to: none environment: - sdk: ^3.2.0 - flutter: ">=3.16.0" + sdk: ^3.4.0 + flutter: ">=3.22.0" dependencies: flutter: diff --git a/packages/video_player/video_player_android/pubspec.yaml b/packages/video_player/video_player_android/pubspec.yaml index 1ac1fa5ea34..35c7d0ee55c 100644 --- a/packages/video_player/video_player_android/pubspec.yaml +++ b/packages/video_player/video_player_android/pubspec.yaml @@ -2,11 +2,11 @@ name: video_player_android description: Android implementation of the video_player plugin. repository: https://github.com/flutter/packages/tree/main/packages/video_player/video_player_android issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+video_player%22 -version: 2.4.14 +version: 2.4.15 environment: - sdk: ^3.2.0 - flutter: ">=3.16.0" + sdk: ^3.4.0 + flutter: ">=3.22.0" flutter: plugin: diff --git a/packages/webview_flutter/webview_flutter_android/CHANGELOG.md b/packages/webview_flutter/webview_flutter_android/CHANGELOG.md index 039efbcf0c9..0e2f151dbe9 100644 --- a/packages/webview_flutter/webview_flutter_android/CHANGELOG.md +++ b/packages/webview_flutter/webview_flutter_android/CHANGELOG.md @@ -1,3 +1,8 @@ +## 3.16.4 + +* Updates minimum supported SDK version to Flutter 3.22/Dart 3.4. +* Removes support for apps using the v1 Android embedding. + ## 3.16.3 * Bumps androidx.webkit:webkit from 1.10.0 to 1.11.0. diff --git a/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/FlutterAssetManager.java b/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/FlutterAssetManager.java index f50b5bf7280..d59943414b7 100644 --- a/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/FlutterAssetManager.java +++ b/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/FlutterAssetManager.java @@ -7,7 +7,6 @@ import android.content.res.AssetManager; import androidx.annotation.NonNull; import io.flutter.embedding.engine.plugins.FlutterPlugin; -import io.flutter.plugin.common.PluginRegistry; import java.io.IOException; /** Provides access to the assets registered as part of the App bundle. */ @@ -48,37 +47,6 @@ public String[] list(@NonNull String path) throws IOException { return assetManager.list(path); } - /** - * Provides access to assets using the {@link PluginRegistry.Registrar} for looking up file paths - * to Flutter assets. - * - * @deprecated The {@link RegistrarFlutterAssetManager} is for Flutter's v1 embedding. For - * instructions on migrating a plugin from Flutter's v1 Android embedding to v2, visit - * http://flutter.dev/go/android-plugin-migration - */ - @Deprecated - static class RegistrarFlutterAssetManager extends FlutterAssetManager { - final PluginRegistry.Registrar registrar; - - /** - * Constructs a new instance of the {@link RegistrarFlutterAssetManager}. - * - * @param assetManager Instance of Android's {@link AssetManager} used to access assets within - * the App bundle. - * @param registrar Instance of {@link io.flutter.plugin.common.PluginRegistry.Registrar} used - * to look up file paths to assets registered by Flutter. - */ - RegistrarFlutterAssetManager(AssetManager assetManager, PluginRegistry.Registrar registrar) { - super(assetManager); - this.registrar = registrar; - } - - @Override - public String getAssetFilePathByName(String name) { - return registrar.lookupKeyForAsset(name); - } - } - /** * Provides access to assets using the {@link FlutterPlugin.FlutterAssets} for looking up file * paths to Flutter assets. diff --git a/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/WebViewFlutterPlugin.java b/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/WebViewFlutterPlugin.java index 7f026119f47..3c73a4e4c31 100644 --- a/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/WebViewFlutterPlugin.java +++ b/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/WebViewFlutterPlugin.java @@ -34,8 +34,6 @@ * Java platform implementation of the webview_flutter plugin. * *

Register this in an add to app scenario to gracefully handle activity and context changes. - * - *

Call {@link #registerWith} to use the stable {@code io.flutter.plugin.common} package instead. */ public class WebViewFlutterPlugin implements FlutterPlugin, ActivityAware { @Nullable private InstanceManager instanceManager; @@ -48,35 +46,11 @@ public class WebViewFlutterPlugin implements FlutterPlugin, ActivityAware { * Add an instance of this to {@link io.flutter.embedding.engine.plugins.PluginRegistry} to * register it. * - *

THIS PLUGIN CODE PATH DEPENDS ON A NEWER VERSION OF FLUTTER THAN THE ONE DEFINED IN THE - * PUBSPEC.YAML. Text input will fail on some Android devices unless this is used with at least - * flutter/flutter@1d4d63ace1f801a022ea9ec737bf8c15395588b9. Use the V1 embedding with {@link - * #registerWith} to use this plugin with older Flutter versions. - * *

Registration should eventually be handled automatically by v2 of the * GeneratedPluginRegistrant. https://github.com/flutter/flutter/issues/42694 */ public WebViewFlutterPlugin() {} - /** - * Registers a plugin implementation that uses the stable {@code io.flutter.plugin.common} - * package. - * - *

Calling this automatically initializes the plugin. However plugins initialized this way - * won't react to changes in activity or context, unlike {@link WebViewFlutterPlugin}. - */ - @SuppressWarnings({"unused", "deprecation"}) - public static void registerWith( - @NonNull io.flutter.plugin.common.PluginRegistry.Registrar registrar) { - new WebViewFlutterPlugin() - .setUp( - registrar.messenger(), - registrar.platformViewRegistry(), - registrar.activity(), - new FlutterAssetManager.RegistrarFlutterAssetManager( - registrar.context().getAssets(), registrar)); - } - private void setUp( BinaryMessenger binaryMessenger, PlatformViewRegistry viewRegistry, diff --git a/packages/webview_flutter/webview_flutter_android/android/src/test/java/io/flutter/plugins/webviewflutter/RegistrarFlutterAssetManagerTest.java b/packages/webview_flutter/webview_flutter_android/android/src/test/java/io/flutter/plugins/webviewflutter/RegistrarFlutterAssetManagerTest.java deleted file mode 100644 index fa0d27d2f5b..00000000000 --- a/packages/webview_flutter/webview_flutter_android/android/src/test/java/io/flutter/plugins/webviewflutter/RegistrarFlutterAssetManagerTest.java +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -package io.flutter.plugins.webviewflutter; - -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.fail; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import android.content.res.AssetManager; -import java.io.IOException; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; - -@SuppressWarnings("deprecation") -public class RegistrarFlutterAssetManagerTest { - @Mock AssetManager mockAssetManager; - @Mock io.flutter.plugin.common.PluginRegistry.Registrar mockRegistrar; - - io.flutter.plugins.webviewflutter.FlutterAssetManager.RegistrarFlutterAssetManager - testRegistrarFlutterAssetManager; - - @Before - public void setUp() { - mockAssetManager = mock(AssetManager.class); - mockRegistrar = mock(io.flutter.plugin.common.PluginRegistry.Registrar.class); - - testRegistrarFlutterAssetManager = - new io.flutter.plugins.webviewflutter.FlutterAssetManager.RegistrarFlutterAssetManager( - mockAssetManager, mockRegistrar); - } - - @Test - public void list() { - try { - when(mockAssetManager.list("test/path")) - .thenReturn(new String[] {"index.html", "styles.css"}); - String[] actualFilePaths = testRegistrarFlutterAssetManager.list("test/path"); - verify(mockAssetManager).list("test/path"); - assertArrayEquals(new String[] {"index.html", "styles.css"}, actualFilePaths); - } catch (IOException ex) { - fail(); - } - } - - @Test - public void registrar_getAssetFilePathByName() { - testRegistrarFlutterAssetManager.getAssetFilePathByName("sample_movie.mp4"); - verify(mockRegistrar).lookupKeyForAsset("sample_movie.mp4"); - } -} diff --git a/packages/webview_flutter/webview_flutter_android/example/pubspec.yaml b/packages/webview_flutter/webview_flutter_android/example/pubspec.yaml index 1bf17a4c1f8..a79d03efb4c 100644 --- a/packages/webview_flutter/webview_flutter_android/example/pubspec.yaml +++ b/packages/webview_flutter/webview_flutter_android/example/pubspec.yaml @@ -3,8 +3,8 @@ description: Demonstrates how to use the webview_flutter_android plugin. publish_to: none environment: - sdk: ^3.2.0 - flutter: ">=3.16.0" + sdk: ^3.4.0 + flutter: ">=3.22.0" dependencies: flutter: diff --git a/packages/webview_flutter/webview_flutter_android/pubspec.yaml b/packages/webview_flutter/webview_flutter_android/pubspec.yaml index b950d8ec5f9..5a283b9acfc 100644 --- a/packages/webview_flutter/webview_flutter_android/pubspec.yaml +++ b/packages/webview_flutter/webview_flutter_android/pubspec.yaml @@ -2,11 +2,11 @@ name: webview_flutter_android description: A Flutter plugin that provides a WebView widget on Android. repository: https://github.com/flutter/packages/tree/main/packages/webview_flutter/webview_flutter_android issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+webview%22 -version: 3.16.3 +version: 3.16.4 environment: - sdk: ^3.2.0 - flutter: ">=3.16.0" + sdk: ^3.4.0 + flutter: ">=3.22.0" flutter: plugin: @@ -32,4 +32,4 @@ dev_dependencies: topics: - html - webview - - webview-flutter \ No newline at end of file + - webview-flutter From 023e3ba08c01c5f279d868b72338777c17a9ffbc Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Wed, 29 May 2024 00:41:07 +0530 Subject: [PATCH 11/14] [google_maps_flutter] Implement polyline patterns in google maps ios (#5757) This PR Implements patterns in google maps ios polylines. Currently the patterns param is simply ignored on ios, despite the official google maps SDK for ios having instructions on how to achieve repeated patterns: https://developers.google.com/maps/documentation/ios-sdk/shapes#add-a-repeating-color-pattern-to-a-polyline *List which issues are fixed by this PR. You must list at least one issue.* https://github.com/flutter/flutter/issues/60083 *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].* Nil --- .../example/lib/place_polyline.dart | 4 +- .../example/lib/place_polyline.dart | 4 +- .../google_maps_flutter_ios/CHANGELOG.md | 4 + .../ios/Runner.xcodeproj/project.pbxproj | 6 +- ...TGoogleMapJSONConversionsConversionTests.m | 14 ++++ .../GoogleMapsPolylinesControllerTests.m | 81 +++++++++++++++++++ .../maps_example_dart/lib/place_polyline.dart | 4 +- .../ios/Classes/FLTGoogleMapJSONConversions.h | 15 ++++ .../ios/Classes/FLTGoogleMapJSONConversions.m | 22 +++++ .../ios/Classes/GoogleMapPolylineController.h | 6 ++ .../ios/Classes/GoogleMapPolylineController.m | 50 ++++++++---- .../GoogleMapPolylineController_Test.h | 24 ++++++ .../google_maps_flutter_ios-umbrella.h | 1 + .../google_maps_flutter_ios/pubspec.yaml | 2 +- 14 files changed, 213 insertions(+), 24 deletions(-) create mode 100644 packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m create mode 100644 packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController_Test.h diff --git a/packages/google_maps_flutter/google_maps_flutter/example/lib/place_polyline.dart b/packages/google_maps_flutter/google_maps_flutter/example/lib/place_polyline.dart index e7997fa4445..7cb07ae37db 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/lib/place_polyline.dart +++ b/packages/google_maps_flutter/google_maps_flutter/example/lib/place_polyline.dart @@ -291,10 +291,10 @@ class PlacePolylineBodyState extends State { child: const Text('change joint type [Android only]'), ), TextButton( - onPressed: isIOS || (selectedId == null) + onPressed: (selectedId == null) ? null : () => _changePattern(selectedId), - child: const Text('change pattern [Android only]'), + child: const Text('change pattern'), ), ], ) diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/place_polyline.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/place_polyline.dart index 659ef87e87f..d008b7d3b97 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/place_polyline.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/place_polyline.dart @@ -292,10 +292,10 @@ class PlacePolylineBodyState extends State { child: const Text('change joint type [Android only]'), ), TextButton( - onPressed: isIOS || (selectedId == null) + onPressed: (selectedId == null) ? null : () => _changePattern(selectedId), - child: const Text('change pattern [Android only]'), + child: const Text('change pattern'), ), ], ) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md index cf9231d6a0a..3a0195b6ca0 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.6.1 + +* Adds support for patterns in polylines. + ## 2.6.0 * Updates the minimum allowed verison of the Google Maps SDK to 8.4, for privacy diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/Runner.xcodeproj/project.pbxproj b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/Runner.xcodeproj/project.pbxproj index d5b6d8248e0..660b466a2fd 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/Runner.xcodeproj/project.pbxproj @@ -11,6 +11,7 @@ 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 4510D964F3B1259FEDD3ABA6 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7755F8F4BABC3D6A0BD4048B /* libPods-Runner.a */; }; + 478116522BEF8F47002F593E /* GoogleMapsPolylinesControllerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 478116512BEF8F47002F593E /* GoogleMapsPolylinesControllerTests.m */; }; 6851F3562835BC180032B7C8 /* FLTGoogleMapJSONConversionsConversionTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6851F3552835BC180032B7C8 /* FLTGoogleMapJSONConversionsConversionTests.m */; }; 68E4726A2836FF0C00BDDDAC /* MapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 68E472692836FF0C00BDDDAC /* MapKit.framework */; }; 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; }; @@ -18,8 +19,8 @@ 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; - F269303B2BB389BF00BF17C4 /* assets in Resources */ = {isa = PBXBuildFile; fileRef = F269303A2BB389BF00BF17C4 /* assets */; }; 982F2A6C27BADE17003C81F4 /* PartiallyMockedMapView.m in Sources */ = {isa = PBXBuildFile; fileRef = 982F2A6B27BADE17003C81F4 /* PartiallyMockedMapView.m */; }; + F269303B2BB389BF00BF17C4 /* assets in Resources */ = {isa = PBXBuildFile; fileRef = F269303A2BB389BF00BF17C4 /* assets */; }; F7151F13265D7ED70028CB91 /* GoogleMapsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F7151F12265D7ED70028CB91 /* GoogleMapsTests.m */; }; F7151F21265D7EE50028CB91 /* GoogleMapsUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = F7151F20265D7EE50028CB91 /* GoogleMapsUITests.m */; }; FC8F35FC8CD533B128950487 /* libPods-RunnerTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F267F68029D1A4E2E4C572A7 /* libPods-RunnerTests.a */; }; @@ -60,6 +61,7 @@ 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 478116512BEF8F47002F593E /* GoogleMapsPolylinesControllerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GoogleMapsPolylinesControllerTests.m; sourceTree = ""; }; 6851F3552835BC180032B7C8 /* FLTGoogleMapJSONConversionsConversionTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLTGoogleMapJSONConversionsConversionTests.m; sourceTree = ""; }; 68E472692836FF0C00BDDDAC /* MapKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MapKit.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.0.sdk/System/iOSSupport/System/Library/Frameworks/MapKit.framework; sourceTree = DEVELOPER_DIR; }; 733AFAB37683A9DA7512F09C /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; }; @@ -203,6 +205,7 @@ F269303A2BB389BF00BF17C4 /* assets */, 6851F3552835BC180032B7C8 /* FLTGoogleMapJSONConversionsConversionTests.m */, F7151F12265D7ED70028CB91 /* GoogleMapsTests.m */, + 478116512BEF8F47002F593E /* GoogleMapsPolylinesControllerTests.m */, 982F2A6A27BADE17003C81F4 /* PartiallyMockedMapView.h */, 982F2A6B27BADE17003C81F4 /* PartiallyMockedMapView.m */, F7151F14265D7ED70028CB91 /* Info.plist */, @@ -467,6 +470,7 @@ F7151F13265D7ED70028CB91 /* GoogleMapsTests.m in Sources */, 6851F3562835BC180032B7C8 /* FLTGoogleMapJSONConversionsConversionTests.m in Sources */, 982F2A6C27BADE17003C81F4 /* PartiallyMockedMapView.m in Sources */, + 478116522BEF8F47002F593E /* GoogleMapsPolylinesControllerTests.m in Sources */, 0DD7B6C32B744EEF00E857FD /* FLTTileProviderControllerTests.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/FLTGoogleMapJSONConversionsConversionTests.m b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/FLTGoogleMapJSONConversionsConversionTests.m index 0d7d3ee9b2b..cc654606d8c 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/FLTGoogleMapJSONConversionsConversionTests.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/FLTGoogleMapJSONConversionsConversionTests.m @@ -288,4 +288,18 @@ - (void)testCameraUpdateFromChannelValueZoomTo { [classMockCameraUpdate stopMocking]; } +- (void)testLengthsFromPatterns { + NSArray *> *patterns = @[ @[ @"gap", @10 ], @[ @"dash", @6.4 ] ]; + + NSArray *spanLengths = [FLTGoogleMapJSONConversions spanLengthsFromPatterns:patterns]; + + XCTAssertEqual([spanLengths count], 2); + + NSNumber *firstSpanLength = spanLengths[0]; + NSNumber *secondSpanLength = spanLengths[1]; + + XCTAssertEqual(firstSpanLength.doubleValue, 10); + XCTAssertEqual(secondSpanLength.doubleValue, 6.4); +} + @end diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m new file mode 100644 index 00000000000..84714f17c7f --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m @@ -0,0 +1,81 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +@import google_maps_flutter_ios; +@import google_maps_flutter_ios.Test; +@import XCTest; +@import GoogleMaps; + +#import +#import +#import "PartiallyMockedMapView.h" + +@interface GoogleMapsPolylinesControllerTests : XCTestCase +@end + +@implementation GoogleMapsPolylinesControllerTests + +/// Returns GoogleMapPolylineController object instantiated with a mocked map instance +/// +/// @return An object of FLTGoogleMapPolylineController +- (FLTGoogleMapPolylineController *)polylineControllerWithMockedMap { + NSDictionary *polyline = @{ + @"points" : @[ + @[ @(52.4816), @(-3.1791) ], @[ @(54.043), @(-2.9925) ], @[ @(54.1396), @(-4.2739) ], + @[ @(53.4153), @(-4.0829) ] + ], + @"polylineId" : @"polyline_id_0", + }; + + CGRect frame = CGRectMake(0, 0, 100, 100); + GMSCameraPosition *camera = [[GMSCameraPosition alloc] initWithLatitude:0 longitude:0 zoom:0]; + + GMSMapViewOptions *mapViewOptions = [[GMSMapViewOptions alloc] init]; + mapViewOptions.frame = frame; + mapViewOptions.camera = camera; + + PartiallyMockedMapView *mapView = [[PartiallyMockedMapView alloc] initWithOptions:mapViewOptions]; + + GMSMutablePath *path = [FLTPolylinesController pathForPolyline:polyline]; + NSString *identifier = polyline[@"polylineId"]; + + FLTGoogleMapPolylineController *polylineControllerWithMockedMap = + [[FLTGoogleMapPolylineController alloc] initPolylineWithPath:path + identifier:identifier + mapView:mapView]; + + return polylineControllerWithMockedMap; +} + +- (void)testSetPatterns { + NSArray *styles = @[ + [GMSStrokeStyle solidColor:[UIColor clearColor]], [GMSStrokeStyle solidColor:[UIColor redColor]] + ]; + + NSArray *lengths = @[ @10, @10 ]; + + FLTGoogleMapPolylineController *polylineController = [self polylineControllerWithMockedMap]; + + XCTAssertNil(polylineController.polyline.spans); + + [polylineController setPattern:styles lengths:lengths]; + + // `GMSStyleSpan` doesn't implement `isEqual` so cannot be compared by value at present. + XCTAssertNotNil(polylineController.polyline.spans); +} + +- (void)testStrokeStylesFromPatterns { + NSArray *> *patterns = @[ @[ @"gap", @10 ], @[ @"dash", @10 ] ]; + UIColor *strokeColor = [UIColor redColor]; + + NSArray *patternStrokeStyle = + [FLTGoogleMapJSONConversions strokeStylesFromPatterns:patterns strokeColor:strokeColor]; + + XCTAssertEqual([patternStrokeStyle count], 2); + + // None of the parameters of `patternStrokeStyle` is observable, so we limit to testing + // the length of this output array. +} + +@end diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/place_polyline.dart b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/place_polyline.dart index 659ef87e87f..d008b7d3b97 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/place_polyline.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/place_polyline.dart @@ -292,10 +292,10 @@ class PlacePolylineBodyState extends State { child: const Text('change joint type [Android only]'), ), TextButton( - onPressed: isIOS || (selectedId == null) + onPressed: (selectedId == null) ? null : () => _changePattern(selectedId), - child: const Text('change pattern [Android only]'), + child: const Text('change pattern'), ), ], ) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.h b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.h index cfccb7b0b5f..1fc8d003d91 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.h +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.h @@ -25,6 +25,21 @@ NS_ASSUME_NONNULL_BEGIN + (GMSMapViewType)mapViewTypeFromTypeValue:(NSNumber *)value; + (nullable GMSCameraUpdate *)cameraUpdateFromChannelValue:(NSArray *)channelValue; +/// Return GMS strokestyle object array populated using the patterns and stroke colors passed in. +/// +/// @param patterns An array of patterns for each stroke in the polyline. +/// @param strokeColor An array of color for each stroke in the polyline. +/// @return An array of GMSStrokeStyle. ++ (NSArray *)strokeStylesFromPatterns:(NSArray *> *)patterns + strokeColor:(UIColor *)strokeColor; + +/// Return GMS strokestyle object array populated using the patterns and stroke colors passed in. +/// Extracts the lengths of each stroke in the polyline from patterns input +/// +/// @param patterns An array of object representing the pattern params in the polyline. +/// @return Array of lengths. ++ (NSArray *)spanLengthsFromPatterns:(NSArray *> *)patterns; + @end NS_ASSUME_NONNULL_END diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.m index d554c501b1e..28307182f2c 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.m @@ -141,4 +141,26 @@ + (nullable GMSCameraUpdate *)cameraUpdateFromChannelValue:(NSArray *)channelVal } return nil; } + ++ (NSArray *)strokeStylesFromPatterns:(NSArray *> *)patterns + strokeColor:(UIColor *)strokeColor { + NSMutableArray *strokeStyles = [[NSMutableArray alloc] initWithCapacity:[patterns count]]; + for (NSArray *pattern in patterns) { + NSString *patternType = pattern[0]; + UIColor *color = [patternType isEqualToString:@"gap"] ? [UIColor clearColor] : strokeColor; + [strokeStyles addObject:[GMSStrokeStyle solidColor:color]]; + } + + return strokeStyles; +} + ++ (NSArray *)spanLengthsFromPatterns:(NSArray *> *)patterns { + NSMutableArray *lengths = [[NSMutableArray alloc] initWithCapacity:[patterns count]]; + for (NSArray *pattern in patterns) { + NSNumber *length = [pattern count] > 1 ? pattern[1] : @0; + [lengths addObject:length]; + } + + return lengths; +} @end diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.h b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.h index f85d1a3896f..63061392e5a 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.h +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.h @@ -11,6 +11,12 @@ identifier:(NSString *)identifier mapView:(GMSMapView *)mapView; - (void)removePolyline; + +/// Sets the pattern on polyline controller +/// +/// @param styles The styles for repeating pattern sections. +/// @param lengths The lengths for repeating pattern sections. +- (void)setPattern:(NSArray *)styles lengths:(NSArray *)lengths; @end @interface FLTPolylinesController : NSObject diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m index 77601d4a1bb..47334576b1c 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m @@ -12,6 +12,12 @@ @interface FLTGoogleMapPolylineController () @end +/// Returns dict[key], or nil if dict[key] is NSNull. +static id GetValueOrNilFromDict(NSDictionary *dict, NSString *key) { + id value = dict[key]; + return value == [NSNull null] ? nil : value; +} + @implementation FLTGoogleMapPolylineController - (instancetype)initPolylineWithPath:(GMSMutablePath *)path @@ -59,42 +65,54 @@ - (void)setGeodesic:(BOOL)isGeodesic { self.polyline.geodesic = isGeodesic; } +- (void)setPattern:(NSArray *)styles lengths:(NSArray *)lengths { + self.polyline.spans = GMSStyleSpans(self.polyline.path, styles, lengths, kGMSLengthRhumb); +} + - (void)interpretPolylineOptions:(NSDictionary *)data registrar:(NSObject *)registrar { - NSNumber *consumeTapEvents = data[@"consumeTapEvents"]; - if (consumeTapEvents && consumeTapEvents != (id)[NSNull null]) { + NSNumber *consumeTapEvents = GetValueOrNilFromDict(data, @"consumeTapEvents"); + if (consumeTapEvents) { [self setConsumeTapEvents:[consumeTapEvents boolValue]]; } - NSNumber *visible = data[@"visible"]; - if (visible && visible != (id)[NSNull null]) { + NSNumber *visible = GetValueOrNilFromDict(data, @"visible"); + if (visible) { [self setVisible:[visible boolValue]]; } - NSNumber *zIndex = data[@"zIndex"]; - if (zIndex && zIndex != (id)[NSNull null]) { + NSNumber *zIndex = GetValueOrNilFromDict(data, @"zIndex"); + if (zIndex) { [self setZIndex:[zIndex intValue]]; } - NSArray *points = data[@"points"]; - if (points && points != (id)[NSNull null]) { + NSArray *points = GetValueOrNilFromDict(data, @"points"); + if (points) { [self setPoints:[FLTGoogleMapJSONConversions pointsFromLatLongs:points]]; } - NSNumber *strokeColor = data[@"color"]; - if (strokeColor && strokeColor != (id)[NSNull null]) { + NSNumber *strokeColor = GetValueOrNilFromDict(data, @"color"); + if (strokeColor) { [self setColor:[FLTGoogleMapJSONConversions colorFromRGBA:strokeColor]]; } - NSNumber *strokeWidth = data[@"width"]; - if (strokeWidth && strokeWidth != (id)[NSNull null]) { + NSNumber *strokeWidth = GetValueOrNilFromDict(data, @"width"); + if (strokeWidth) { [self setStrokeWidth:[strokeWidth intValue]]; } - NSNumber *geodesic = data[@"geodesic"]; - if (geodesic && geodesic != (id)[NSNull null]) { + NSNumber *geodesic = GetValueOrNilFromDict(data, @"geodesic"); + if (geodesic) { [self setGeodesic:geodesic.boolValue]; } + + NSArray *patterns = GetValueOrNilFromDict(data, @"pattern"); + if (patterns) { + [self + setPattern:[FLTGoogleMapJSONConversions strokeStylesFromPatterns:patterns + strokeColor:self.polyline.strokeColor] + lengths:[FLTGoogleMapJSONConversions spanLengthsFromPatterns:patterns]]; + } } @end @@ -125,7 +143,7 @@ - (instancetype)init:(FlutterMethodChannel *)methodChannel } - (void)addPolylines:(NSArray *)polylinesToAdd { for (NSDictionary *polyline in polylinesToAdd) { - GMSMutablePath *path = [FLTPolylinesController getPath:polyline]; + GMSMutablePath *path = [FLTPolylinesController pathForPolyline:polyline]; NSString *identifier = polyline[@"polylineId"]; FLTGoogleMapPolylineController *controller = [[FLTGoogleMapPolylineController alloc] initPolylineWithPath:path @@ -171,7 +189,7 @@ - (bool)hasPolylineWithIdentifier:(NSString *)identifier { } return self.polylineIdentifierToController[identifier] != nil; } -+ (GMSMutablePath *)getPath:(NSDictionary *)polyline { ++ (GMSMutablePath *)pathForPolyline:(NSDictionary *)polyline { NSArray *pointArray = polyline[@"points"]; NSArray *points = [FLTGoogleMapJSONConversions pointsFromLatLongs:pointArray]; GMSMutablePath *path = [GMSMutablePath path]; diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController_Test.h b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController_Test.h new file mode 100644 index 00000000000..2b6e91e5d12 --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController_Test.h @@ -0,0 +1,24 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import "GoogleMapPolylineController.h" + +/// Internal APIs exposed for unit testing +@interface FLTGoogleMapPolylineController (Test) + +/// Polyline instance the controller is attached to +@property(strong, nonatomic) GMSPolyline *polyline; + +@end + +/// Internal APIs explosed for unit testing +@interface FLTPolylinesController (Test) + +/// Returns the path for polyline based on the points(locations) the polyline has. +/// +/// @param polyline The polyline instance for which path is calculated. +/// @return An instance of GMSMutablePath. ++ (GMSMutablePath *)pathForPolyline:(NSDictionary *)polyline; + +@end diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/google_maps_flutter_ios-umbrella.h b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/google_maps_flutter_ios-umbrella.h index 791c3aaea6c..4f331de069b 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/google_maps_flutter_ios-umbrella.h +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/google_maps_flutter_ios-umbrella.h @@ -6,6 +6,7 @@ #import #import #import +#import FOUNDATION_EXPORT double google_maps_flutterVersionNumber; FOUNDATION_EXPORT const unsigned char google_maps_flutterVersionString[]; diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_ios/pubspec.yaml index e98f7209380..df74168cb10 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_ios/pubspec.yaml @@ -2,7 +2,7 @@ name: google_maps_flutter_ios description: iOS implementation of the google_maps_flutter plugin. repository: https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter_ios issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22 -version: 2.6.0 +version: 2.6.1 environment: sdk: ^3.2.3 From 2a051d7309ef2b5636584c4f051f88d1b387e910 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 28 May 2024 19:20:18 +0000 Subject: [PATCH 12/14] [pigeon]: Bump org.jetbrains.kotlin:kotlin-gradle-plugin from 1.9.22 to 2.0.0 in /packages/pigeon/platform_tests/test_plugin/android (#6815) Bumps [org.jetbrains.kotlin:kotlin-gradle-plugin](https://github.com/JetBrains/kotlin) from 1.9.22 to 2.0.0.

Release notes

Sourced from org.jetbrains.kotlin:kotlin-gradle-plugin's releases.

Kotlin 2.0.0

Changelog

Analysis. API

New Features

  • KT-65327 Support reading klib contents in Analysis API

Performance Improvements

  • KT-65560 K2: Anaysis API: ContextCollector triggers redundant resolution in the case of file elements
  • KT-64987 Analysis API: 50GB memory allocation on creating empty kotlinx.collections.immutable.persistentMapOf
  • KT-61789 K2: optimize getFirForNonKtFileElement for references inside super type reference
  • KT-59498 K2: getOnAirGetTowerContextProvider took too much time due to on air resolve
  • KT-61728 Analysis API: optimize AllCandidatesResolver.getAllCandidates

Fixes

  • KT-65561 Analysis API: dummy.kt is not a physical file
  • KT-65616 K2: FirDeclarationStatusImpl cannot be cast to FirResolvedDeclarationStatus from STATUS
  • KT-65600 Analysis Api: FirFile for KtCodeFragments are created and not updated on changes
  • KT-64919 K2 IDE: Implement KMP support for sealed class inheritors
  • KT-64241 K2: Unresolved calls to functions in scripts depending on included projects
  • KT-65813 Analysis API Standalone: FirDeclarationForCompiledElementSearcher does not find compiled elements
  • KT-66052 AA: render expect/actual modifier
  • KT-66795 KtCodeFragment.clone() is broken
  • KT-66532 K2 CodeGen AA: missing annotation setup for function in source module but not in a compile target file
  • KT-64833 Analysis API: Members implemented by delegation have no overridden symbols
  • KT-62405 Analysis API: Symbols SUBSTITUTION_OVERRIDE have no overridden symbols
  • KT-66749 K2: "Collection contains no element matching the predicate" on an unresolved call
  • KT-62832 K2: ClassCastException: FirDeclarationStatusImpl cannot be cast to FirResolvedDeclarationStatus
  • KT-66719 AbstractGetKlibSourceFileNameTest: The dependency to ":native:analysis-api-klib-reader" breaks JPS compilation
  • KT-66603 Analysis API: support type annotations in KtPsiTypeProviderMixIn#asPsiType
  • KT-64505 Analysis API Standalone: Remove test-specific calculation of sealed class inheritors
  • KT-66013 Analysis API Standalone: Sealed inheritors aren't correctly calculated for source classes
  • KT-62880 K2 IDE: Unresolved java annotation methods in KDoc
  • KT-66530 K2: Analysis API: KtPsiTypeProvider#asKtType crashes on PsiClassType for Java type parameter with wrong use site
  • KT-65571 Support VirtualFile inputs to Analysis API modules
  • KT-66485 Substituted types are not provided for callable references
  • KT-66498 Analysis API: 'KtFe10SymbolDeclarationOverridesProvider' considers a class to be a subclass of itself
  • KT-64579 K2 IDE: "Expected FirResolvedArgumentList for FirAnnotationCallImpl of FirValueParameterImpl(Source) but FirArgumentListImpl found"
  • KT-65978 Analysis API: Use soft references in FileStructureCache
  • KT-64051 K2 IDE: Analysis API: Unresolved links to typealias in KDoc
  • KT-66189 K2 / IDE: KtFirExpressionTypeProvider bugs
  • KT-61422 K2 IDE: "No array element type for vararg value parameter: org.jetbrains.kotlin.fir.declarations.impl.FirValueParameterImpl"
  • KT-66276 K2: Analysis API: TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM false positive for script parameter
  • KT-66232 K2: Analysis API: cover ScriptWithCustomDefDiagnosticsTestBaseGenerated by LL FIR tests
  • KT-60996 K2: Stub Based Deserializer: Set versionRequirements to enable VERSION_REQUIREMENT_DEPRECATION diagnostics
  • KT-66306 K2: Analysis API: drop ability to enable global phase resolve lock
  • KT-55750 LL FIR: Implement multi-threaded resolve

... (truncated)

Changelog

Sourced from org.jetbrains.kotlin:kotlin-gradle-plugin's changelog.

2.0.0

Analysis. API

New Features

  • KT-65327 Support reading klib contents in Analysis API

Performance Improvements

  • KT-65560 K2: Anaysis API: ContextCollector triggers redundant resolution in the case of file elements
  • KT-64987 Analysis API: 50GB memory allocation on creating empty kotlinx.collections.immutable.persistentMapOf
  • KT-61789 K2: optimize getFirForNonKtFileElement for references inside super type reference
  • KT-59498 K2: getOnAirGetTowerContextProvider took too much time due to on air resolve
  • KT-61728 Analysis API: optimize AllCandidatesResolver.getAllCandidates

Fixes

  • KT-65561 Analysis API: dummy.kt is not a physical file
  • KT-65616 K2: FirDeclarationStatusImpl cannot be cast to FirResolvedDeclarationStatus from STATUS
  • KT-65600 Analysis Api: FirFile for KtCodeFragments are created and not updated on changes
  • KT-64919 K2 IDE: Implement KMP support for sealed class inheritors
  • KT-64241 K2: Unresolved calls to functions in scripts depending on included projects
  • KT-65813 Analysis API Standalone: FirDeclarationForCompiledElementSearcher does not find compiled elements
  • KT-66052 AA: render expect/actual modifier
  • KT-66795 KtCodeFragment.clone() is broken
  • KT-66532 K2 CodeGen AA: missing annotation setup for function in source module but not in a compile target file
  • KT-64833 Analysis API: Members implemented by delegation have no overridden symbols
  • KT-62405 Analysis API: Symbols SUBSTITUTION_OVERRIDE have no overridden symbols
  • KT-66749 K2: "Collection contains no element matching the predicate" on an unresolved call
  • KT-62832 K2: ClassCastException: FirDeclarationStatusImpl cannot be cast to FirResolvedDeclarationStatus
  • KT-66719 AbstractGetKlibSourceFileNameTest: The dependency to ":native:analysis-api-klib-reader" breaks JPS compilation
  • KT-66603 Analysis API: support type annotations in KtPsiTypeProviderMixIn#asPsiType
  • KT-64505 Analysis API Standalone: Remove test-specific calculation of sealed class inheritors
  • KT-66013 Analysis API Standalone: Sealed inheritors aren't correctly calculated for source classes
  • KT-62880 K2 IDE: Unresolved java annotation methods in KDoc
  • KT-66530 K2: Analysis API: KtPsiTypeProvider#asKtType crashes on PsiClassType for Java type parameter with wrong use site
  • KT-65571 Support VirtualFile inputs to Analysis API modules
  • KT-66485 Substituted types are not provided for callable references
  • KT-66498 Analysis API: 'KtFe10SymbolDeclarationOverridesProvider' considers a class to be a subclass of itself
  • KT-64579 K2 IDE: "Expected FirResolvedArgumentList for FirAnnotationCallImpl of FirValueParameterImpl(Source) but FirArgumentListImpl found"
  • KT-65978 Analysis API: Use soft references in FileStructureCache
  • KT-64051 K2 IDE: Analysis API: Unresolved links to typealias in KDoc
  • KT-66189 K2 / IDE: KtFirExpressionTypeProvider bugs
  • KT-61422 K2 IDE: "No array element type for vararg value parameter: org.jetbrains.kotlin.fir.declarations.impl.FirValueParameterImpl"
  • KT-66276 K2: Analysis API: TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM false positive for script parameter
  • KT-66232 K2: Analysis API: cover ScriptWithCustomDefDiagnosticsTestBaseGenerated by LL FIR tests
  • KT-60996 K2: Stub Based Deserializer: Set versionRequirements to enable VERSION_REQUIREMENT_DEPRECATION diagnostics
  • KT-66306 K2: Analysis API: drop ability to enable global phase resolve lock
  • KT-55750 LL FIR: Implement multi-threaded resolve

... (truncated)

Commits
  • e84e835 Add changelog for 2.0.0
  • 975dea2 Add changelog for 2.0.0-RC3
  • b618ee4 [FIR] Prohibit referencing java field in case of conflict with property..
  • b239239 K2: build outer classes sequence in FirImplicitBodyResolve properly
  • afc5b49 [IR] Assume IrFile has at least one offset entry
  • be1804c [K/N][tests] Don't attempt to download simulator after first failure
  • b666160 K2: fix captureFromExpressionInternal for nullable intersection types
  • f04f051 K2: fix withNullability() for ConeIntersectionType
  • cda1ad4 K2: reproduce KT-67912
  • 8e0919e [K2/JS] Use declaration session for looking up containing declaration
  • Additional commits viewable in compare view

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=org.jetbrains.kotlin:kotlin-gradle-plugin&package-manager=gradle&previous-version=1.9.22&new-version=2.0.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- packages/pigeon/platform_tests/test_plugin/android/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/pigeon/platform_tests/test_plugin/android/build.gradle b/packages/pigeon/platform_tests/test_plugin/android/build.gradle index 96cc166d5a8..e99686da09c 100644 --- a/packages/pigeon/platform_tests/test_plugin/android/build.gradle +++ b/packages/pigeon/platform_tests/test_plugin/android/build.gradle @@ -2,7 +2,7 @@ group 'com.example.test_plugin' version '1.0-SNAPSHOT' buildscript { - ext.kotlin_version = '1.9.22' + ext.kotlin_version = '2.0.0' repositories { google() mavenCentral() From 52101d3d04ff095cd8ca604c9fd74821a34793aa Mon Sep 17 00:00:00 2001 From: Thang Date: Wed, 29 May 2024 00:43:28 +0700 Subject: [PATCH 13/14] update versions go_router & go_router_builder --- packages/go_router/CHANGELOG.md | 4 ++++ packages/go_router_builder/CHANGELOG.md | 4 ++++ packages/go_router_builder/pubspec.yaml | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/go_router/CHANGELOG.md b/packages/go_router/CHANGELOG.md index 5e2bac6cee0..2115a894e19 100644 --- a/packages/go_router/CHANGELOG.md +++ b/packages/go_router/CHANGELOG.md @@ -9,6 +9,10 @@ ## 14.1.3 +- Adds `GoRouter.goRelative` + +## 14.1.3 + - Improves the logging of routes when `debugLogDiagnostics` is enabled or `debugKnownRoutes() is called. Explains the position of shell routes in the route tree. Prints the widget name of the routes it is building. ## 14.1.2 diff --git a/packages/go_router_builder/CHANGELOG.md b/packages/go_router_builder/CHANGELOG.md index 3332a70e1b8..8357de4d3f0 100644 --- a/packages/go_router_builder/CHANGELOG.md +++ b/packages/go_router_builder/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.7.1 + +- Adds `TypedRelativeGoRoute` annotation which supports relative routes. + ## 2.7.0 - Adds an example and a test with `onExit`. diff --git a/packages/go_router_builder/pubspec.yaml b/packages/go_router_builder/pubspec.yaml index 0e6e10b6b3d..6fba2f8dc9f 100644 --- a/packages/go_router_builder/pubspec.yaml +++ b/packages/go_router_builder/pubspec.yaml @@ -2,7 +2,7 @@ name: go_router_builder description: >- A builder that supports generated strongly-typed route helpers for package:go_router -version: 2.7.0 +version: 2.7.1 repository: https://github.com/flutter/packages/tree/main/packages/go_router_builder issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+go_router_builder%22 From 101d03bb494afed73b8467618285e44fc07d8f67 Mon Sep 17 00:00:00 2001 From: Thang Date: Wed, 29 May 2024 13:51:50 +0700 Subject: [PATCH 14/14] fix changelog title --- packages/go_router/CHANGELOG.md | 4 ++++ packages/go_router/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/go_router/CHANGELOG.md b/packages/go_router/CHANGELOG.md index 2115a894e19..9b3b53e0d3b 100644 --- a/packages/go_router/CHANGELOG.md +++ b/packages/go_router/CHANGELOG.md @@ -11,6 +11,10 @@ - Adds `GoRouter.goRelative` +## 14.1.4 + +- Fixes a URL in `navigation.md`. + ## 14.1.3 - Improves the logging of routes when `debugLogDiagnostics` is enabled or `debugKnownRoutes() is called. Explains the position of shell routes in the route tree. Prints the widget name of the routes it is building. diff --git a/packages/go_router/pubspec.yaml b/packages/go_router/pubspec.yaml index 4d8331d16a6..09061001a77 100644 --- a/packages/go_router/pubspec.yaml +++ b/packages/go_router/pubspec.yaml @@ -1,7 +1,7 @@ name: go_router description: A declarative router for Flutter based on Navigation 2 supporting deep linking, data-driven routes and more -version: 14.1.4 +version: 14.1.5 repository: https://github.com/flutter/packages/tree/main/packages/go_router issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+go_router%22