Skip to content

Instantly share code, notes, and snippets.

@daiki1003
Last active August 14, 2022 14:37
Embed
What would you like to do?
class SomeWidget extends ConsumerWidget {
const SomeWidget({
super.key,
});
@override
Widget build(BuildContext context, WidgetRef ref) {
final musicId = ref.watch(musicIdProvider);
final volume = ref.watch(volumeProvider);
Future<void> playMusic() async {
final music = await searchMusic();
// here can uses context, ref, musicId, and volume :)
}
Future<Music?> searchMusic() async {
// search
}
return TextButton(
onPressed: playMusic,
child: Text('sample'),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment