Advertisement
Guest User

AudioCache

a guest
Nov 18th, 2019
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 0.94 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2. import 'package:audioplayers/audio_cache.dart';
  3.  
  4. void main() => runApp(MyApp());
  5.  
  6. class MyApp extends StatelessWidget {
  7.   // This widget is the root of your application.
  8.   @override
  9.   Widget build(BuildContext context) {
  10.     return MaterialApp(
  11.       title: 'Flutter Demo',
  12.       theme: ThemeData(
  13.         primarySwatch: Colors.blue,
  14.       ),
  15.       home: MyHomePage(),
  16.     );
  17.   }
  18. }
  19.  
  20. class MyHomePage extends StatefulWidget {
  21.   @override
  22.   _MyHomePageState createState() => _MyHomePageState();
  23. }
  24.  
  25. class _MyHomePageState extends State<MyHomePage> {
  26.  
  27.   static AudioCache _audioCache = new AudioCache();
  28.  
  29.   @override
  30.   void initState() {
  31.     // TODO: implement initState
  32.     super.initState();
  33.     _audioCache.play('assets/jogando.mp3');
  34.   }
  35.  
  36.   @override
  37.   Widget build(BuildContext context) {
  38.     return Scaffold(
  39.       body: Center(
  40.         child: Text("player")
  41.       ),
  42.     );
  43.   }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement