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
extension type Intersection<T, U>._(dynamic _value) { | |
factory Intersection(dynamic value) { | |
if (value is! T && value is! U) { | |
throw StateError('Invalid type'); | |
} | |
return Intersection(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'; | |
class MyStreamController { | |
final MyStream stream; | |
MyStreamController() : stream = MyStream(); | |
void add(int i) { | |
Future.microtask(() { | |
stream.lastElement = 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
class A { | |
static int g() { | |
print('happens'); | |
return 42; | |
} | |
static final int f = g(); | |
} | |
void main() { | |
print('hmm?'); |
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 random | |
total = 0 | |
boys = 0 | |
for _ in range(10000): | |
population = [(random.choice(['B', 'G']), random.choice(['B', 'G'])) for _ in range(1000)] | |
mr_smith_kids = random.choice(population) | |
if mr_smith_kids == ('G', 'G'): # We know this did not happen | |
continue | |
total += 1 |
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(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: MyHomePage(), | |
); |
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(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: Builder( | |
builder: (context) { |
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
String _value = 'D'; // is not in your hand | |
mixin B on Z { | |
String get value => _value; | |
String get cachedValue; | |
@override | |
void call() { | |
print('in B: $value, $cachedValue'); | |
super.call(); |
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(MaterialApp(home: A())); | |
} | |
class A extends StatefulWidget { | |
@override | |
_AState createState() => _AState(); | |
} |
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(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: MyHomePage(), | |
); |
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'; | |
Future<void> wait(int millis) => | |
Future.delayed(Duration(milliseconds: millis)); | |
Stream<String> userTyping() async* { | |
await wait(100); | |
yield 'h'; | |
await wait(100); | |
yield 'he'; |
NewerOlder