flutterdartvisual-studio-codeflame

How to Make VSCode Autocomplete Future<void> onLoad() Instead of FutureOr<void> onLoad()


Related: What exactly is FutureOr<void> onLoad?

When I try to write onLoad in VSCode, it autocompletes as FutureOr<void> onLoad(). However, I want it to autocomplete as Future<void> onLoad().

How can I configure VSCode to suggest Future<void> onLoad() instead?

Most Flutter Flame sample code online uses Future<void> onLoad(), For example: https://docs.flame-engine.org/latest/flame/game.html

 @override
 Future<void> onLoad() async {
   sprite = await Sprite.load('crate.png');
 }

Solution

  • You can't, not directly at least, since FutureOr<void> is what the super class specifies as its method signature return type. As suggested you can create a VSCode snippet for it though.