I want to add background audio in my splash screen. So tried the below code. But I got some exceptions. Anyone pls help me to solve this.Here I use the package Flutter Sound.
-------------This is My Code-----------------
import 'dart:async';
import 'package:FlutterNewApp/Screens/HomeMain.dart';
import 'package:flutter/material.dart';
import 'package:animated_text_kit/animated_text_kit.dart';
import 'package:flutter_sound/flutter_sound.dart';
class Splash extends StatefulWidget {
@override
_SplashState createState() => _SplashState();
}
class _SplashState extends State<Splash> {
@override
void initState() {
FlutterSound flutterSound = FlutterSound();
flutterSound.thePlayer.startPlayer(fromURI: 'assets/audio/splash.mp3');//My splash.mp3 is inside the audio folder in assets folder
super.initState();
Timer(
Duration(minutes: 50),
() => Navigator.pushReplacement(
context, MaterialPageRoute(builder: (context) => HomeMain())));
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Center(
child: AnimatedTextKit(
totalRepeatCount: 1,
//repeatForever: true,
animatedTexts: [
TyperAnimatedText(
'Tofee Ride',
//speed: Duration(milliseconds: 50),
textStyle: TextStyle(
fontFamily: 'Ultra-Regular',
color: Colors.pink[600],
fontSize: 30,
)
),
]),
),
Center
(child:AnimatedTextKit(
totalRepeatCount: 1,
//repeatForever: true,
animatedTexts: [
TyperAnimatedText('Learning App for classes I - IV')
]) ,)
],)
);
}
}
Exception is given below. Pls Help. Here I use the Package Flutter Sound.