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() async { | |
| // can catch exeptions. | |
| wait(); | |
| // cannot catch exeptions. | |
| record(); | |
| } | |
| Future<bool> someFuture() async { | |
| Future.delayed(const Duration(seconds: 1)); | |
| return true; |
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 stopwatch = Stopwatch(); | |
| () { | |
| stopwatch.start(); | |
| final sut = List.generate(100000, (index) => index * index); | |
| [for (final s in sut) s.toString()]; | |
| stopwatch.stop(); | |
| print('for time: ${stopwatch.elapsedMilliseconds} ms'); | |
| }(); |
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
| // Definition | |
| @Riverpod(keepAlive: true) | |
| _RefreshToken refreshToken(RefreshTokenRef ref) => _RefreshToken(ref); | |
| class _RefreshToken { | |
| const _RefreshToken(this.ref); | |
| final Ref ref; | |
| Future<RefreshTokenResponse> call({ |
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> throwForIgnore() async { | |
| throw Exception('for ignore'); // <- be ignored | |
| } | |
| Future<void> throwForUnawaited() async { | |
| throw Exception('for unawaited'); | |
| } |
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 BaseClass {} | |
| class ExtendedClass extends BaseClass {} | |
| class OtherClass {} | |
| void main() { | |
| final baseClass = BaseClass(); | |
| final extendedClass = ExtendedClass(); |
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_hooks/flutter_hooks.dart'; | |
| void main() => runApp(const MyApp()); | |
| class MyApp extends StatelessWidget { | |
| const MyApp({super.key}); | |
| @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
| import 'package:flutter/material.dart'; | |
| void main() => runApp(MyApp()); | |
| class MyApp extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| return MaterialApp( | |
| title: 'Flutter Demo', | |
| debugShowCheckedModeBanner: 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 'package:riverpod/riverpod.dart'; | |
| final stateProvider = StateProvider((_) => 1); | |
| final getterClassProvider = Provider((ref) => GetterClass(ref.read)); | |
| class GetterClass { | |
| GetterClass(this._read) { | |
| print('Construct GetterClass'); | |
| } | |
| final Reader _read; |
NewerOlder