From 0f1a703a6b4674388dd54cfdbcb243001c6e5ad5 Mon Sep 17 00:00:00 2001 From: Ian Hickson Date: Thu, 8 Jun 2017 17:13:03 -0700 Subject: [PATCH] More documentation (#10589) --- .../lib/src/foundation/change_notifier.dart | 2 +- .../lib/src/painting/text_painter.dart | 5 ++ packages/flutter/lib/src/rendering/debug.dart | 6 ++- .../flutter/lib/src/rendering/object.dart | 2 +- .../flutter/lib/src/widgets/page_storage.dart | 2 +- packages/flutter/lib/src/widgets/routes.dart | 2 +- .../flutter/lib/src/widgets/transitions.dart | 54 +++++++++++++++++-- packages/flutter_driver/lib/src/driver.dart | 4 +- .../flutter_driver/lib/src/extension.dart | 7 +-- .../lib/src/timeline_summary.dart | 8 +-- .../lib/src/android/android_device.dart | 2 +- packages/flutter_tools/lib/src/asset.dart | 2 +- packages/flutter_tools/lib/src/base/os.dart | 4 +- .../lib/src/commands/build_aot.dart | 2 +- .../lib/src/commands/config.dart | 2 +- .../lib/src/commands/create.dart | 4 +- .../flutter_tools/lib/src/dart/analysis.dart | 2 +- .../lib/src/runner/flutter_command.dart | 6 +-- packages/flutter_tools/lib/src/version.dart | 2 +- 19 files changed, 88 insertions(+), 30 deletions(-) diff --git a/packages/flutter/lib/src/foundation/change_notifier.dart b/packages/flutter/lib/src/foundation/change_notifier.dart index 953296c114..06dd9ea97d 100644 --- a/packages/flutter/lib/src/foundation/change_notifier.dart +++ b/packages/flutter/lib/src/foundation/change_notifier.dart @@ -20,7 +20,7 @@ abstract class Listenable { /// The list must not be changed after this method has been called. Doing so /// will lead to memory leaks or exceptions. /// - /// The list may contain `null`s; they are ignored. + /// The list may contain nulls; they are ignored. factory Listenable.merge(List listenables) = _MergingListenable; /// Register a closure to be called when the object notifies its listeners. diff --git a/packages/flutter/lib/src/painting/text_painter.dart b/packages/flutter/lib/src/painting/text_painter.dart index 8c7e458f6c..8afa2858e7 100644 --- a/packages/flutter/lib/src/painting/text_painter.dart +++ b/packages/flutter/lib/src/painting/text_painter.dart @@ -109,6 +109,11 @@ class TextPainter { /// passed to [layout]. /// /// After this is set, you must call [layout] before the next call to [paint]. + /// + /// The higher layers of the system, such as the [Text] widget, represent + /// overflow effects using the [TextOverflow] enum. The + /// [TextOverflow.ellipsis] value corresponds to setting this property to + /// U+2026 HORIZONTAL ELLIPSIS (…). String get ellipsis => _ellipsis; String _ellipsis; set ellipsis(String value) { diff --git a/packages/flutter/lib/src/rendering/debug.dart b/packages/flutter/lib/src/rendering/debug.dart index fdd137177a..e605d73e52 100644 --- a/packages/flutter/lib/src/rendering/debug.dart +++ b/packages/flutter/lib/src/rendering/debug.dart @@ -108,7 +108,11 @@ bool debugPrintMarkNeedsLayoutStacks = false; /// Check the intrinsic sizes of each [RenderBox] during layout. bool debugCheckIntrinsicSizes = false; -/// Adds [dart:developer.Timeline] events for every RenderObject painted. +/// Adds [dart:developer.Timeline] events for every [RenderObject] painted. +/// +/// This is only enabled in debug builds. The timing information this exposes is +/// not representative of actual paints. However, it can expose unexpected +/// painting in the timeline. /// /// For details on how to use [dart:developer.Timeline] events in the Dart /// Observatory to optimize your app, see: diff --git a/packages/flutter/lib/src/rendering/object.dart b/packages/flutter/lib/src/rendering/object.dart index b5fd189f3d..81856d505a 100644 --- a/packages/flutter/lib/src/rendering/object.dart +++ b/packages/flutter/lib/src/rendering/object.dart @@ -2401,7 +2401,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget { /// the approximate bounding box of the clip rect that would be /// applied to the given child during the paint phase, if any. /// - /// Returns `null` if the child would not be clipped. + /// Returns null if the child would not be clipped. /// /// This is used in the semantics phase to avoid including children /// that are not physically visible. diff --git a/packages/flutter/lib/src/widgets/page_storage.dart b/packages/flutter/lib/src/widgets/page_storage.dart index 7d71ac87db..8b4d42ffe1 100644 --- a/packages/flutter/lib/src/widgets/page_storage.dart +++ b/packages/flutter/lib/src/widgets/page_storage.dart @@ -119,7 +119,7 @@ class PageStorage extends StatelessWidget { /// The bucket from the closest instance of this class that encloses the given context. /// - /// Returns `null` if none exists. + /// Returns null if none exists. /// /// Typical usage is as follows: /// diff --git a/packages/flutter/lib/src/widgets/routes.dart b/packages/flutter/lib/src/widgets/routes.dart index 571d86f0b8..ddd68b14aa 100644 --- a/packages/flutter/lib/src/widgets/routes.dart +++ b/packages/flutter/lib/src/widgets/routes.dart @@ -524,7 +524,7 @@ abstract class ModalRoute extends TransitionRoute with LocalHistoryRoute new _SpinnerState(); +/// } +/// +/// class _SpinnerState extends State with SingleTickerProviderStateMixin { +/// AnimationController _controller; +/// +/// @override +/// void initState() { +/// super.initState(); +/// _controller = new AnimationController( +/// duration: const Duration(seconds: 10), +/// vsync: this, +/// )..repeat(); +/// } +/// +/// @override +/// void dispose() { +/// _controller.dispose(); +/// super.dispose(); +/// } +/// +/// @override +/// Widget build(BuildContext context) { +/// return new AnimatedBuilder( +/// animation: _controller, +/// child: new Container(width: 200.0, height: 200.0, color: Colors.green), +/// builder: (BuildContext context, Widget child) { +/// return new Transform.rotate( +/// angle: _controller.value * 2.0 * math.PI, +/// child: child, +/// ); +/// }, +/// ); +/// } +/// } +/// ``` class AnimatedBuilder extends AnimatedWidget { /// Creates an animated builder. /// diff --git a/packages/flutter_driver/lib/src/driver.dart b/packages/flutter_driver/lib/src/driver.dart index 8652cd553a..2b8addaeea 100644 --- a/packages/flutter_driver/lib/src/driver.dart +++ b/packages/flutter_driver/lib/src/driver.dart @@ -158,8 +158,8 @@ class FlutterDriver { VMIsolate isolate = await vm.isolates.first.loadRunnable(); // TODO(yjbanov): vm_service_client does not support "None" pause event yet. - // It is currently reported as `null`, but we cannot rely on it because - // eventually the event will be reported as a non-`null` object. For now, + // It is currently reported as null, but we cannot rely on it because + // eventually the event will be reported as a non-null object. For now, // list all the events we know about. Later we'll check for "None" event // explicitly. // diff --git a/packages/flutter_driver/lib/src/extension.dart b/packages/flutter_driver/lib/src/extension.dart index 1af359d89e..851c2cb3b4 100644 --- a/packages/flutter_driver/lib/src/extension.dart +++ b/packages/flutter_driver/lib/src/extension.dart @@ -49,13 +49,14 @@ void enableFlutterDriverExtension() { assert(WidgetsBinding.instance is _DriverBinding); } -/// Handles a command and returns a result. +/// Signature for functions that handle a command and return a result. typedef Future CommandHandlerCallback(Command c); -/// Deserializes JSON map to a command object. +/// Signature for functions that deserialize a JSON map to a command object. typedef Command CommandDeserializerCallback(Map params); -/// Runs the finder and returns the [Element] found, or `null`. +/// Signature for functions that run the given finder and return the [Element] +/// found, if any, or null otherwise. typedef Finder FinderConstructor(SerializableFinder finder); @visibleForTesting diff --git a/packages/flutter_driver/lib/src/timeline_summary.dart b/packages/flutter_driver/lib/src/timeline_summary.dart index df5c098c11..f0d90f3f2b 100644 --- a/packages/flutter_driver/lib/src/timeline_summary.dart +++ b/packages/flutter_driver/lib/src/timeline_summary.dart @@ -28,14 +28,14 @@ class TimelineSummary { /// Average amount of time spent per frame in the framework building widgets, /// updating layout, painting and compositing. /// - /// Returns `null` if no frames were recorded. + /// Returns null if no frames were recorded. double computeAverageFrameBuildTimeMillis() { return _averageInMillis(_extractFrameThreadDurations()); } /// The longest frame build time in milliseconds. /// - /// Returns `null` if no frames were recorded. + /// Returns null if no frames were recorded. double computeWorstFrameBuildTimeMillis() { return _maxInMillis(_extractFrameThreadDurations()); } @@ -48,14 +48,14 @@ class TimelineSummary { /// Average amount of time spent per frame in the GPU rasterizer. /// - /// Returns `null` if no frames were recorded. + /// Returns null if no frames were recorded. double computeAverageFrameRasterizerTimeMillis() { return _averageInMillis(_extractDuration(_extractGpuRasterizerDrawEvents())); } /// The longest frame rasterization time in milliseconds. /// - /// Returns `null` if no frames were recorded. + /// Returns null if no frames were recorded. double computeWorstFrameRasterizerTimeMillis() { return _maxInMillis(_extractDuration(_extractGpuRasterizerDrawEvents())); } diff --git a/packages/flutter_tools/lib/src/android/android_device.dart b/packages/flutter_tools/lib/src/android/android_device.dart index 59019ab752..b4dd532fbd 100644 --- a/packages/flutter_tools/lib/src/android/android_device.dart +++ b/packages/flutter_tools/lib/src/android/android_device.dart @@ -476,7 +476,7 @@ class AndroidDevice extends Device { static final RegExp _timeRegExp = new RegExp(r'^\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3}', multiLine: true); - /// Return the most recent timestamp in the Android log or `null` if there is + /// Return the most recent timestamp in the Android log or null if there is /// no available timestamp. The format can be passed to logcat's -T option. String get lastLogcatTimestamp { final String output = runCheckedSync(adbCommandForDevice([ diff --git a/packages/flutter_tools/lib/src/asset.dart b/packages/flutter_tools/lib/src/asset.dart index df951e7eab..6f1e39ae87 100644 --- a/packages/flutter_tools/lib/src/asset.dart +++ b/packages/flutter_tools/lib/src/asset.dart @@ -316,7 +316,7 @@ DevFSContent _createFontManifest(Map manifestDescriptor, /// Given an assetBase location and a pubspec.yaml Flutter manifest, return a /// map of assets to asset variants. /// -/// Returns `null` on missing assets. +/// Returns null on missing assets. Map<_Asset, List<_Asset>> _parseAssets( PackageMap packageMap, Map manifestDescriptor, diff --git a/packages/flutter_tools/lib/src/base/os.dart b/packages/flutter_tools/lib/src/base/os.dart index b4027ad8b3..1cb56968f0 100644 --- a/packages/flutter_tools/lib/src/base/os.dart +++ b/packages/flutter_tools/lib/src/base/os.dart @@ -27,7 +27,7 @@ abstract class OperatingSystemUtils { /// Make the given file executable. This may be a no-op on some platforms. ProcessResult makeExecutable(File file); - /// Return the path (with symlinks resolved) to the given executable, or `null` + /// Return the path (with symlinks resolved) to the given executable, or null /// if `which` was not able to locate the binary. File which(String execName) { final List result = _which(execName); @@ -206,7 +206,7 @@ class _WindowsUtils extends OperatingSystemUtils { /// Find and return the project root directory relative to the specified /// directory or the current working directory if none specified. -/// Return `null` if the project root could not be found +/// Return null if the project root could not be found /// or if the project root is the flutter repository root. String findProjectRoot([String directory]) { const String kProjectRootSentinel = 'pubspec.yaml'; diff --git a/packages/flutter_tools/lib/src/commands/build_aot.dart b/packages/flutter_tools/lib/src/commands/build_aot.dart index 10f79bb9cc..22e0b2ca23 100644 --- a/packages/flutter_tools/lib/src/commands/build_aot.dart +++ b/packages/flutter_tools/lib/src/commands/build_aot.dart @@ -82,7 +82,7 @@ String _getPackagePath(PackageMap packageMap, String package) { return fs.path.dirname(packageMap.map[package].toFilePath()); } -/// Build an AOT snapshot. Return `null` (and log to `printError`) if the method +/// Build an AOT snapshot. Return null (and log to `printError`) if the method /// fails. Future buildAotSnapshot( String mainPath, diff --git a/packages/flutter_tools/lib/src/commands/config.dart b/packages/flutter_tools/lib/src/commands/config.dart index 11f7e078aa..16c0629193 100644 --- a/packages/flutter_tools/lib/src/commands/config.dart +++ b/packages/flutter_tools/lib/src/commands/config.dart @@ -42,7 +42,7 @@ class ConfigCommand extends FlutterCommand { 'Analytics reporting is currently ${flutterUsage.enabled ? 'enabled' : 'disabled'}.'; } - /// Return `null` to disable tracking of the `config` command. + /// Return null to disable tracking of the `config` command. @override Future get usagePath => null; diff --git a/packages/flutter_tools/lib/src/commands/create.dart b/packages/flutter_tools/lib/src/commands/create.dart index cf8c3ec1bf..cb60d498f3 100644 --- a/packages/flutter_tools/lib/src/commands/create.dart +++ b/packages/flutter_tools/lib/src/commands/create.dart @@ -311,7 +311,7 @@ final Set _packageDependencies = new Set.from([ 'yaml' ]); -/// Return `null` if the project name is legal. Return a validation message if +/// Return null if the project name is legal. Return a validation message if /// we should disallow the project name. String _validateProjectName(String projectName) { if (!package_names.isValidPackageName(projectName)) @@ -324,7 +324,7 @@ String _validateProjectName(String projectName) { return null; } -/// Return `null` if the project directory is legal. Return a validation message +/// Return null if the project directory is legal. Return a validation message /// if we should disallow the directory name. String _validateProjectDir(String dirPath, { String flutterRoot }) { if (fs.path.isWithin(flutterRoot, dirPath)) { diff --git a/packages/flutter_tools/lib/src/dart/analysis.dart b/packages/flutter_tools/lib/src/dart/analysis.dart index cd20c4546c..a41dfe4d5e 100644 --- a/packages/flutter_tools/lib/src/dart/analysis.dart +++ b/packages/flutter_tools/lib/src/dart/analysis.dart @@ -136,7 +136,7 @@ class AnalysisDriver { bool _isFiltered(AnalysisError error) { final ErrorProcessor processor = ErrorProcessor.getProcessor(context.analysisOptions, error); - // Filtered errors are processed to a severity of `null`. + // Filtered errors are processed to a severity of null. return processor != null && processor.severity == null; } diff --git a/packages/flutter_tools/lib/src/runner/flutter_command.dart b/packages/flutter_tools/lib/src/runner/flutter_command.dart index eb6984beba..28b227ed17 100644 --- a/packages/flutter_tools/lib/src/runner/flutter_command.dart +++ b/packages/flutter_tools/lib/src/runner/flutter_command.dart @@ -134,7 +134,7 @@ abstract class FlutterCommand extends Command { applicationPackages ??= new ApplicationPackageStore(); } - /// The path to send to Google Analytics. Return `null` here to disable + /// The path to send to Google Analytics. Return null here to disable /// tracking of the command. Future get usagePath async => name; @@ -218,7 +218,7 @@ abstract class FlutterCommand extends Command { /// Find and return all target [Device]s based upon currently connected /// devices and criteria entered by the user on the command line. /// If no device can be found that meets specified criteria, - /// then print an error message and return `null`. + /// then print an error message and return null. Future> findAllTargetDevices() async { if (!doctor.canLaunchAnything) { printError("Unable to locate a development device; please run 'flutter doctor' " @@ -264,7 +264,7 @@ abstract class FlutterCommand extends Command { /// Find and return the target [Device] based upon currently connected /// devices and criteria entered by the user on the command line. /// If a device cannot be found that meets specified criteria, - /// then print an error message and return `null`. + /// then print an error message and return null. Future findTargetDevice() async { List deviceList = await findAllTargetDevices(); if (deviceList == null) diff --git a/packages/flutter_tools/lib/src/version.dart b/packages/flutter_tools/lib/src/version.dart index 4246b6176e..de68f74d76 100644 --- a/packages/flutter_tools/lib/src/version.dart +++ b/packages/flutter_tools/lib/src/version.dart @@ -236,7 +236,7 @@ class FlutterVersion { /// This method sends a server request if it's been more than /// [kCheckAgeConsideredUpToDate] since the last version check. /// - /// Returns `null` if the cached version is out-of-date or missing, and we are + /// Returns null if the cached version is out-of-date or missing, and we are /// unable to reach the server to get the latest version. Future _getLatestAvailableFlutterVersion() async { Cache.checkLockAcquired();