Unverified Commit 4a094de2 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

[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.
parent 5fc6b871
...@@ -569,7 +569,7 @@ class ArchivePublisher { ...@@ -569,7 +569,7 @@ class ArchivePublisher {
/// ///
/// Archives contain the executables and customizations for the platform that /// Archives contain the executables and customizations for the platform that
/// they are created on. /// they are created on.
Future<void> main(List<String> argList) async { Future<void> main(List<String> rawArguments) async {
final ArgParser argParser = ArgParser(); final ArgParser argParser = ArgParser();
argParser.addOption( argParser.addOption(
'temp_dir', 'temp_dir',
...@@ -612,9 +612,9 @@ Future<void> main(List<String> argList) async { ...@@ -612,9 +612,9 @@ Future<void> main(List<String> argList) async {
help: 'Print help for this command.', 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); print(argParser.usage);
exit(0); exit(0);
} }
...@@ -625,7 +625,7 @@ Future<void> main(List<String> argList) async { ...@@ -625,7 +625,7 @@ Future<void> main(List<String> argList) async {
exit(exitCode); exit(exitCode);
} }
final String revision = args['revision']; final String revision = parsedArguments['revision'];
if (revision.isEmpty) { if (revision.isEmpty) {
errorExit('Invalid argument: --revision must be specified.'); errorExit('Invalid argument: --revision must be specified.');
} }
...@@ -633,40 +633,40 @@ Future<void> main(List<String> argList) async { ...@@ -633,40 +633,40 @@ Future<void> main(List<String> argList) async {
errorExit('Invalid argument: --revision must be the entire hash, not just a prefix.'); 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.'); errorExit('Invalid argument: --branch must be specified.');
} }
Directory tempDir; Directory tempDir;
bool removeTempDir = false; 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.'); tempDir = Directory.systemTemp.createTempSync('flutter_package.');
removeTempDir = true; removeTempDir = true;
} else { } else {
tempDir = Directory(args['temp_dir']); tempDir = Directory(parsedArguments['temp_dir']);
if (!tempDir.existsSync()) { if (!tempDir.existsSync()) {
errorExit("Temporary directory ${args['temp_dir']} doesn't exist."); errorExit("Temporary directory ${parsedArguments['temp_dir']} doesn't exist.");
} }
} }
Directory outputDir; Directory outputDir;
if (args['output'] == null) { if (parsedArguments['output'] == null) {
outputDir = tempDir; outputDir = tempDir;
} else { } else {
outputDir = Directory(args['output']); outputDir = Directory(parsedArguments['output']);
if (!outputDir.existsSync()) { if (!outputDir.existsSync()) {
outputDir.createSync(recursive: true); outputDir.createSync(recursive: true);
} }
} }
final Branch branch = fromBranchName(args['branch']); final Branch branch = fromBranchName(parsedArguments['branch']);
final ArchiveCreator creator = ArchiveCreator(tempDir, outputDir, revision, branch); final ArchiveCreator creator = ArchiveCreator(tempDir, outputDir, revision, branch);
int exitCode = 0; int exitCode = 0;
String message; String message;
try { try {
final String version = await creator.initializeRepo(); final String version = await creator.initializeRepo();
final File outputFile = await creator.createArchive(); final File outputFile = await creator.createArchive();
if (args['publish']) { if (parsedArguments['publish']) {
final ArchivePublisher publisher = ArchivePublisher( final ArchivePublisher publisher = ArchivePublisher(
tempDir, tempDir,
revision, revision,
......
...@@ -168,6 +168,36 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget { ...@@ -168,6 +168,36 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget {
/// widget with an [IconButton] that opens the drawer (using [Icons.menu]). If /// 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] /// there's no [Drawer] and the parent [Navigator] can go back, the [AppBar]
/// will use a [BackButton] that calls [Navigator.maybePop]. /// 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; final Widget leading;
/// Controls whether we should try to imply the leading widget if null. /// Controls whether we should try to imply the leading widget if null.
......
...@@ -355,14 +355,14 @@ abstract class ScrollView extends StatelessWidget { ...@@ -355,14 +355,14 @@ abstract class ScrollView extends StatelessWidget {
/// generated semantics of each scrollable item with a semantic index. This can /// generated semantics of each scrollable item with a semantic index. This can
/// be done by wrapping the child widgets in an [IndexedSemantics]. /// be done by wrapping the child widgets in an [IndexedSemantics].
/// ///
/// This semantic index is not necesarily the same as the index of the widget /// This semantic index is not necesarily the same as the index of the widget in
/// in the scrollable, because some widgets may not contribute semantic /// the scrollable, because some widgets may not contribute semantic
/// information. Consider a [new ListView.separated()], every other widget is a /// information. Consider a [new ListView.separated()]: every other widget is a
/// divider with no semantic information. In this case, only odd numbered /// divider with no semantic information. In this case, only odd numbered
/// widgets have a semantic index (equal to the index ~/ 2). Furthermore, the /// 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 /// total number of children in this example would be half the number of
/// widgets. Note that [new ListView.separated()] handles this automatically /// widgets. (The [new ListView.separated()] constructor handles this
/// and is only used here as an example. /// automatically; this is only used here as an example.)
/// ///
/// The total number of visible children can be provided by the constructor /// The total number of visible children can be provided by the constructor
/// parameter `semanticChildCount`. This should always be the same as the /// parameter `semanticChildCount`. This should always be the same as the
......
...@@ -61,4 +61,30 @@ void main() { ...@@ -61,4 +61,30 @@ void main() {
expect(box.size, equals(const Size(400.0, 300.0))); 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))); 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)));
});
} }
...@@ -41,7 +41,8 @@ void main() { ...@@ -41,7 +41,8 @@ void main() {
equals('/home/me/.AndroidStudioWithCheese5.0/config/plugins')); equals('/home/me/.AndroidStudioWithCheese5.0/config/plugins'));
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FileSystem: () => fs, 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(), Platform: () => linuxPlatform(),
}); });
}); });
......
...@@ -23,7 +23,8 @@ void main() { ...@@ -23,7 +23,8 @@ void main() {
final NoAndroidStudioValidator validator = NoAndroidStudioValidator(); final NoAndroidStudioValidator validator = NoAndroidStudioValidator();
expect((await validator.validate()).type, equals(ValidationType.notAvailable)); expect((await validator.validate()).type, equals(ValidationType.notAvailable));
}, overrides: <Type, Generator>{ }, 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(), Platform: () => linuxPlatform(),
}); });
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment