This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Only supported in the analyzer at this time. | |
// Use `--enable-experiment=anonymous-methods`. | |
// ---------------------------------------------------------------------- | |
// Example from Sam Rawlins, discussed in chat. | |
// Original code. | |
Bucket? get _daysToFirstConversion1 => | |
(_forecastRpcState?.performanceForecast?.hasDaysToFirstConversion() ?? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This library shows how metaobjects in Dart can be used to achieve a | |
// similar effect as the Java type class proposal in the talk by Brian | |
// Goetz. The point is that we can use types (no need to have an instance) | |
// to work with "static-like" properties like the `zero` value and the | |
// `plus` operation of a `Monoid`. | |
// | |
// No attempt is made to include the syntactic sugar than allows | |
// `witness.plus(a, b)` to be written as `a + b`. That's a separate | |
// consideration, and it might be useful with metaobjects as well as | |
// in other contexts. So that's a topic for another day, and the code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// A run of text with a single style. | |
/// | |
/// The [Text] widget displays a string of text with single style. The string | |
/// might break across multiple lines or might all be displayed on the same line | |
/// depending on the layout constraints. | |
/// | |
/// The [style] argument is optional. When omitted, the text will use the style | |
/// from the closest enclosing [DefaultTextStyle]. If the given style's | |
/// [TextStyle.inherit] property is true (the default), the given style will | |
/// be merged with the closest enclosing [DefaultTextStyle]. This merging |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This program printed `A<List<int>, dynamic>` before inference-using-bounds. | |
// With that feature it prints `A<List<int>, int>`. | |
class A<X extends Iterable<Y>, Y> { | |
final X x; | |
A(this.x) { | |
print('Creating an A<$X, $Y>.'); | |
} | |
Y get first => x.first; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This is the basic approach, showing how the examples in 'Traits for Dart' | |
can be written using 'More capable type objects'. The main differences are | |
that the 'traits' approach can add an implementation to an existing type | |
(say, `String`) whereas the 'type objects' approach supports late binding. | |
*/ | |
// --- Glue classes. | |
class Writer { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static extension EdgeInsetsGeometryExtensions on EdgeInsetsGeometry { | |
// Forward to EdgeInsets: | |
const factory EdgeInsetsGeometry.fromLTRB = EdgeInsets.fromLTRB; | |
const factory EdgeInsetsGeometry.all = EdgeInsets.all; | |
const factory EdgeInsetsGeometry.only = EdgeInsets.only; | |
const factory EdgeInsetsGeometry.symmetric = EdgeInsets.symmetric; | |
static const zero = EdgeInsets.only(); | |
// Forward to EdgeInsetsDirectional: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static extension EdgeInsetsGeometryExtensions on EdgeInsetsGeometry { | |
// Forward to EdgeInsets: | |
const factory EdgeInsetsGeometry.fromLTRB( | |
double left, | |
double top, | |
double right, | |
double bottom, | |
) = EdgeInsets.fromLTRB; | |
const factory EdgeInsetsGeometry.all(double value) = EdgeInsets.all; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/cupertino.dart'; | |
import 'package:flutter/material.dart' show Divider; | |
import 'package:landmarks/widgets/favorite_button.dart'; | |
import '../model/landmarks_model.dart'; | |
import '../model/landmark.dart'; | |
import '../widgets/circle_image.dart'; | |
import '../widgets/map_view.dart'; | |
extension on BuildContext { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
// Assumptions: | |
// * Dart has primary constructors. | |
// * Dart supports `override`, and override inference | |
// is considered appropriate. | |
// * The named parameter `String name` can omit `required` | |
// because it is inferred. | |
void main() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(const App(name: 'Dash')); | |
} | |
@Stateless() | |
class App { | |
@Input() String get name; |
NewerOlder