Skip to content

Commit dc83c49

Browse files
authored
Add some missing dartdocs (flutter#8819)
1 parent d87f198 commit dc83c49

File tree

7 files changed

+97
-36
lines changed

7 files changed

+97
-36
lines changed

packages/flutter/lib/src/foundation/serialization.dart

Lines changed: 52 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import 'package:typed_data/typed_buffers.dart' show Uint8Buffer;
1313
///
1414
/// The byte order used is [Endianness.HOST_ENDIAN] throughout.
1515
class WriteBuffer {
16+
/// Creates an interface for incrementally building a [ByteData] instance.
1617
WriteBuffer() {
1718
_buffer = new Uint8Buffer();
1819
_eightBytes = new ByteData(8);
@@ -23,49 +24,59 @@ class WriteBuffer {
2324
ByteData _eightBytes;
2425
Uint8List _eightBytesAsList;
2526

27+
/// Write a Uint8 into the buffer.
2628
void putUint8(int byte) {
2729
_buffer.add(byte);
2830
}
2931

32+
/// Write a Uint16 into the buffer.
3033
void putUint16(int value) {
3134
_eightBytes.setUint16(0, value, Endianness.HOST_ENDIAN);
3235
_buffer.addAll(_eightBytesAsList, 0, 2);
3336
}
3437

38+
/// Write a Uint32 into the buffer.
3539
void putUint32(int value) {
3640
_eightBytes.setUint32(0, value, Endianness.HOST_ENDIAN);
3741
_buffer.addAll(_eightBytesAsList, 0, 4);
3842
}
3943

44+
/// Write an Int32 into the buffer.
4045
void putInt32(int value) {
4146
_eightBytes.setInt32(0, value, Endianness.HOST_ENDIAN);
4247
_buffer.addAll(_eightBytesAsList, 0, 4);
4348
}
4449

50+
/// Write an Int64 into the buffer.
4551
void putInt64(int value) {
4652
_eightBytes.setInt64(0, value, Endianness.HOST_ENDIAN);
4753
_buffer.addAll(_eightBytesAsList, 0, 8);
4854
}
4955

56+
/// Write an Float64 into the buffer.
5057
void putFloat64(double value) {
5158
_eightBytes.setFloat64(0, value, Endianness.HOST_ENDIAN);
5259
_buffer.addAll(_eightBytesAsList);
5360
}
5461

62+
/// Write all the values from a [Uint8List] into the buffer.
5563
void putUint8List(Uint8List list) {
5664
_buffer.addAll(list);
5765
}
5866

67+
/// Write all the values from a [Int32List] into the buffer.
5968
void putInt32List(Int32List list) {
6069
_alignTo(4);
6170
_buffer.addAll(list.buffer.asUint8List(list.offsetInBytes, 4 * list.length));
6271
}
6372

73+
/// Write all the values from an [Int64List] into the buffer.
6474
void putInt64List(Int64List list) {
6575
_alignTo(8);
6676
_buffer.addAll(list.buffer.asUint8List(list.offsetInBytes, 8 * list.length));
6777
}
6878

79+
/// Write all the values from a [Float64List] into the buffer.
6980
void putFloat64List(Float64List list) {
7081
_alignTo(8);
7182
_buffer.addAll(list.buffer.asUint8List(list.offsetInBytes, 8 * list.length));
@@ -79,6 +90,7 @@ class WriteBuffer {
7990
}
8091
}
8192

93+
/// Finalize and return the written [ByteData].
8294
ByteData done() {
8395
final ByteData result = _buffer.buffer.asByteData(0, _buffer.lengthInBytes);
8496
_buffer = null;
@@ -90,80 +102,94 @@ class WriteBuffer {
90102
///
91103
/// The byte order used is [Endianness.HOST_ENDIAN] throughout.
92104
class ReadBuffer {
93-
final ByteData data;
94-
int position = 0;
95-
96105
/// Creates a [ReadBuffer] for reading from the specified [data].
97106
ReadBuffer(this.data) {
98107
assert(data != null);
99108
}
100109

110+
/// The underlying data being read.
111+
final ByteData data;
112+
113+
/// The position to read next.
114+
int _position = 0;
115+
116+
/// Whether the buffer has data remaining to read.
117+
bool get hasRemaining => _position < data.lengthInBytes;
118+
119+
/// Reads a Uint8 from the buffer.
101120
int getUint8() {
102-
return data.getUint8(position++);
121+
return data.getUint8(_position++);
103122
}
104123

124+
/// Reads a Uint16 from the buffer.
105125
int getUint16() {
106-
final int value = data.getUint16(position, Endianness.HOST_ENDIAN);
107-
position += 2;
126+
final int value = data.getUint16(_position, Endianness.HOST_ENDIAN);
127+
_position += 2;
108128
return value;
109129
}
110130

131+
/// Reads a Uint32 from the buffer.
111132
int getUint32() {
112-
final int value = data.getUint32(position, Endianness.HOST_ENDIAN);
113-
position += 4;
133+
final int value = data.getUint32(_position, Endianness.HOST_ENDIAN);
134+
_position += 4;
114135
return value;
115136
}
116137

138+
/// Reads an Int32 from the buffer.
117139
int getInt32() {
118-
final int value = data.getInt32(position, Endianness.HOST_ENDIAN);
119-
position += 4;
140+
final int value = data.getInt32(_position, Endianness.HOST_ENDIAN);
141+
_position += 4;
120142
return value;
121143
}
122144

145+
/// Reads an Int64 from the buffer.
123146
int getInt64() {
124-
final int value = data.getInt64(position, Endianness.HOST_ENDIAN);
125-
position += 8;
147+
final int value = data.getInt64(_position, Endianness.HOST_ENDIAN);
148+
_position += 8;
126149
return value;
127150
}
128151

152+
/// Reads a Float64 from the buffer.
129153
double getFloat64() {
130-
final double value = data.getFloat64(position, Endianness.HOST_ENDIAN);
131-
position += 8;
154+
final double value = data.getFloat64(_position, Endianness.HOST_ENDIAN);
155+
_position += 8;
132156
return value;
133157
}
134158

159+
/// Reads the given number of Uint8s from the buffer.
135160
Uint8List getUint8List(int length) {
136-
final Uint8List list = data.buffer.asUint8List(data.offsetInBytes + position, length);
137-
position += length;
161+
final Uint8List list = data.buffer.asUint8List(data.offsetInBytes + _position, length);
162+
_position += length;
138163
return list;
139164
}
140165

166+
/// Reads the given number of Int32s from the buffer.
141167
Int32List getInt32List(int length) {
142168
_alignTo(4);
143-
final Int32List list = data.buffer.asInt32List(data.offsetInBytes + position, length);
144-
position += 4 * length;
169+
final Int32List list = data.buffer.asInt32List(data.offsetInBytes + _position, length);
170+
_position += 4 * length;
145171
return list;
146172
}
147173

174+
/// Reads the given number of Int64s from the buffer.
148175
Int64List getInt64List(int length) {
149176
_alignTo(8);
150-
final Int64List list = data.buffer.asInt64List(data.offsetInBytes + position, length);
151-
position += 8 * length;
177+
final Int64List list = data.buffer.asInt64List(data.offsetInBytes + _position, length);
178+
_position += 8 * length;
152179
return list;
153180
}
154181

182+
/// Reads the given number of Float64s from the buffer.
155183
Float64List getFloat64List(int length) {
156184
_alignTo(8);
157-
final Float64List list = data.buffer.asFloat64List(data.offsetInBytes + position, length);
158-
position += 8 * length;
185+
final Float64List list = data.buffer.asFloat64List(data.offsetInBytes + _position, length);
186+
_position += 8 * length;
159187
return list;
160188
}
161189

162190
void _alignTo(int alignment) {
163-
final int mod = position % alignment;
191+
final int mod = _position % alignment;
164192
if (mod != 0)
165-
position += alignment - mod;
193+
_position += alignment - mod;
166194
}
167-
168-
bool get hasRemaining => position < data.lengthInBytes;
169195
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,16 @@ class BackdropFilterLayer extends ContainerLayer {
522522
}
523523
}
524524

525+
/// A composited layer that uses a physical model to producing lighting effects.
526+
///
527+
/// For example, the layer casts a shadow according to its geometry and the
528+
/// relative position of lights and other physically modelled objects in the
529+
/// scene.
525530
class PhysicalModelLayer extends ContainerLayer {
531+
/// Creates a composited layer that uses a physical model to producing
532+
/// lighting effects.
533+
///
534+
/// The [clipRRect], [elevation], and [color] arguments must not be null.
526535
PhysicalModelLayer({
527536
@required this.clipRRect,
528537
@required this.elevation,

packages/flutter/lib/src/services/message_codecs.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import 'message_codec.dart';
1111

1212
/// [MessageCodec] with unencoded binary messages represented using [ByteData].
1313
class BinaryCodec implements MessageCodec<ByteData> {
14+
/// Creates a [MessageCodec] with unencoded binary messages represented using
15+
/// [ByteData].
1416
const BinaryCodec();
1517

1618
@override
@@ -22,6 +24,7 @@ class BinaryCodec implements MessageCodec<ByteData> {
2224

2325
/// [MessageCodec] with UTF-8 encoded String messages.
2426
class StringCodec implements MessageCodec<String> {
27+
/// Creates a [MessageCodec] with UTF-8 encoded String messages.
2528
const StringCodec();
2629

2730
@override
@@ -54,6 +57,8 @@ class JSONMessageCodec implements MessageCodec<dynamic> {
5457
// The codec serializes messages as defined by the JSON codec of the
5558
// dart:convert package. The format used must match the Android and
5659
// iOS counterparts.
60+
61+
/// Creates a [MessageCodec] with UTF-8 encoded JSON messages.
5762
const JSONMessageCodec();
5863

5964
@override
@@ -72,6 +77,7 @@ class JSONMessageCodec implements MessageCodec<dynamic> {
7277
}
7378

7479
/// [MethodCodec] with UTF-8 encoded JSON method calls and result envelopes.
80+
///
7581
/// Values supported as method arguments and result payloads are those supported
7682
/// by [JSONMessageCodec].
7783
class JSONMethodCodec implements MethodCodec {
@@ -87,6 +93,9 @@ class JSONMethodCodec implements MethodCodec {
8793
// element, or
8894
// * three-element lists containing, in order, an error code String, an
8995
// error message String, and an error details value.
96+
97+
/// Creates a [MethodCodec] with UTF-8 encoded JSON method calls and result
98+
/// envelopes.
9099
const JSONMethodCodec();
91100

92101
@override
@@ -185,6 +194,7 @@ class StandardMessageCodec implements MessageCodec<dynamic> {
185194
static const int _kList = 12;
186195
static const int _kMap = 13;
187196

197+
/// Creates a [MessageCodec] using the Flutter standard binary encoding.
188198
const StandardMessageCodec();
189199

190200
@override
@@ -379,6 +389,7 @@ class StandardMethodCodec implements MethodCodec {
379389
// * In the error case, the concatenation of the encoding of the error code
380390
// string, the error message string, and the error details value.
381391

392+
/// Creates a [MethodCodec] using the Flutter standard binary encoding.
382393
const StandardMethodCodec();
383394

384395
@override

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2563,9 +2563,7 @@ abstract class Element implements BuildContext {
25632563
if (_dirty)
25642564
owner.scheduleBuildFor(this);
25652565
if (hadDependencies)
2566-
didChangeDependencies
2567-
2568-
();
2566+
didChangeDependencies();
25692567
}
25702568

25712569
/// Transition from the "active" to the "inactive" lifecycle state.
@@ -3047,9 +3045,9 @@ abstract class ComponentElement extends Element {
30473045
rebuild();
30483046
}
30493047

3050-
/// Calls the `build` method of the [StatelessWidget] object (for
3051-
/// stateless widgets) or the [State] object (for stateful widgets) and
3052-
/// then updates the widget tree.
3048+
/// Calls the [StatelessWidget.build] method of the [StatelessWidget] object
3049+
/// (for stateless widgets) or the [State.build] method of the [State] object
3050+
/// (for stateful widgets) and then updates the widget tree.
30533051
///
30543052
/// Called automatically during [mount] to generate the first build, and by
30553053
/// [rebuild] when the element needs updating.
@@ -3091,6 +3089,9 @@ abstract class ComponentElement extends Element {
30913089
});
30923090
}
30933091

3092+
/// Subclasses should override this function to actually call the appropriate
3093+
/// `build` function (e.g., [StatelessWidget.build] or [State.build]) for
3094+
/// their widget.
30943095
@protected
30953096
Widget build();
30963097

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,10 +416,13 @@ class _HeroFlight {
416416
class HeroController extends NavigatorObserver {
417417
/// Creates a hero controller with the given [RectTween] constructor if any.
418418
///
419-
/// The [createRectTween] argument is optional. If null, a linear
420-
/// [RectTween] is used.
419+
/// The [createRectTween] argument is optional. If null, the controller uses a
420+
/// linear [RectTween].
421421
HeroController({ this.createRectTween });
422422

423+
/// Used to create [RectTween]s that interpolate the position of heros in flight.
424+
///
425+
/// If null, the controller uses a linear [RectTween].
423426
final CreateRectTween createRectTween;
424427

425428
// Disable Hero animations while a user gesture is controlling the navigation.

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ Widget _defaultTransitionsBuilder(BuildContext context, Animation<double> animat
6262
/// Callers must define the [pageBuilder] function which creates the route's
6363
/// primary contents. To add transitions define the [transitionsBuilder] function.
6464
class PageRouteBuilder<T> extends PageRoute<T> {
65+
/// Creates a route that deletates to builder callbacks.
66+
///
67+
/// The [pageBuilder], [transitionsBuilder], [opaque], [barrierDismissable],
68+
/// and [maintainState] arguments must not be null.
6569
PageRouteBuilder({
6670
RouteSettings settings: const RouteSettings(),
6771
this.pageBuilder,
@@ -79,7 +83,14 @@ class PageRouteBuilder<T> extends PageRoute<T> {
7983
assert(maintainState != null);
8084
}
8185

86+
/// Used build the route's primary contents.
87+
///
88+
/// See [ModalRoute.buildPage] for complete definition of the parameters.
8289
final RoutePageBuilder pageBuilder;
90+
91+
/// Used to build the route's transitions.
92+
///
93+
/// See [ModalRoute.buildTransitions] for complete definition of the parameters.
8394
final RouteTransitionsBuilder transitionsBuilder;
8495

8596
@override

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ abstract class TextSelectionDelegate {
6363
void hideToolbar();
6464
}
6565

66-
// An interface for building the selection UI, to be provided by the
67-
// implementor of the toolbar widget.
66+
/// An interface for building the selection UI, to be provided by the
67+
/// implementor of the toolbar widget.
6868
abstract class TextSelectionControls {
6969
/// Builds a selection handle of the given type.
7070
Widget buildHandle(BuildContext context, TextSelectionHandleType type);

0 commit comments

Comments
 (0)