Skip to content

Instantly share code, notes, and snippets.

View yjbanov's full-sized avatar
💭
Building a Web runtime for Flutter: http://bit.ly/flutter-web

Yegor yjbanov

💭
Building a Web runtime for Flutter: http://bit.ly/flutter-web
  • Google
  • United States
View GitHub Profile
@yjbanov
yjbanov / widget.dart
Last active June 6, 2018 05:08
A Darty widget declaration syntax
// Stateless widget:
//
// - no `extends StatelessWidget`
// - fields are `final` by default
// - `@override`, `Widget` return type and `BuildContext context` parameter are implied
widget MyApp {
String title;
build {
}
@yjbanov
yjbanov / wrap_unwrap.dart
Last active June 28, 2018 16:27
Conditional wrapping operator for Dart
// This build method attempts to conditionally insert a
// DecoratedBox widget into the widget hierarchy. Roughly
// speaking we want the widget tree to be like this:
//
// if (someCondition) {
// Container > DecoratedBox > Container
// } else {
// Container > Container
// }
build(_) {
dart --enable-asserts ./dev/bots/test.dart
Running task: web_tests-0-linux
════════════════════════════════════════════════════════════════════════════════
Running smoketests...
▌21:31:29▐ RUNNING: cd dev/automated_tests; ../../bin/flutter test test_smoke_test/pass_test.dart
▌21:31:39▐ ELAPSED TIME: 10.229s for ../../bin/flutter test test_smoke_test/pass_test.dart in dev/automated_tests
▌21:31:39▐ RUNNING: cd dev/automated_tests; ../../bin/flutter test test_smoke_test/fail_test.dart
▌21:31:42▐ ELAPSED TIME: 3.148s for ../../bin/flutter test test_smoke_test/fail_test.dart in dev/automated_tests
▌21:31:42▐ RUNNING: cd dev/automated_tests; ../../bin/flutter test test_smoke_test/timeout_pass_test.dart
▌21:31:48▐ ELAPSED TIME: 5.831s for ../../bin/flutter test test_smoke_test/timeout_pass_test.dart in dev/automated_tests
INFO: chrome version in use Google Chrome 80.0.3987.132
downloading file from https://chromedriver.storage.googleapis.com/80.0.3987.106/chromedriver_linux64.zip
lib/chrome_driver_command.dart:50:45: Error: No named parameter with the name 'alwaysInstall'.
await chromeDriverInstaller.install(alwaysInstall: alwaysInstall);
^^^^^^^^^^^^^
lib/chrome_driver_command.dart:52:43: Error: No named parameter with the name 'alwaysInstall'.
await chromeDriverInstaller.start(alwaysInstall: alwaysInstall);
^^^^^^^^^^^^^
lib/chrome_driver_command.dart:66:53: Error: Method not found: 'ChromeDriverInstaller.withVersion'.
4 workers:
[INFO] Running build completed, took 3m 57s
[INFO] Caching finalized dependency graph completed, took 210ms
[INFO] Reading manifest at build/.build.manifest completed, took 1ms
[INFO] Deleting previous outputs in `build` completed, took 119ms
[INFO] Creating merged output dir `build` completed, took 685ms
[INFO] Writing asset manifest completed, took 8ms
[INFO] Succeeded after 3m 58s with 824 outputs (414 actions)
@yjbanov
yjbanov / main.dart
Created May 15, 2020 20:36
async puzzler
Future<void> foo() => Future<void>.delayed(
Duration.zero,
() { print('foo'); }
);
void bar() async {
await foo();
print('bar');
}
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
class Foo {
Foo({this.x, this.y});
final int x;
final int y;
toString() => '($x, $y)';
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
class Foo {
Foo({this.x, this.y});
final int x;
final int y;
toString() => '($x, $y)';
updateNode$11$actions$childrenInHitTestOrder$childrenInTraversalOrder$decreasedValue$flags$id$increasedValue$label$rect$transform$value: function(actions, childrenInHitTestOrder, childrenInTraversalOrder, decreasedValue, flags, id, increasedValue, label, rect, transform, value) {
var t1, matrix32, _null = null;
if (C.JSString_methods.contains$1(H.S(label), "_Required"))
throw H.wrapException(P.Exception_Exception('Value of label is "' + H.S(label) + '" of type ' + J.get$runtimeType$(label).toString$0(0)));
t1 = transform.length;
if (t1 !== 16)
throw H.wrapException(P.ArgumentError$("transform argument must have 16 entries."));
matrix32 = new Float32Array(16);
if (15 >= t1)
return H.ioore(transform, 15);
void _buildSegments() {
assert(_segments.isEmpty, '_buildSegments should be called once');
_isClosed = false;
double distance = 0.0;
bool haveSeenMoveTo = false;
final List<PathCommand> commands = subPath.commands;
double currentX = 0.0, currentY = 0.0;
final Function lineToHandler = (double x, double y) {
final double dx = currentX - x;