Created
June 28, 2022 04:30
-
-
Save riscait/105e8c648faee487f6b59892afb45e16 to your computer and use it in GitHub Desktop.
unawaited vs ignore
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> throwForIgnore() async { | |
throw Exception('for ignore'); // <- be ignored | |
} | |
Future<void> throwForUnawaited() async { | |
throw Exception('for unawaited'); | |
} | |
void main() async { | |
try { | |
throwForIgnore().ignore(); | |
print('no throw with throwForIgnore'); | |
} on Exception catch (e) { | |
print(e); | |
} | |
try { | |
unawaited(throwForUnawaited()); | |
print('no throw with throwForUnawaited'); | |
} on Exception catch (e) { | |
print(e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment