### Example .packages File Entry Source: https://github.com/dart-lang/language/blob/main/working/0093 - Gradual Language Change Migration/0094 - Per Library Language Version Selection/strawman.md This is an example of an entry in the .packages file, specifying the default language level for a package. The language version is provided as a fragment on the URI reference. ```ini quiver=../../.pubcache/quiver/1.3.17/lib#sdk=2.5 ``` -------------------------------- ### Dart Import Syntax Examples Source: https://github.com/dart-lang/language/blob/main/working/modules/motivation.md Demonstrates various ways to import libraries in Dart, including core libraries, packages, and local files. These examples highlight the verbosity of the current URI-based syntax. ```dart import 'dart:isolate'; import 'package:flutter_test/flutter_test.dart'; import 'package:path/path.dart'; import 'package:flutter/material.dart'; import 'package:analyzer/dart/ast/visitor.dart'; import 'package:widget.tla.server/server.dart'; import 'package:widget.tla.proto/client/component.dart'; import 'test_utils.dart'; import '../util/dart_type_utilities.dart'; import '../../../room/member/membership.dart'; import 'src/assets/source_stylesheet.dart'; ``` -------------------------------- ### View Getter Invocation Example Source: https://github.com/dart-lang/language/blob/main/working/1426-extension-types/feature-specification-views.md Shows an example of invoking a getter `myGetter` on a view with type arguments. ```dart invokeViewMethod(V, , o).myGetter ``` -------------------------------- ### Example: fromJson Specialization Source: https://github.com/dart-lang/language/blob/main/working/4271 - static enough metaprogramming/proposal.md Shows how `fromJson` and its helper `_valueFromJson` are specialized for class `A`. ```dart // Example class A { final int a; final String b; A({required this.a, required this.b}); } // Calling fromJson({...}) produces specializations: A fromJson$A(Map map) { return A( a: _valueFromJson$int(map['a']), b: _valueFromJson$String(map['a']), ); } int _valueFromJson$int(Object? value) { if (value == null) { throw ArgumentError('Field not found in incoming json'); } return value as int; } String _valueFromJson$String(Object? value) { if (value == null) { throw ArgumentError('Field not found in incoming json'); } return value as String; } ``` -------------------------------- ### Another Static Extension Specialization Example Source: https://github.com/dart-lang/language/blob/main/working/0723-static-extensions/feature-specification-variant1.md This example further illustrates static extension specialization, showing how type arguments can be inferred for constructors based on the provided arguments and the on-declaration type. ```dart static extension E6 on Map { factory Map.fromString(Y y) => {y.toString(): y}; } var string2bool = Map.fromString(true); // `Map`. Map> string2listOfBool = Map.fromString([]); ``` -------------------------------- ### Example: toJson Specialization Source: https://github.com/dart-lang/language/blob/main/working/4271 - static enough metaprogramming/proposal.md Illustrates how `toJson` is specialized into `toJson$A` for a specific class `A`. ```dart // Example class A { final int a; final String b; A({required this.a, required this.b}); } // Calling toJson(A(...)) produces specialization Map<...> toJson$A(A value) => {a: value.a, b: value.b}; ``` -------------------------------- ### Inline Class Usage Example Source: https://github.com/dart-lang/language/blob/main/working/1426-extension-types/feature-specification-inline-classes.md Demonstrates the creation and usage of an inline class, highlighting type enforcement and potential errors. ```dart var tiny = TinyJson([[1, 2], 3, []]); print(tiny.leaves); tiny.add("Hello!"); // Error. } ``` -------------------------------- ### String Trim Example with Current Promotion Rules Source: https://github.com/dart-lang/language/blob/main/inactive/enhanced-type-promotion/feature-specification.md This example demonstrates a common scenario where current type promotion rules fail. Assigning to `o` within the `if` block prevents promotion, leading to a static error because `Object` does not have a `trim()` method. ```dart Object trimIfString(Object o) { if (o is String) o = o.trim(); return o; } ``` -------------------------------- ### Ambiguous Import Syntax Example Source: https://github.com/dart-lang/language/blob/main/resources/optional-semicolons-prototype.md Shows how contextual keywords in import statements can create parsing ambiguity. ```dart import 'foo.dart' hide bar ``` -------------------------------- ### Basic String Buffer Operations Source: https://github.com/dart-lang/language/blob/main/working/0260-anonymous-methods/feature-specification.md This example demonstrates standard string buffer manipulation without anonymous methods. ```dart void main() { final String halfDone, result; final sb = StringBuffer('Hello'); sb.write(','); halfDone = sb.toString(); sb.write(' '); sb.write('world!'); result = sb.toString(); print('Creating an important string: $halfDone then $result'); } ``` -------------------------------- ### View Operator Invocation Example Source: https://github.com/dart-lang/language/blob/main/working/1426-extension-types/feature-specification-views.md Demonstrates invoking an operator, such as addition, on a view. ```dart invokeViewMethod(V, , o) + rightOperand ``` -------------------------------- ### Original Constructor with Initializer List Source: https://github.com/dart-lang/language/blob/main/working/enhanced-constructors/feature-specification.md This example shows the traditional syntax for a Dart constructor using an initializer list to set fields and call a super constructor. ```dart VariableDeclarationImpl({ required this.name, required this.equals, required ExpressionImpl? initializer, }) : _initializer = initializer, super(comment: null, metadata: null) { _becomeParentOf(_initializer); } ``` -------------------------------- ### Widget Class with Initializing Formals Source: https://github.com/dart-lang/language/blob/main/working/declaring-constructors/feature-specification.md This example shows how initializing formals in Dart reduce boilerplate by inferring parameter types and allowing direct field initialization. ```dart class ExampleComponent extends StatelessWidget { final String displayString; ExampleComponent({required this.displayString}); @override Widget build(BuildContext context) { return Text(displayString); } } ``` -------------------------------- ### View Type Usage Examples Source: https://github.com/dart-lang/language/blob/main/working/1426-extension-types/feature-specification-views.md Illustrates various valid contexts for using view types, such as variable declarations, function return types, and type tests. ```dart V ``` -------------------------------- ### Tagged String Desugaring Examples Source: https://github.com/dart-lang/language/blob/main/working/tagged-strings/feature-specification.md Illustrates how tagged strings are desugared into function calls with lists of string parts and expressions. ```dart // string parts expressions tag '' // '' (none) tag 'str' // 'str' (none) tag '$e' // '', '' e tag '@$e' // '@', '' e tag '$e!' // '', '!' e tag '@$e!' // '@', '!' e tag '$e$f' // '', '', '' e, f tag '@$e#$f!' // '@', '#', '!' e, f ``` -------------------------------- ### Struct Extension Example Source: https://github.com/dart-lang/language/blob/main/working/extension_structs/overview.md Demonstrates how a struct can extend another abstract struct. Ensure the super-struct is abstract and the extension occurs within the same library. ```dart abstract struct Foo { int foo() => 3; } struct Data(int x, List l = [3]) extends Foo ; struct GenericData(T x, T y) extends Foo; ``` -------------------------------- ### Dart Optional Parameter Syntax Before Migration Source: https://github.com/dart-lang/language/blob/main/working/simpler-parameters/feature-specification.md This example shows the syntax for an optional named parameter in Dart before the proposed changes. It is valid both before and after the migration, but its meaning changes. ```dart f({int? x}) {} ``` -------------------------------- ### Tagged String Static Typing Example Source: https://github.com/dart-lang/language/blob/main/working/tagged-strings/feature-specification.md Demonstrates static typing rules for tagged strings, highlighting type errors when interpolated expressions do not match the expected type. ```dart Expression exprStringLiteral( List strings, List values) { var buffer = StringBuffer(); for (var i = 0; i < values.length; i++) { buffer.write(strings[i]); buffer.write('(' + values[i].toSource() + ')'); } buffer.write(strings.last); return Expression.parse(buffer.toString()); } main() { var identifier = expr "foo"; var add = expr "$identifier + $identifier"; // OK. var notExpr = 123; var subtract = expr "$identifier - $notExpr"; // <-- Error. } ``` -------------------------------- ### Conditional Constructor Example Source: https://github.com/dart-lang/language/blob/main/working/4213-generic-constructors/feature-specification.md Shows a conditional constructor 'ofComparable' that is only valid when the type parameter 'X' satisfies 'X extends Comparable'. ```dart class D { final X x; final int Function(X, X) _compare; D(this.x, this._compare); D.ofComparable>(X x): this(x, (x1, x2) => x1.compareTo(x2)); } void main() { D.ofComparable(1); // OK, type argument `num <: Comparable`. D.ofComparable(1); // Also OK. D.ofComparable(C(42), (c1, c2) => c1.i.compareTo(c2.i)); // OK. D.ofComparable(C(42)); // Compile-time error. } ``` -------------------------------- ### Illegal Cyclical Package Dependency in Bazel Source: https://github.com/dart-lang/language/blob/main/resources/bazel/module-structure.md Bazel prohibits cyclical dependencies between packages (targets), unlike Dart's pub which allows it between libraries. This example shows an illegal setup. ```bazel # //ninjacat/common/foo (i.e. package:ninjacat.common.foo/foo.dart) dart_library( name = "foo", srcs = ["lib/foo.dart"], dependencies = [ "//ninjacat/common/bar", ], ) ``` ```bazel # //ninjacat/common/bar (i.e. package:ninjacat.common.bar/bar.dart) dart_library( name = "bar", srcs = ["lib/bar.dart"], dependencies = [ "//ninjacat/common/foo", ], ) ``` -------------------------------- ### Dart: For loop with newline before body Source: https://github.com/dart-lang/language/blob/main/inactive/terminating-tokens.md Example of a 'for' loop where the body starts on the next line. Dart's parsing rules disallow empty statements (`;`) as control flow bodies, ensuring this is interpreted as the loop body. ```dart for (var i = 0; i < 10; i++) print("hi") ``` -------------------------------- ### Macro Application Ordering Example Source: https://github.com/dart-lang/language/blob/main/working/macros/feature-specification.md Demonstrates how macro applications can circumvent normal 'inside-out' ordering rules, allowing generated macros to run after their parent class macros. This is permitted if it doesn't cause ambiguity. ```dart @MacroA() @MacroB() class X { @MacroC() // Added by `@MacroA()`, runs after both `@MacroB()` and `@MacroA()` int? a; // Generated by `@MacroC()`, not visible to `@MacroB()`. int? b; } ``` -------------------------------- ### Example of a nested union type Source: https://github.com/dart-lang/language/blob/main/working/union-types/nominative-union-types.md This example demonstrates a union type nested within itself, which is allowed dynamically but not recursively at compile time. ```dart typedef U = S | T; void main() { U, String> x; } ``` -------------------------------- ### Type Promotion Scope Example Source: https://github.com/dart-lang/language/blob/main/inactive/enhanced-type-promotion/feature-specification.md This example illustrates the scope in which a type fact is known to be true. The fact that 'o' is a String is only valid within the 'then' clause of the if statement. ```dart if (o is String) { return o.length; } else { throw "Not a string."; } ``` -------------------------------- ### Class Declaration Comparison (Current vs. Primary Constructor) Source: https://github.com/dart-lang/language/blob/main/accepted/3.13/primary-constructors/feature-specification.md Illustrates the equivalent declarations of a 'Point' class using both the current syntax and the new primary constructor syntax. ```dart // Current syntax. class Point { int x; int y; Point(this.x, this.y); } // Using a primary constructor. class Point(var int x, var int y); ``` -------------------------------- ### Dart View Type Composition Example Source: https://github.com/dart-lang/language/blob/main/working/1426-extension-types/feature-specification-views.md Demonstrates how view types can inherit from multiple superviews and how to invoke members from a specific superview using the `super.` syntax when a name clash occurs. ```dart view class V2(Object id) { void foo() { print('V2.foo()'); } } view class V3(Object id) { void foo() { print('V3.foo()'); } } view class V1(Object id) implements V2, V3 { void bar() { super.V3.foo(); // Prints "V3.foo()". } } ``` -------------------------------- ### Type Inference Example with Generic Class Source: https://github.com/dart-lang/language/blob/main/resources/type-system/inference.md Demonstrates type inference for a generic type `T` within a function that uses a generic class `C`. This example shows how the type of `T` is inferred based on the arguments passed to the generic class constructor. ```dart class C { C(void Function(X) x); } T check(C> f) { return null as T; } void test() { var x = check(C((List x) {})); // Should infer `int` for `T` String s = x; // Should be an error, `T` should be int. } ``` -------------------------------- ### Under-constrained list literal example Source: https://github.com/dart-lang/language/blob/main/resources/type-system/strict-inference.md This example demonstrates how an under-constrained empty list literal can lead to a runtime error when passed to a function expecting a specific list type. Strict inference would flag the empty list literal as an inference failure, suggesting an explicit type argument. ```dart fn(List numbers) => print(numbers.first.isEven); void main() { var args = ["one", "two", "three"]; var useArgs = true; var numbers = useArgs ? args : []; fn(numbers); } ``` -------------------------------- ### Opting into new String extension methods Source: https://github.com/dart-lang/language/blob/main/resources/String Class Issues.md Demonstrates how to hide existing String extension methods and import new ones from a specific version. This allows for gradual adoption of updated string functionality. ```dart import "dart:core" hide String.*; // Hides extension methods on String, not static methods. import "dart:core/2.2" show String.*; // Imports new String extension methods from core/2.2. ``` -------------------------------- ### Anonymous Method Invocation Example Source: https://github.com/dart-lang/language/blob/main/working/0260-anonymous-methods/feature-specification.md Illustrates how to read an anonymous method invocation with a simple expression. ```dart e.=> one && two && three ``` -------------------------------- ### Synthesize Instance Construction from Record Source: https://github.com/dart-lang/language/blob/main/working/4271 - static enough metaprogramming/proposal.md Illustrates how static metaprogramming could construct an instance of a class using values from a record, bypassing traditional constructors. This requires a mechanism to construct instances from field values. ```dart class Foo { final String x; final int y; // Empty external constructor. external Foo._(); } /// Construct an instance of `T` using values from `r`. T construct<@konst T>(Record r); ``` ```dart Foo f = construct((x: '', y: 10)); ``` -------------------------------- ### Class with Assertion (Current Syntax) Source: https://github.com/dart-lang/language/blob/main/accepted/3.13/primary-constructors/feature-specification.md Example of a class with an assertion in its constructor using current Dart syntax. ```dart class Point { int x; int y; Point(this.x, this.y): assert(0 <= x && x <= y * y); } ``` -------------------------------- ### Error: Augmenting Mixin Application Class Source: https://github.com/dart-lang/language/blob/main/working/augmentations/feature-specification.md Mixin application classes cannot be augmented. This example shows an error. ```dart class C = S with M; augment class C = S with N; // Error. ``` -------------------------------- ### Generated Documentation for Private Named Parameters Source: https://github.com/dart-lang/language/blob/main/accepted/3.12/private-named-parameters/feature-specification.md Illustrates how generated documentation should ideally represent a constructor with private named parameters, showing the public names to the user. ```dart /// Creates a new instance initialized from `positional` and `named`. ``` -------------------------------- ### Ruby Encoding Comment Source: https://github.com/dart-lang/language/blob/main/resources/backgroundhow-other-languages-manage-breakage.md This is an example of a special comment syntax in Ruby used for encoding, similar to the freeze_string directive. ```ruby # -*- warn_indent: false -*- ``` -------------------------------- ### View Declaration and Member Access Example Source: https://github.com/dart-lang/language/blob/main/working/1426-extension-types/feature-specification-views.md Demonstrates the declaration of view classes (V1, V2) and how member invocations within V2 are resolved, including calls to methods on the representation type (it.foo) and extension methods (1.foo). ```dart extension E1 on int { void foo() { print('E1.foo'); } } view class V1(int it) { void foo() { print('V1.foo'); } void baz() { print('V1.baz'); } void qux() { print('V1.qux'); } } void qux() { print('qux'); } view class V2(V1 it) { void foo() { print('V2.foo); } void bar() { foo(); // Prints 'V2.foo'. it.foo(); // Prints 'V1.foo'. it.baz(); // Prints 'V1.baz'. 1.foo(); // Prints 'E1.foo'. 1.baz(); // Compile-time error. qux(); // Prints 'qux'. } } ``` -------------------------------- ### Class with Named Parameter (Current Syntax) Source: https://github.com/dart-lang/language/blob/main/accepted/3.13/primary-constructors/feature-specification.md Example of a class with a required named parameter using the current Dart syntax. ```dart class Point { int x; int y; Point(this.x, {required this.y}); } ``` -------------------------------- ### Before: Traditional Constructor for ClipboardHistoryItem Source: https://github.com/dart-lang/language/blob/main/working/declaring-constructors/feature-specification.md Illustrates the verbose syntax of a traditional constructor in a StatefulWidget before the introduction of declaring constructors. ```dart // Before: class ClipboardHistoryItem extends StatefulWidget { final DictionaryHistoryEntry entry; final CreatorCallback creatorCallback; final VoidCallback stateCallback; final ScrollController dictionaryScroller; final ValueNotifier dictionaryScrollOffset; ClipboardHistoryItem( this.entry, this.creatorCallback, this.stateCallback, this.dictionaryScroller, this.dictionaryScrollOffset, ); @override _ClipboardHistoryItemState createState() { // ... } } ``` -------------------------------- ### Superconstructor Invocation and Initializer List (Current Syntax) Source: https://github.com/dart-lang/language/blob/main/accepted/3.13/primary-constructors/feature-specification.md Shows how to invoke a superconstructor and initialize instance variables using an initializer list in current Dart syntax. ```dart class A { final int x; const A.someName(this.x); } class B extends A { final String s1; final String s2; const B(int x, int y, {required this.s2}) : s1 = y.toString(), super.someName(x + 1); } ``` -------------------------------- ### Generic Constructor Example Source: https://github.com/dart-lang/language/blob/main/working/4213-generic-constructors/feature-specification.md Demonstrates a generic constructor where the type parameter 'X' is used to relate parameters but not in the return type. ```dart class C { final int i; C(this.i); C.computed(X x, int Function(X) func): this(func(x)); } void main() { C(42); // OK. C.computed('Hello', (s) => s.length); // OK. C.computed('Hello', (s) => s.length); // OK. } ``` -------------------------------- ### New Constructor Syntax with Private Named Parameters Source: https://github.com/dart-lang/language/blob/main/accepted/3.12/private-named-parameters/feature-specification.md This demonstrates the simplified syntax for initializing private instance fields using named parameters, enabled by the private-named-parameters feature. ```dart class House { int? _windows; int? _bedrooms; int? _swimmingPools; House({this._windows, this._bedrooms, this._swimmingPools}); } ``` -------------------------------- ### Shorthand for Static Members and Constructors Source: https://github.com/dart-lang/language/blob/main/working/3616 - enum value shorthand/proposal-lrhn.md Illustrates the proposed extension of the shorthand syntax to include static method calls, constructor invocations, and environment variable access. This requires the context type to have a corresponding static member or constructor. ```dart Padding( padding: const .all(8.0), // const EdgeInsets.all(8.0) // constructor child: ... ) int x = .parse(input); // Static method. const String option = .fromEnvironment("my_option"); // Constructor ``` -------------------------------- ### Inheritance with Super Parameters (Current Syntax) Source: https://github.com/dart-lang/language/blob/main/accepted/3.13/primary-constructors/feature-specification.md Example of a subclass 'B' inheriting from 'A' and using super parameters with the current Dart syntax. ```dart // Current syntax. class A { final int a; A(this.a); } class B extends A { B(super.a); } ``` -------------------------------- ### Larger Example: `User` Class Declaration Source: https://github.com/dart-lang/language/blob/main/working/0015-infer-required/feature-specification.md Illustrates the impact of the proposed `required` inference on a more complex class, showing the current, proposed, and combined syntax with primary constructors. ```dart class User { final String id; final String email; final String userName; final String address; final String phoneNumber; final String name; final String? avatarUrl; User({ required this.id, required this.email, required this.userName, required this.address, required this.phoneNumber, required this.name, this.avatarUrl, }); } ``` ```dart class User { final String id; final String email; final String userName; final String address; final String phoneNumber; final String name; final String? avatarUrl; User({ this.id, this.email, this.userName, this.address, this.phoneNumber, this.name, this.avatarUrl, }); } ``` ```dart class const User({ String id, String email, String userName, String address, String phoneNumber, String name, String? avatarUrl, }); ``` -------------------------------- ### Example Tag Processor Function Source: https://github.com/dart-lang/language/blob/main/working/tagged-strings/feature-specification.md A toy implementation of a tag processor function that demonstrates how to handle string parts and interpolated values. ```dart Code exprStringLiteral( List strings, List values) { var buffer = StringBuffer(); for (var i = 0; i < values.length; i++) { buffer.write(strings[i]); var value = values[i]; if (value is Expression) { buffer.write('(' + value.toSource() + ')'); } else { buffer.write(value); } } buffer.write(strings.last); return Expression.parse(buffer.toString()); } ``` -------------------------------- ### Generalized Collection Literal Syntax Example Source: https://github.com/dart-lang/language/blob/main/working/tagged-strings/alternative-generalized-feature-specification.md Illustrates a potential syntax for generalized collection literals, similar to tagged string interpolations. ```dart var c1 = MyCollection(capacity: 24){1, for (var i = 2; i <= 23; i+= 3) i, 26}; // or var c2 = myCollectionTag{1, 2, ...more}; // or without tagged collections var c3 = myCollectionLiterals"${1, 2, …more}"; ``` -------------------------------- ### Class with Generics and Named Constructor (Current Syntax) Source: https://github.com/dart-lang/language/blob/main/accepted/3.13/primary-constructors/feature-specification.md Illustrates a generic class with a named constructor, inheritance, mixins, and interfaces using current syntax. ```dart class D extends A with M implements B, C { final int x; final int y; const D.named(this.x, [this.y = 0]); } ``` -------------------------------- ### Static Semantics Example Source: https://github.com/dart-lang/language/blob/main/working/static wrapper types/feature-specification.md Illustrates the static semantics of a newtype declaration, including constructor syntax and the behavior of the `_value` pseudo-field and `this` reference. ```dart newtype W wraps T { W() : _value = ... {} W.unsafe(this._value); } ``` -------------------------------- ### After: Declaring Constructor for ClipboardHistoryItem Source: https://github.com/dart-lang/language/blob/main/working/declaring-constructors/feature-specification.md Shows the concise syntax of a declaring constructor for a StatefulWidget, highlighting the reduction in boilerplate code compared to traditional constructors. ```dart // After: class ClipboardHistoryItem extends StatefulWidget { this( final DictionaryHistoryEntry entry, final CreatorCallback creatorCallback, final VoidCallback stateCallback, final ScrollController dictionaryScroller, final ValueNotifier dictionaryScrollOffset, ); @override _ClipboardHistoryItemState createState() { // ... } } ``` -------------------------------- ### JSON Serialization Example in Dart Source: https://github.com/dart-lang/language/blob/main/working/macros/motivation.md A simple Dart class demonstrating manual JSON serialization by explicitly mapping fields to a map. ```dart class Dog { final String breed; final String name; Object toJSON() => {'breed': breed, 'name': name}; } ``` -------------------------------- ### Emulating Generic Constructor with Static Method Source: https://github.com/dart-lang/language/blob/main/working/4213-generic-constructors/feature-specification.md This example shows how to emulate the behavior of a generic constructor using a generic static method in current Dart. It includes a main function to demonstrate its usage. ```dart class Map { Map(); static Map> keyToList(Iterable keys) => {for (key in keys) key: [key]}; } void main() { var xs = [1, 2, 3]; var map = Map.keyToList(xs); // Has type `Map>`. } ``` -------------------------------- ### Explicit Type Declaration in C Source: https://github.com/dart-lang/language/blob/main/inactive/terminating-tokens.md This example shows how C requires explicit type declarations for variables, even when the value is known. ```c int i = 3; ``` -------------------------------- ### Comparison of Original and Abbreviated Dart Constructor Syntax Source: https://github.com/dart-lang/language/blob/main/accepted/3.13/primary-constructors/feature-specification.md Provides a side-by-side comparison of original Dart constructor syntax and the new abbreviated syntax for various constructor forms, including generative, named, const, redirecting, and factory constructors. ```dart Original Dart syntax New abbreviated syntax --------------------------------------- LongClassName() {} new() {} LongClassName.name() {} new name() {} const LongClassName(); const new(); const LongClassName.name(); const new name(); LongClassName(): this.other(); new(): this.other(); LongClassName.name(): this(); new name(): this(); const LongClassName(): this.other(); const new(): this.other(); const LongClassName.name(): this(); const new name(): this(); factory LongClassName() { ... } factory() { ... } factory LongClassName.name() { ... } factory name() { ... } factory LongClassName() = D; factory() = D; factory LongClassName.name() = D; factory name() = D; const factory LongClassName() = D; const factory() = D; const factory LongClassName.name() = D; const factory name() = D; ``` -------------------------------- ### Automated Migration: Using unawaited Source: https://github.com/dart-lang/language/blob/main/working/1661 - unawaited futures/proposal.md Illustrates migrating code that previously used workarounds for unawaited futures to the new `unawaited e` syntax. This ensures explicit handling of futures that are not awaited. ```dart unawaited e ``` -------------------------------- ### Dynamic Semantics of invokeViewMethod Source: https://github.com/dart-lang/language/blob/main/working/1426-extension-types/feature-specification-views.md Describes the evaluation process for `invokeViewMethod` expressions, including argument evaluation and environment setup for method execution. ```dart invokeViewMethod(View, , e).m(args) ``` -------------------------------- ### Private Named Parameter Example Source: https://github.com/dart-lang/language/blob/main/accepted/3.12/private-named-parameters/feature-specification.md Demonstrates a scenario where a named parameter has a private name. The language currently disallows this, resulting in a compile-time error. ```dart test({String? _hmm}) { print(_hmm); } main() { test(_hmm: 'ok?'); } ``` -------------------------------- ### Basic Type Promotion with `is` Check Source: https://github.com/dart-lang/language/blob/main/inactive/enhanced-type-promotion/feature-specification.md Demonstrates how type promotion works when an `is` check is true. Inside the `if` block, `o` is treated as a `String`, allowing access to `String`-specific members like `.length`. ```dart int stringLength(Object o) { if (o is String) { return o.length; // OK! } else { throw "Not a string."; } } ```