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
void main() { | |
runApp( | |
MaterialApp( | |
home: Scaffold( | |
appBar: AppBar(title: Text('Title')), | |
body: Text('Hello World'), | |
floatingActionButton: FloatingActionButton( | |
onPressed: () => print('Button pressed'), | |
child: Icon(Icons.add), | |
), |
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/widgets.dart'; | |
void main() { | |
runApp( | |
Directionality( | |
textDirection: TextDirection.ltr, | |
child: Text('Hello World!'), | |
), | |
); | |
} |
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/widgets.dart'; | |
void main() { | |
runApp(Text('Hello World!')); | |
} |
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'; | |
// non-nullable state | |
final todos = StateStream(state: <Todo>[]); | |
final counter = StateStream(state: 0); | |
// nullable state | |
final selectedTodo = StateStream<Todo?>(state: null); | |
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 'dart:async'; | |
// non-nullable state | |
final todos = StateStream(state: <Todo>[]); | |
final counter = StateStream(state: 0); | |
// nullable state | |
final selectedTodo = StateStream<Todo?>(); | |
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
type Monad<A> = Array<A>; | |
function of<A>(a: A): Monad<A> { | |
return [a]; | |
} | |
function flatMap<A, B>(monad: Monad<A>, callback: (a: A) => Monad<B>): Monad<B> { | |
return monad.flatMap(callback); | |
} |
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
Promise.resolve(3).then(x => /* x is 3 here */) | |
const x = await Promise.resolve(3) // x is 3 here as well |
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 x = await Promise.resolve(Promise.resolve(3)) | |
// x is 3 here | |
// but should be Promise.resolve(3) |
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 promise2 = promise1.then(x => Promise.resolve(x)) | |
// promise1 and promise2 are equivalent | |
const promise2 = Promise.resolve(await promise1) | |
// promise1 and promise2 are equivalent |
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 a = yield* pick([1, 2]); | |
// a is inferred as type number | |
const b = yield* pick(['Foo', 'Bar'] as const); | |
// b is inferred as type 'Foo' | 'Bar' |