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
| final visited = <(int, int)>{}; | |
| Iterable<List<(int, int)>> getBiomes(List<List<int>> worldmap) sync* { | |
| visited.clear(); | |
| for (int i = 0; i < worldmap.length; i++) { | |
| for (int j = 0; j < worldmap[i].length; j++) { | |
| if (visited.contains((i, j))) { | |
| continue; | |
| } |
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 'dart:io'; | |
| import 'dart:math'; | |
| final rng = Random(); | |
| sealed class State { | |
| const State(); | |
| } | |
| class UninitializedState extends State { |
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
| class User { | |
| final String name; | |
| User({required this.name}); | |
| } | |
| class SuperchargedUser extends User { | |
| final String ability; | |
| // no duplication of the "final String name;" here | |
| SuperchargedUser({super.key, super.name, required this.ability}); |
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
| part 'my_widget.styled.dart'; // generated code here | |
| // below is what user writes | |
| @Style() | |
| // ^^^^ provided by the library | |
| class WidgetStyle { | |
| const WidgetStyle(); | |
| final EdgeInsets padding => const EdgeInsets.all(8.0); |
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
| class Comparable { | |
| final String content; | |
| Comparable(this.content); | |
| @override | |
| bool operator ==(other) { | |
| print('=='); | |
| return other is Comparable && other.hashCode == hashCode; | |
| } |
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
| class EmailForm extends StatelessWidget { | |
| final VoidCallback onSubmitted; | |
| final TextEditingController emailCtrl; | |
| final TextEditingController passwordCtrl; | |
| const EmailForm({ | |
| Key? key, | |
| required this.onSubmitted, | |
| required this.emailCtrl, | |
| required this.passwordCtrl, |
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
| void main() { | |
| final store = Store<int>(counterReducer, initialState: 0); | |
| Flutter.registerWrapperWidget(StoreProvider(store: store)); // proposed API | |
| runApp(); | |
| } | |
| class App extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { |
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
| final store = Store<int>(counterReducer, initialState: 0); | |
| void main() { | |
| runApp(); | |
| } | |
| class App extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| return MaterialApp( |
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/foundation.dart'; | |
| import 'package:flutter/material.dart'; | |
| class AppModel extends InheritedWidget { | |
| const AppModel({ | |
| Key? key, | |
| required Widget child, | |
| }) : super(key: key, child: child); | |
| static V get<K, V>(BuildContext context, K key) { |
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
| class Storage<T> { | |
| final _internal = <Type, T>{}; | |
| void add(T value, [Type? type]) { | |
| _internal[type ?? T] = value; | |
| } | |
| T get<T>() { | |
| return _internal[T] as T; | |
| } |
NewerOlder