Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(771)

Unified Diff: pkg/meta/lib/meta.dart

Issue 1770653002: Add an optional parameter to the Required annotation (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/meta/lib/meta.dart
diff --git a/pkg/meta/lib/meta.dart b/pkg/meta/lib/meta.dart
index c94fd800f79ac04b5e6e1a5e25770ef924d27183..16411b5def992b9c278a7e8a2e3ed2de5a38ab50 100644
--- a/pkg/meta/lib/meta.dart
+++ b/pkg/meta/lib/meta.dart
@@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-/// Constants for use in metadata annotations such as `@protected`.
+/// Constants for use in metadata annotations.
///
/// See also `@deprecated` and `@override` in the `dart:core` library.
///
@@ -84,7 +84,26 @@ const _Protected protected = const _Protected();
/// name that does not have this annotation, or
/// * an invocation of a method or function does not include an argument
/// corresponding to a named parameter that has this annotation.
-const _Required required = const _Required();
+const Required required = const Required();
+
+/// Used to annotate a named parameter `p` in a method or function `f`.
+///
+/// See [required] for more details.
+class Required {
+ /// A human-readable explanation of the reason why the annotated parameter is
+ /// required. For example, the annotation might look like:
+ ///
+ /// ButtonWidget({
+ /// Function onHover,
+ /// @Required('Buttons must do something when pressed')
+ /// Function onPressed,
+ /// ...
+ /// }) ...
+ final String reason;
+
+ /// Initialize a newly created instance to have the given [reason].
+ const Required([this.reason]);
+}
class _Factory {
const _Factory();
@@ -101,7 +120,3 @@ class _MustCallSuper {
class _Protected {
const _Protected();
}
-
-class _Required {
- const _Required();
-}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698