This file contains 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 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 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; |
This file contains 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:http/http.dart' as http; | |
import 'dart:convert'; | |
import 'package:json/json.dart'; | |
main() async { | |
const pubUrl = "https://pub.dartlang.org/api/packages/protobuf"; | |
var response = await http.get(Uri.parse(pubUrl)); | |
if (response.statusCode == 200) { | |
PkgInfo info = PkgInfo.fromJson(json.decode(response.body)); |
This file contains 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
const count = 1000000; | |
bool b = false; | |
dynamic top; | |
void main() { | |
var sw = Stopwatch(); | |
sw.start(); | |
for (int i = 0; i < count; ++i) { |
This file contains 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
// Main idea is "same object, different treatment". We create one | |
// `_Buffer` object and use it as a `WriteBuffer` or as a `ReadBuffer`. | |
// The two perspectives on the `_Buffer` yield unrelated types, | |
// different members, even different variance of the type parameter. | |
// A client _must_ use one or the other extension type, there is no | |
// way a caller outside this library can directly call any instance | |
// member of `_Buffer`. | |
class _Buffer<X> { | |
X? _value; |
This file contains 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 'dart:async'; | |
typedef BetterCompleter<T> = ({ | |
void Function(T) complete, | |
void Function(Object, [StackTrace?]) completeError, | |
bool Function() isCompleted | |
}); | |
BetterCompleter<T> fromCompleter<T>(Completer<T> c) => ( | |
complete: c.complete, |
This file contains 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 'dart:async'; | |
typedef Inv<X> = X Function(X); | |
typedef BetterCompleter<X> = _BetterCompleter<X, Inv<X>>; | |
extension type _BetterCompleter<X, Invariance extends Inv<X>> | |
.fromCompleter(Completer<X> _) { | |
void complete(X value) => _.complete(value); | |
void completeError(Object error, [StackTrace? stackTrace]) => | |
_.completeError(error, stackTrace); |
This file contains 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
dev/conductor/core/test/common.dart:79:11 | |
`String? name;` could just as well be `final String? name;` | |
dev/conductor/core/test/common.dart:82:15 | |
`command` could just as well be `final` | |
dev/conductor/core/test/common.dart:88:20 | |
Could return `const <String>[]`. | |
examples/layers/rendering/src/binding.dart:39:18 | |
Could be `late final RenderView _renderView;`` | |
packages/flutter/lib/src/cupertino/route.dart:391:12 | |
`_page` can be stable if `settings` is stable |
This file contains 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
class A<X extends A<X>> {} | |
class B extends A<B> {} | |
class C extends B {} | |
void f<X extends A<X>>(X x) {} | |
void main() { | |
f<B>(C()); // OK. | |
f(C()); // Compile-time error: "Couldn't infer ..". | |
} |
NewerOlder