Coding Projects in Flutter: A Hands-On, Project-Based Introduction to Mobile App Development by Thornton Edward

Coding Projects in Flutter: A Hands-On, Project-Based Introduction to Mobile App Development by Thornton Edward

Author:Thornton, Edward [Thornton, Edward]
Language: eng
Format: epub
Publisher: Street Genius Publishing
Published: 2021-09-29T16:00:00+00:00


7. SongDuration

This function is used to format the song’s duration in milliseconds, but we’ll convert it into the more useful format 00:00. The format is a string 00:00 in this case. It returns — : — if the duration is nil; otherwise, it returns the duration in the supplied format.

String _formatDuration(Duration d) {

if (d == null) return "--:--";

int minute = d.inMinutes;

int second = (d.inSeconds > 60) ? (d.inSeconds % 60) : d.inSeconds;

String format = ((minute < 10) ? "0$minute" : "$minute") +

":" +

((second < 10) ? "0$second" : "$second");

return format;

}



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.