Skip to content

Commit 54ba8d6

Browse files
Hixiegspencergoog
authored andcommitted
More documentation. (flutter#10953)
Applies comments I missed from flutter#10904.
1 parent 0e17d04 commit 54ba8d6

File tree

5 files changed

+115
-7
lines changed

5 files changed

+115
-7
lines changed

dev/bots/analyze-sample-code.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ Future<Null> main() async {
120120
assert(block.isEmpty);
121121
startLine = new Line(file.path, lineNumber + 1, 3);
122122
inPreamble = true;
123-
} else if (trimmedLine == '/// ## Sample code') {
123+
} else if (trimmedLine == '/// ## Sample code' || trimmedLine == '/// ### Sample code') {
124124
inSampleSection = true;
125125
foundDart = false;
126126
sampleCodeSections += 1;

packages/flutter/lib/src/rendering/sliver_grid.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ class SliverGridDelegateWithFixedCrossAxisCount extends SliverGridDelegate {
325325
}
326326
}
327327

328-
/// Creates grid layouts with tiles that have a maximum cross-axis extent.
328+
/// Creates grid layouts with tiles that each have a maximum cross-axis extent.
329329
///
330330
/// This delegate will select a cross-axis extent for the tiles that is as
331331
/// large as possible subject to the following conditions:

packages/flutter/lib/src/widgets/image.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,22 @@ class Image extends StatefulWidget {
172172
/// directory with the name `cat.png` (the paths are relative to the
173173
/// `pubspec.yaml` file).
174174
///
175+
/// On a device with a 4.0 device pixel ratio, the `images/3.5x/cat.png` asset
176+
/// would be used. On a device with a 1.0 device pixel ratio, the
177+
/// `images/cat.png` resource would be used.
178+
///
179+
/// The `images/cat.png` image can be omitted from disk (though it must still
180+
/// be present in the manifest). If it is omitted, then on a device with a 1.0
181+
/// device pixel ratio, the `images/2x/cat.png` image would be used instead.
182+
///
175183
/// See also:
176184
///
177185
/// * [AssetImage], which is used to implement the behavior when the scale is
178186
/// omitted.
179187
/// * [ExactAssetImage], which is used to implement the behavior when the
180188
/// scale is present.
189+
/// * <https://flutter.io/assets-and-images/>, an introduction to assets in
190+
/// Flutter.
181191
Image.asset(String name, {
182192
Key key,
183193
AssetBundle bundle,

packages/flutter/lib/src/widgets/scroll_view.dart

Lines changed: 91 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,45 @@ abstract class BoxScrollView extends ScrollView {
454454
/// [SliverGrid] or [SliverAppBar], can be put in the [CustomScrollView.slivers]
455455
/// list.
456456
///
457+
/// ### Sample code
458+
///
459+
/// Here are two brief snippets showing a [ListView] and its equivalent using
460+
/// [CustomScrollView]:
461+
///
462+
/// ```dart
463+
/// new ListView(
464+
/// shrinkWrap: true,
465+
/// padding: const EdgeInsets.all(20.0),
466+
/// children: <Widget>[
467+
/// const Text('I\'m dedicating every day to you'),
468+
/// const Text('Domestic life was never quite my style'),
469+
/// const Text('When you smile, you knock me out, I fall apart'),
470+
/// const Text('And I thought I was so smart'),
471+
/// ],
472+
/// )
473+
/// ```
474+
///
475+
/// ```dart
476+
/// new CustomScrollView(
477+
/// shrinkWrap: true,
478+
/// slivers: <Widget>[
479+
/// new SliverPadding(
480+
/// padding: const EdgeInsets.all(20.0),
481+
/// sliver: new SliverList(
482+
/// delegate: new SliverChildListDelegate(
483+
/// <Widget>[
484+
/// const Text('I\'m dedicating every day to you'),
485+
/// const Text('Domestic life was never quite my style'),
486+
/// const Text('When you smile, you knock me out, I fall apart'),
487+
/// const Text('And I thought I was so smart'),
488+
/// ],
489+
/// ),
490+
/// ),
491+
/// ),
492+
/// ],
493+
/// )
494+
/// ```
495+
///
457496
/// See also:
458497
///
459498
/// * [SingleChildScrollView], which is a scrollable widget that has a single
@@ -603,10 +642,13 @@ class ListView extends BoxScrollView {
603642

604643
/// A scrollable, 2D array of widgets.
605644
///
645+
/// The main axis direction of a grid is the direction in which it scrolls (the
646+
/// [scrollDirection]).
647+
///
606648
/// The most commonly used grid layouts are [GridView.count], which creates a
607649
/// layout with a fixed number of tiles in the cross axis, and
608650
/// [GridView.extent], which creates a layout with tiles that have a maximum
609-
/// cross-axis extent. A custom [SliverGridDelegate] can produce an aribtrary 2D
651+
/// cross-axis extent. A custom [SliverGridDelegate] can produce an arbitrary 2D
610652
/// arrangement of children, including arrangements that are unaligned or
611653
/// overlapping.
612654
///
@@ -657,9 +699,54 @@ class ListView extends BoxScrollView {
657699
/// the [SliverGrid] instead be a child of the [SliverPadding].
658700
///
659701
/// Once code has been ported to use [CustomScrollView], other slivers, such as
660-
/// [SliverGrid] or [SliverAppBar], can be put in the [CustomScrollView.slivers]
702+
/// [SliverList] or [SliverAppBar], can be put in the [CustomScrollView.slivers]
661703
/// list.
662704
///
705+
/// ### Sample code
706+
///
707+
/// Here are two brief snippets showing a [GridView] and its equivalent using
708+
/// [CustomScrollView]:
709+
///
710+
/// ```dart
711+
/// new GridView.count(
712+
/// primary: false,
713+
/// padding: const EdgeInsets.all(20.0),
714+
/// crossAxisSpacing: 10.0,
715+
/// crossAxisCount: 2,
716+
/// children: <Widget>[
717+
/// const Text('He\'d have you all unravel at the'),
718+
/// const Text('Heed not the rabble'),
719+
/// const Text('Sound of screams but the'),
720+
/// const Text('Who scream'),
721+
/// const Text('Revolution is coming...'),
722+
/// const Text('Revolution, they...'),
723+
/// ],
724+
/// )
725+
/// ```
726+
///
727+
/// ```dart
728+
/// new CustomScrollView(
729+
/// primary: false,
730+
/// slivers: <Widget>[
731+
/// new SliverPadding(
732+
/// padding: const EdgeInsets.all(20.0),
733+
/// sliver: new SliverGrid.count(
734+
/// crossAxisSpacing: 10.0,
735+
/// crossAxisCount: 2,
736+
/// children: <Widget>[
737+
/// const Text('He\'d have you all unravel at the'),
738+
/// const Text('Heed not the rabble'),
739+
/// const Text('Sound of screams but the'),
740+
/// const Text('Who scream'),
741+
/// const Text('Revolution is coming...'),
742+
/// const Text('Revolution, they...'),
743+
/// ],
744+
/// ),
745+
/// ),
746+
/// ],
747+
/// )
748+
/// ```
749+
///
663750
/// See also:
664751
///
665752
/// * [SingleChildScrollView], which is a scrollable widget that has a single
@@ -810,8 +897,8 @@ class GridView extends BoxScrollView {
810897
padding: padding,
811898
);
812899

813-
/// Creates a scrollable, 2D array of widgets with tiles that have a maximum
814-
/// cross-axis extent.
900+
/// Creates a scrollable, 2D array of widgets with tiles that each have a
901+
/// maximum cross-axis extent.
815902
///
816903
/// Uses a [SliverGridDelegateWithMaxCrossAxisExtent] as the [gridDelegate].
817904
///

packages/flutter/lib/src/widgets/sliver.dart

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,9 @@ class SliverFixedExtentList extends SliverMultiBoxAdaptorWidget {
393393
/// [gridDelegate]. Each child is forced to have the size specified by the
394394
/// [gridDelegate].
395395
///
396+
/// The main axis direction of a grid is the direction in which it scrolls; the
397+
/// cross axis direction is the orthogonal direction.
398+
///
396399
/// ## Sample code
397400
///
398401
/// This example, which would be inserted into a [CustomScrollView.slivers]
@@ -441,6 +444,10 @@ class SliverGrid extends SliverMultiBoxAdaptorWidget {
441444
///
442445
/// Uses a [SliverGridDelegateWithFixedCrossAxisCount] as the [gridDelegate],
443446
/// and a [SliverChildListDelegate] as the [delegate].
447+
///
448+
/// See also:
449+
///
450+
/// * [new GridView.count], the equivalent constructor for [GridView] widgets.
444451
SliverGrid.count({
445452
Key key,
446453
@required int crossAxisCount,
@@ -457,10 +464,14 @@ class SliverGrid extends SliverMultiBoxAdaptorWidget {
457464
super(key: key, delegate: new SliverChildListDelegate(children));
458465

459466
/// Creates a sliver that places multiple box children in a two dimensional
460-
/// arrangement with tiles that have a maximum cross-axis extent.
467+
/// arrangement with tiles that each have a maximum cross-axis extent.
461468
///
462469
/// Uses a [SliverGridDelegateWithMaxCrossAxisExtent] as the [gridDelegate],
463470
/// and a [SliverChildListDelegate] as the [delegate].
471+
///
472+
/// See also:
473+
///
474+
/// * [new GridView.extent], the equivalent constructor for [GridView] widgets.
464475
SliverGrid.extent({
465476
Key key,
466477
@required double maxCrossAxisExtent,

0 commit comments

Comments
 (0)