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/material.dart'; | |
| void main() { | |
| runApp(const MyApp()); | |
| } | |
| class MyApp extends StatelessWidget { | |
| const MyApp({super.key}); | |
| @override |
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/material.dart'; | |
| import 'package:flutter_riverpod/flutter_riverpod.dart'; | |
| void main() { | |
| runApp(ProviderScope(child: const MyApp())); | |
| } | |
| class MyApp extends StatelessWidget { | |
| const MyApp({super.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
| void main() { | |
| print('main: before someFutureFunc'); | |
| someFutureFunc(); | |
| print('main: after someFutureFunc'); | |
| } | |
| Future<void> someFutureFunc() async { | |
| print('someFutureFunc: before wait'); | |
| await Future.delayed(const Duration(seconds: 3)); | |
| print('someFutureFunc: after wait'); |
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() { | |
| List<HitProduct> hitProducs = []; | |
| hitProducs.add(HitProduct("test")); | |
| hitProducs.add(HitProduct("test2")); | |
| final test = hitProducs.map((hitProduct) => OtherClass(hitProduct: hitProduct)).toList(); | |
| print('test is $test'); | |
| } |
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:async'; | |
| Future<void> main() async { | |
| final controller = StreamController<int>(); | |
| startSender(controller); | |
| await for (int n in controller.stream) { | |
| print('consume $n'); | |
| } |
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:math'; | |
| void main() { | |
| final List<int> a = [1, 2]; | |
| final List<int> b = [3, 4]; | |
| List<int> newList1 = a; | |
| newList1 += b; | |
| print('newList1 $newList1'); // -> newList1 [1, 2, 3, 4] | |
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
| typedef Id = String; | |
| extension on Id { | |
| String get firstChar => substring(0, 1); | |
| } | |
| typedef IdList = List<Id>; | |
| extension on IdList { | |
| String get firstItem => this[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
| void main() { | |
| _test1(); | |
| _test2(); | |
| _test3(); | |
| _test4(); | |
| // check `assert` works | |
| assert(false); | |
| } |
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:async'; | |
| void main() { | |
| final controller = StreamController<String>(); | |
| _handle1(controller.stream); | |
| // _handle2(controller.stream); | |
| controller.sink.add('message 1'); | |
| controller.sink.add('message 2'); |
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/material.dart'; | |
| void main() => runApp(const MyApp()); | |
| class MyApp extends StatelessWidget { | |
| const MyApp({Key? key}) : super(key: key); | |
| static const String _title = 'Flutter Code Sample'; | |
| @override |
NewerOlder