Created
October 10, 2023 14:20
-
-
Save doyle-flutter/d798e63b0728e0907d07eb5bc376dd91 to your computer and use it in GitHub Desktop.
audio 2023
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 'package:audioplayers/audioplayers.dart'; | |
import 'package:flutter/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) => MaterialApp( | |
home: MainPage(), | |
); | |
} | |
class MainPage extends StatelessWidget { | |
const MainPage({super.key}); | |
@override | |
Widget build(BuildContext context) => Scaffold( | |
appBar: AppBar(title: Text("Audio 2023"),), | |
floatingActionButton: FloatingActionButton( | |
child: Icon(Icons.play_arrow), | |
onPressed: () async{ | |
AudioPlayer audioPlayer = AudioPlayer(); | |
await audioPlayer.play( | |
AssetSource('sample/base.mp3') | |
); | |
}, | |
), | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment