Skip to content

Instantly share code, notes, and snippets.

@loushou
loushou / main.dart
Last active October 31, 2021 18:22
Flutter - Programmatically trigger button without directly tapping it #flutter #statemanagement #provider
/*
The goal of this is to show you how to abstract the action of tapping a button,
such that it can be triggered from some other code. In this case we trigger one
button's action from tapping another button... but the principle should carry
over if you are triggering it from somewhere else in the code as well, possibly
not related to a user button tap (maybe after a certain amount of time, or when
another state updates elsewhere in the code).
*/
// this package provides the state management utilities we need for this magic to happen