I am not into Android, but wheather there is a seach related to term, "How to play custom sounds in flutter Splash Screen" Your post is following up and i am here to help the Flutter devs community who are not into kotlin, java etc. so no developer go bare hands so for flutter community people who may be searching for this term and not finding internet results I saved you for some place,
Use this kind of Code.
final player = AudioCache(); //Define the player
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return FutureBuilder(
future: Future.delayed(Duration(seconds: 3)),
builder: (context, AsyncSnapshot snapshot) {
// Show splash screen while waiting for app resources to load:
if (snapshot.connectionState == ConnectionState.waiting) {
player.play('sounds/notification_ambient.wav'); //Here is what will play sounds.
return MaterialApp(home: Splash());
} else {
// Loading is done, return the app:
return MaterialApp(
debugShowCheckedModeBanner: false,
home: TodoApp(),
title: 'Toodolee',
theme: ThemeData(
brightness: Brightness.light,
fontFamily: "WorkSans",
));
}
});
}
}
class Splash extends StatefulWidget {
@override
_SplashState createState() => _SplashState();
}
class _SplashState extends State<Splash> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
color: Colors.white70,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
FadeIn(
duration: Duration(milliseconds: 1200),
child: Center(
child: Icon(CarbonIcons.checkmark,
size: 90, color: Colors.black87)),
),
FadeOut(
duration: Duration(milliseconds: 1100),
child: Center(child: Text("Made by Proco :love"))),
],
),
),
);
}
}
Don't Forget to Import import 'package:audioplayers/audio_cache.dart';
import 'package:audioplayers/audioplayers.dart';
and in the pubspec.yaml do announce the place for audioplayers:
and in the assets too.
Hope it will help, Also You may find errors Regarding the sounds can't be played so don't worry, istead of playing sounds like this, player.play('assets\sounds/notification_ambient.wav');
play like, player.play('sounds/notification_ambient.wav');
don't mention assets always it sometimes don't work, So Enjoy... And Thanks..