Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
uldall authored Jul 16, 2024
2 parents 95c6d1a + 7022a44 commit 5978b00
Show file tree
Hide file tree
Showing 48 changed files with 500 additions and 254 deletions.
35 changes: 33 additions & 2 deletions .ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,24 @@ targets:
timeout: 30
properties:
version_file: flutter_master.version
target_file: android_build_all_packages.yaml
# This builds the all_packages app only in a current JDK.
target_file: android_build_all_packages_jdk17.yaml
channel: master
env_variables: >-
{
"CHANNEL": "master"
}
- name: Linux_android android_build_all_packages_legacy master
recipe: packages/packages
timeout: 30
properties:
version_file: flutter_master.version
# TODO(stuartmorgan): Once stable requires JDK 17, and the
# legacy project is updated accordingly, this entire target
# can be merged back into android_build_all_packages.
# This file only builds a *legacy* version of the project.
target_file: android_build_all_packages_legacy.yaml
channel: master
# The legacy project build requires an older JDK.
dependencies: >-
Expand All @@ -382,7 +399,21 @@ targets:
properties:
add_recipes_cq: "true"
version_file: flutter_stable.version
target_file: android_build_all_packages.yaml
# This builds the all_packages app only in a current JDK.
target_file: android_build_all_packages_jdk17.yaml
channel: stable
env_variables: >-
{
"CHANNEL": "stable"
}
- name: Linux_android android_build_all_packages_legacy stable
recipe: packages/packages
timeout: 30
properties:
version_file: flutter_stable.version
# This file only builds a *legacy* version of the project.
target_file: android_build_all_packages_legacy.yaml
channel: stable
# The legacy project build requires an older JDK.
dependencies: >-
Expand Down
2 changes: 1 addition & 1 deletion .ci/flutter_master.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5103d757436124a08e6a8024ebacbf0cf4b2bacf
58068d8ea4eca8a17d99469697aaff46255522e9
14 changes: 14 additions & 0 deletions .ci/targets/android_build_all_packages_jdk17.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This only builds the modern all_packages app, which requires jdk17+
tasks:
- name: prepare tool
script: .ci/scripts/prepare_tool.sh
infra_step: true # Note infra steps failing prevents "always" from running.
- name: create all_packages app
script: .ci/scripts/create_all_packages_app.sh
infra_step: true # Note infra steps failing prevents "always" from running.
- name: build all_packages for Android debug
script: .ci/scripts/build_all_packages_app.sh
args: ["apk", "debug"]
- name: build all_packages for Android release
script: .ci/scripts/build_all_packages_app.sh
args: ["apk", "release"]
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
# This only builds the legacy all_packages app, which requires jdk11
tasks:
- name: prepare tool
script: .ci/scripts/prepare_tool.sh
infra_step: true # Note infra steps failing prevents "always" from running.
- name: create all_packages app
script: .ci/scripts/create_all_packages_app.sh
infra_step: true # Note infra steps failing prevents "always" from running.
- name: build all_packages for Android debug
script: .ci/scripts/build_all_packages_app.sh
args: ["apk", "debug"]
- name: build all_packages for Android release
script: .ci/scripts/build_all_packages_app.sh
args: ["apk", "release"]
- name: create all_packages app - legacy version
script: .ci/scripts/create_all_packages_app_legacy.sh
# Output dir; must match the final argument to build_all_packages_app_legacy
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
cd $GITHUB_WORKSPACE
# Checks out a copy of the repo.
- name: Check out code
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
with:
fetch-depth: 0 # Fetch all history so the tool can get all the tags to determine version.
- name: Set up tools
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/scorecards-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:

steps:
- name: "Checkout code"
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v2.4.0
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v2.4.0
with:
persist-credentials: false

Expand All @@ -41,14 +41,14 @@ jobs:

# Upload the results as artifacts (optional).
- name: "Upload artifact"
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v2.3.1
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v2.3.1
with:
name: SARIF file
path: results.sarif
retention-days: 5

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@23acc5c183826b7a8a97bce3cecc52db901f8251 # v1.0.26
uses: github/codeql-action/upload-sarif@4fa2a7953630fd2f3fb380f21be14ede0169dd4f # v1.0.26
with:
sarif_file: results.sarif
4 changes: 4 additions & 0 deletions packages/go_router/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 14.2.1

- Makes GoRouterState lookup more robust.

## 14.2.0

- Added proper `redirect` handling for `ShellRoute.$route` and `StatefulShellRoute.$route` for proper redirection handling in case of code generation.
Expand Down
57 changes: 37 additions & 20 deletions packages/go_router/lib/src/state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class GoRouterState {
///
/// This method cannot be called during [GoRoute.pageBuilder] or
/// [ShellRoute.pageBuilder] since there is no [GoRouterState] to be
/// associated with.
/// associated with yet.
///
/// To access GoRouterState from a widget.
///
Expand All @@ -116,26 +116,41 @@ class GoRouterState {
/// }
/// ```
static GoRouterState of(BuildContext context) {
final ModalRoute<Object?>? route = ModalRoute.of(context);
if (route == null) {
throw GoError('There is no modal route above the current context.');
}
final RouteSettings settings = route.settings;
if (settings is! Page<Object?>) {
throw GoError(
'The parent route must be a page route to have a GoRouterState');
}
final GoRouterStateRegistryScope? scope = context
.dependOnInheritedWidgetOfExactType<GoRouterStateRegistryScope>();
if (scope == null) {
throw GoError(
'There is no GoRouterStateRegistryScope above the current context.');
ModalRoute<Object?>? route;
GoRouterStateRegistryScope? scope;
while (true) {
route = ModalRoute.of(context);
if (route == null) {
throw _noGoRouterStateError;
}
final RouteSettings settings = route.settings;
if (settings is Page<Object?>) {
scope = context
.dependOnInheritedWidgetOfExactType<GoRouterStateRegistryScope>();
if (scope == null) {
throw _noGoRouterStateError;
}
final GoRouterState? state = scope.notifier!
._createPageRouteAssociation(
route.settings as Page<Object?>, route);
if (state != null) {
return state;
}
}
final NavigatorState? state = Navigator.maybeOf(context);
if (state == null) {
throw _noGoRouterStateError;
}
context = state.context;
}
final GoRouterState state =
scope.notifier!._createPageRouteAssociation(settings, route);
return state;
}

static GoError get _noGoRouterStateError => GoError(
'There is no GoRouterState above the current context. '
'This method should only be called under the sub tree of a '
'RouteBase.builder.',
);

/// Get a location from route name and parameters.
/// This is useful for redirecting to a named location.
String namedLocation(
Expand Down Expand Up @@ -207,10 +222,12 @@ class GoRouterStateRegistry extends ChangeNotifier {
final Map<Route<Object?>, Page<Object?>> _routePageAssociation =
<ModalRoute<Object?>, Page<Object?>>{};

GoRouterState _createPageRouteAssociation(
GoRouterState? _createPageRouteAssociation(
Page<Object?> page, ModalRoute<Object?> route) {
assert(route.settings == page);
assert(registry.containsKey(page));
if (!registry.containsKey(page)) {
return null;
}
final Page<Object?>? oldPage = _routePageAssociation[route];
if (oldPage == null) {
// This is a new association.
Expand Down
2 changes: 1 addition & 1 deletion packages/go_router/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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.2.0
version: 14.2.1
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

Expand Down
33 changes: 33 additions & 0 deletions packages/go_router/test/go_router_state_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,39 @@ void main() {
expect(find.byKey(key), findsNothing);
});

testWidgets(
'GoRouterState look up should be resilient when there is a nested navigator.',
(WidgetTester tester) async {
final List<GoRoute> routes = <GoRoute>[
GoRoute(
path: '/',
builder: (_, __) {
return Scaffold(
appBar: AppBar(),
body: Navigator(
pages: <Page<void>>[
MaterialPage<void>(
child: Builder(
builder: (BuildContext context) {
return Center(
child: Text(GoRouterState.of(context).uri.toString()),
);
},
),
),
],
onPopPage: (Route<Object?> route, Object? result) {
throw UnimplementedError();
},
),
);
},
)
];
await createRouter(routes, tester);
expect(find.text('/'), findsOneWidget);
});

testWidgets('GoRouterState topRoute accessible from StatefulShellRoute',
(WidgetTester tester) async {
final GlobalKey<NavigatorState> rootNavigatorKey =
Expand Down
3 changes: 2 additions & 1 deletion packages/palette_generator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT
## 0.3.3+4

* Makes the example app compatible with the `web`.
* Updates minimum supported SDK version to Flutter 3.16/Dart 3.2.

## 0.3.3+3
Expand Down
2 changes: 2 additions & 0 deletions packages/palette_generator/dart_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# TODO(dit): Reenable web tests and remove this file, https://github.com/flutter/flutter/issues/151498
test_on: vm
40 changes: 29 additions & 11 deletions packages/palette_generator/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -275,17 +275,20 @@ class PaletteSwatch extends StatelessWidget {
fallbackHeight: 20.0,
color: Color(0xff404040),
)
: Container(
decoration: BoxDecoration(
color: color,
border: Border.all(
color: _kPlaceholderColor,
style: colorDistance < 0.2
? BorderStyle.solid
: BorderStyle.none,
)),
width: 34.0,
height: 20.0,
: Tooltip(
message: color!.toRGB(),
child: Container(
decoration: BoxDecoration(
color: color,
border: Border.all(
color: _kPlaceholderColor,
style: colorDistance < 0.2
? BorderStyle.solid
: BorderStyle.none,
)),
width: 34.0,
height: 20.0,
),
),
);

Expand All @@ -304,3 +307,18 @@ class PaletteSwatch extends StatelessWidget {
return swatch;
}
}

/// Converts a [Color] into a #RRGGBB string.
extension on Color {
String toRGB() {
// In the example all alphas are 255, so no need to show it.
return '#${red.toHex()}${green.toHex()}${blue.toHex()}';
}
}

/// Converts an [int] to a uppercase hexadecimal string of at least [minDigits] length.
extension on int {
String toHex([int minDigits = 2]) {
return toRadixString(16).toUpperCase().padLeft(minDigits, '0');
}
}
Binary file added packages/palette_generator/example/web/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions packages/palette_generator/example/web/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<!-- 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. -->
<html>
<head>
<base href="$FLUTTER_BASE_HREF">

<meta charset="UTF-8">
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
<meta name="description" content="Flutter Palette Generator example app.">

<!-- iOS meta tags & icons -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-title" content="example">
<link rel="apple-touch-icon" href="icons/Icon-192.png">

<!-- Favicon -->
<link rel="icon" type="image/png" href="favicon.png"/>

<title>Image Colors</title>
<link rel="manifest" href="manifest.json">
</head>
<body>
<script src="flutter_bootstrap.js" async></script>
</body>
</html>
35 changes: 35 additions & 0 deletions packages/palette_generator/example/web/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "Flutter Palette Generator example app",
"short_name": "Palette Generator Example",
"start_url": ".",
"display": "standalone",
"background_color": "#0175C2",
"theme_color": "#0175C2",
"description": "A demonstration of the Palette Generator Flutter package.",
"orientation": "portrait-primary",
"prefer_related_applications": false,
"icons": [
{
"src": "icons/Icon-192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "icons/Icon-512.png",
"sizes": "512x512",
"type": "image/png"
},
{
"src": "icons/Icon-maskable-192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "maskable"
},
{
"src": "icons/Icon-maskable-512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "maskable"
}
]
}
2 changes: 1 addition & 1 deletion packages/palette_generator/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: palette_generator
description: Flutter package for generating palette colors from a source image.
repository: https://github.com/flutter/packages/tree/main/packages/palette_generator
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+palette_generator%22
version: 0.3.3+3
version: 0.3.3+4

environment:
sdk: ^3.2.0
Expand Down
Loading

0 comments on commit 5978b00

Please sign in to comment.