[H] Cleanup (#23632)
* Avoid abbreviations
* Sample code for AppBar.leading
* Add a test for OverflowBox/FractionallySizedBox
* Minor wording improvements in the text.
The words "note that" here don't really contribute to the flow.
diff --git a/dev/bots/prepare_package.dart b/dev/bots/prepare_package.dart
index ec7f52f..34464a9 100644
--- a/dev/bots/prepare_package.dart
+++ b/dev/bots/prepare_package.dart
@@ -569,7 +569,7 @@
///
/// Archives contain the executables and customizations for the platform that
/// they are created on.
-Future<void> main(List<String> argList) async {
+Future<void> main(List<String> rawArguments) async {
final ArgParser argParser = ArgParser();
argParser.addOption(
'temp_dir',
@@ -612,9 +612,9 @@
help: 'Print help for this command.',
);
- final ArgResults args = argParser.parse(argList);
+ final ArgResults parsedArguments = argParser.parse(rawArguments);
- if (args['help']) {
+ if (parsedArguments['help']) {
print(argParser.usage);
exit(0);
}
@@ -625,7 +625,7 @@
exit(exitCode);
}
- final String revision = args['revision'];
+ final String revision = parsedArguments['revision'];
if (revision.isEmpty) {
errorExit('Invalid argument: --revision must be specified.');
}
@@ -633,40 +633,40 @@
errorExit('Invalid argument: --revision must be the entire hash, not just a prefix.');
}
- if (args['branch'].isEmpty) {
+ if (parsedArguments['branch'].isEmpty) {
errorExit('Invalid argument: --branch must be specified.');
}
Directory tempDir;
bool removeTempDir = false;
- if (args['temp_dir'] == null || args['temp_dir'].isEmpty) {
+ if (parsedArguments['temp_dir'] == null || parsedArguments['temp_dir'].isEmpty) {
tempDir = Directory.systemTemp.createTempSync('flutter_package.');
removeTempDir = true;
} else {
- tempDir = Directory(args['temp_dir']);
+ tempDir = Directory(parsedArguments['temp_dir']);
if (!tempDir.existsSync()) {
- errorExit("Temporary directory ${args['temp_dir']} doesn't exist.");
+ errorExit("Temporary directory ${parsedArguments['temp_dir']} doesn't exist.");
}
}
Directory outputDir;
- if (args['output'] == null) {
+ if (parsedArguments['output'] == null) {
outputDir = tempDir;
} else {
- outputDir = Directory(args['output']);
+ outputDir = Directory(parsedArguments['output']);
if (!outputDir.existsSync()) {
outputDir.createSync(recursive: true);
}
}
- final Branch branch = fromBranchName(args['branch']);
+ final Branch branch = fromBranchName(parsedArguments['branch']);
final ArchiveCreator creator = ArchiveCreator(tempDir, outputDir, revision, branch);
int exitCode = 0;
String message;
try {
final String version = await creator.initializeRepo();
final File outputFile = await creator.createArchive();
- if (args['publish']) {
+ if (parsedArguments['publish']) {
final ArchivePublisher publisher = ArchivePublisher(
tempDir,
revision,
diff --git a/packages/flutter/lib/src/material/app_bar.dart b/packages/flutter/lib/src/material/app_bar.dart
index b3883ae..f535d11 100644
--- a/packages/flutter/lib/src/material/app_bar.dart
+++ b/packages/flutter/lib/src/material/app_bar.dart
@@ -168,6 +168,36 @@
/// widget with an [IconButton] that opens the drawer (using [Icons.menu]). If
/// there's no [Drawer] and the parent [Navigator] can go back, the [AppBar]
/// will use a [BackButton] that calls [Navigator.maybePop].
+ ///
+ /// ## Sample code
+ ///
+ /// The following code shows how the drawer button could be manually specified
+ /// instead of relying on [automaticallyImplyLeading]:
+ ///
+ /// ```dart
+ /// AppBar(
+ /// leading: Builder(
+ /// builder: (BuildContext context) {
+ /// return IconButton(
+ /// icon: const Icon(Icons.menu),
+ /// onPressed: () { Scaffold.of(context).openDrawer(); },
+ /// tooltip: MaterialLocalizations.of(context).openAppDrawerTooltip,
+ /// );
+ /// },
+ /// ),
+ /// )
+ /// ```
+ ///
+ /// The [Builder] is used in this example to ensure that the `context` refers
+ /// to that part of the subtree. That way this code snippet can be used even
+ /// inside the very code that is creating the [Scaffold] (in which case,
+ /// without the [Builder], the `context` wouldn't be able to see the
+ /// [Scaffold], since it would refer to an ancestor of that widget).
+ ///
+ /// See also:
+ ///
+ /// * [Scaffold.appBar], in which an [AppBar] is usually placed.
+ /// * [Scaffold.drawer], in which the [Drawer] is usually placed.
final Widget leading;
/// Controls whether we should try to imply the leading widget if null.
diff --git a/packages/flutter/lib/src/widgets/scroll_view.dart b/packages/flutter/lib/src/widgets/scroll_view.dart
index 85a7260..4225732 100644
--- a/packages/flutter/lib/src/widgets/scroll_view.dart
+++ b/packages/flutter/lib/src/widgets/scroll_view.dart
@@ -355,14 +355,14 @@
/// generated semantics of each scrollable item with a semantic index. This can
/// be done by wrapping the child widgets in an [IndexedSemantics].
///
-/// This semantic index is not necesarily the same as the index of the widget
-/// in the scrollable, because some widgets may not contribute semantic
-/// information. Consider a [new ListView.separated()], every other widget is a
+/// This semantic index is not necesarily the same as the index of the widget in
+/// the scrollable, because some widgets may not contribute semantic
+/// information. Consider a [new ListView.separated()]: every other widget is a
/// divider with no semantic information. In this case, only odd numbered
/// widgets have a semantic index (equal to the index ~/ 2). Furthermore, the
/// total number of children in this example would be half the number of
-/// widgets. Note that [new ListView.separated()] handles this automatically
-/// and is only used here as an example.
+/// widgets. (The [new ListView.separated()] constructor handles this
+/// automatically; this is only used here as an example.)
///
/// The total number of visible children can be provided by the constructor
/// parameter `semanticChildCount`. This should always be the same as the
diff --git a/packages/flutter/test/widgets/fractionally_sized_box_test.dart b/packages/flutter/test/widgets/fractionally_sized_box_test.dart
index 006572e..b0579d7 100644
--- a/packages/flutter/test/widgets/fractionally_sized_box_test.dart
+++ b/packages/flutter/test/widgets/fractionally_sized_box_test.dart
@@ -61,4 +61,30 @@
expect(box.size, equals(const Size(400.0, 300.0)));
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(0.0 + 400.0 / 2.0, 0.0 + 300.0 / 2.0)));
});
+
+ testWidgets('OverflowBox alignment with FractionallySizedBox', (WidgetTester tester) async {
+ final GlobalKey inner = GlobalKey();
+ await tester.pumpWidget(Directionality(
+ textDirection: TextDirection.rtl,
+ child: OverflowBox(
+ minWidth: 0.0,
+ maxWidth: 100.0,
+ minHeight: 0.0,
+ maxHeight: 100.0,
+ alignment: const AlignmentDirectional(1.0, -1.0),
+ child: Center(
+ child: FractionallySizedBox(
+ widthFactor: 0.5,
+ heightFactor: 0.25,
+ child: Container(
+ key: inner
+ ),
+ ),
+ ),
+ ),
+ ));
+ final RenderBox box = inner.currentContext.findRenderObject();
+ expect(box.size, equals(const Size(50.0, 25.0)));
+ expect(box.localToGlobal(Offset.zero), equals(const Offset(25.0, 37.5)));
+ });
}
diff --git a/packages/flutter_tools/test/android/android_studio_test.dart b/packages/flutter_tools/test/android/android_studio_test.dart
index 0272992..20ba39c 100644
--- a/packages/flutter_tools/test/android/android_studio_test.dart
+++ b/packages/flutter_tools/test/android/android_studio_test.dart
@@ -41,7 +41,8 @@
equals('/home/me/.AndroidStudioWithCheese5.0/config/plugins'));
}, overrides: <Type, Generator>{
FileSystem: () => fs,
- // Note that custom home paths are not supported on macOS nor Windows yet:
+ // Custom home paths are not supported on macOS nor Windows yet,
+ // so we force the platform to fake Linux here.
Platform: () => linuxPlatform(),
});
});
diff --git a/packages/flutter_tools/test/android/android_studio_validator_test.dart b/packages/flutter_tools/test/android/android_studio_validator_test.dart
index 3fe1849..138996e 100644
--- a/packages/flutter_tools/test/android/android_studio_validator_test.dart
+++ b/packages/flutter_tools/test/android/android_studio_validator_test.dart
@@ -23,7 +23,8 @@
final NoAndroidStudioValidator validator = NoAndroidStudioValidator();
expect((await validator.validate()).type, equals(ValidationType.notAvailable));
}, overrides: <Type, Generator>{
- // Note that custom home paths are not supported on macOS nor Windows yet:
+ // Custom home paths are not supported on macOS nor Windows yet,
+ // so we force the platform to fake Linux here.
Platform: () => linuxPlatform(),
});
});