commit | c2393453ce748020e2019340433930520144703e | [log] [tgz] |
---|---|---|
author | Ben Konyi <bkonyi@google.com> | Fri May 02 15:28:17 2025 -0400 |
committer | dart-internal-monorepo <dart-internal-monorepo@dart-ci-internal.iam.gserviceaccount.com> | Fri May 02 16:33:09 2025 -0700 |
tree | 3d1bc112d20b080e602c1d15b468caff8a098227 | |
parent | 3f0565a60c527c8f78afe093d1c9b5f2d0f6fb90 [diff] |
[ Widget Preview ] Improve widget inspector support for widget previews (#168013) In order to prevent the widget inspector from being able to select and inspect elements of the widget previewer's scaffolding, this commit consists of two notable changes: 1) A `debugWillManuallyInjectWidgetInspector` property has been added to `WidgetsBinding`. Setting this property to true before running the application will prevent `WidgetsApp` from injecting a `WidgetInspector` instance into the widget tree, even if the widget inspector is enabled. This means that the widget inspector will not be able to select and highlight widgets by default, requiring `WidgetInspector` to be manually wrapped around widget trees that should be inspectable. 2) The widget_preview_scaffold template has been updated to set `debugWillManuallyInjectWidgetInspector` to true by default, and to wrap individual previews provided by the developer with an instance of `WidgetInspector` to restrict widget inspection to the contents of the preview. This change also includes a minor bug fix for situations where `WidgetInspector` is inserted into an unconstrained context. Previously, the `WidgetInspector`'s `_InspectorOverlay` would attempt to take up as much space as possible, causing an overflow. To fix this, the `_InspectorOverlay` is wrapped with `Positioned.fill(...)` to force it to take on the same size as its parent `Stack`. Work towards https://github.com/flutter/flutter/issues/166423 **Demo:** https://github.com/user-attachments/assets/6d9d384c-5470-4828-983d-a6d9051a2282 https://dart.googlesource.com/external/github.com/flutter/flutter/+/e3db1bb721f274197805f25366da4a389b5a910c
Monorepo is:
With depot_tools installed and on your path, create a directory for your monorepo checkout and run these commands to create a gclient solution in that directory:
mkdir monorepo cd monorepo gclient config --unmanaged https://dart.googlesource.com/monorepo gclient sync -D
This gives you a checkout in the monorepo directory that contains:
monorepo/ DEPS - the DEPS used for this gclient checkout commits.json - the pinned commits for Dart, flutter/engine, and flutter/flutter tools/ - scripts used to create monorepo DEPS engine/src/ - the flutter/buildroot repo flutter/ - the flutter/engine repo out/ - the build directory, where Flutter engine builds are created third_party/ - Flutter dependencies checked out by DEPS dart/ - the Dart SDK checkout. third_party - Dart dependencies, also used by Flutter flutter/ - the flutter/flutter repo
Flutter's instructions for building the engine are at Compiling the engine
They can be followed closely, with a few changes:
goma_ctl ensure_start
is sufficient.Example build commands that work on linux:
MONOREPO_PATH=$PWD if [[ ! $PATH =~ (^|:)$MONOREPO_PATH/flutter/bin(:|$) ]]; then PATH=$MONOREPO_PATH/flutter/bin:$PATH fi export GOMA_DIR=$(dirname $(command -v gclient))/.cipd_bin goma_ctl ensure_start pushd engine/src flutter/tools/gn --goma --no-prebuilt-dart-sdk --unoptimized --full-dart-sdk autoninja -C out/host_debug_unopt popd
The Flutter commands used to build and run apps will use the locally built Flutter engine and Dart SDK, instead of the one downloaded by the Flutter tool, if the --local-engine
option is provided.
For example, to build and run the Flutter spinning square sample on the web platform,
MONOREPO_PATH=$PWD cd flutter/examples/layers flutter --local-engine=host_debug_unopt \ -d chrome run widgets/spinning_square.dart cd $MONOREPO_PATH
To build for desktop, specify the desktop platform device in flutter run
as -d macos
or -d linux
or -d windows
. You may also need to run the command
flutter create --platforms=windows,macos,linux
on existing apps, such as sample apps. New apps created with flutter create
already include these support files. Details of desktop support are at Desktop Support for Flutter
Tests in the Flutter source tree can be run with the flutter test
command, run in the directory of a package containing tests. For example:
MONOREPO_PATH=$PWD cd flutter/packages/flutter flutter test --local-engine=host_debug_unopt cd $MONOREPO_PATH
Please file an issue or email the dart-engprod team with any problems with or questions about using monorepo.
We will update this documentation to address them.
flutter
commands may download the engine and Dart SDK files for the configured channel, even though they will be using the local engine and its SDK.gclient sync
needs to be run in an administrator session, because some installed dependencies create symlinks.