Skip to content

Instantly share code, notes, and snippets.

@daiki1003
Last active August 14, 2022 14:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daiki1003/0e84c860a5dc15a4d22aab5786826fe9 to your computer and use it in GitHub Desktop.
Save daiki1003/0e84c860a5dc15a4d22aab5786826fe9 to your computer and use it in GitHub Desktop.
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