Created
March 3, 2025 06:00
-
-
Save Lxxyx/18148689bcda9241ddfaadb8e5fb7da1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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:flutter/material.dart'; | |
void main() => runApp(const MyApp()); | |
class MyApp extends StatelessWidget { | |
const MyApp({super.key}); | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Music Item Card', | |
debugShowCheckedModeBanner: false, | |
theme: ThemeData( | |
colorSchemeSeed: Colors.blue, | |
), | |
home: const MyHomePage(title: 'Music Item Card'), | |
); | |
} | |
} | |
class MyHomePage extends StatelessWidget { | |
final String title; | |
const MyHomePage({ | |
super.key, | |
required this.title, | |
}); | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text(title), | |
), | |
body: Padding( | |
padding: const EdgeInsets.all(16.0), | |
child: MusicItemCard( | |
title: 'Music Title', | |
artist: 'Artist Name', | |
album: 'Album Name', | |
duration: '03:45', | |
imageUrl: 'https://via.placeholder.com/150', | |
), | |
), | |
); | |
} | |
} | |
class MusicItemCard extends StatelessWidget { | |
final String title; | |
final String artist; | |
final String album; | |
final String duration; | |
final String imageUrl; | |
const MusicItemCard({ | |
super.key, | |
required this.title, | |
required this.artist, | |
required this.album, | |
required this.duration, | |
required this.imageUrl, | |
}); | |
@override | |
Widget build(BuildContext context) { | |
return Card( | |
child: Row( | |
children: [ | |
Image.network( | |
imageUrl, | |
width: 50, | |
height: 50, | |
fit: BoxFit.cover, | |
), | |
const SizedBox(width: 16), | |
Expanded( | |
child: Column( | |
crossAxisAlignment: CrossAxisAlignment.start, | |
children: [ | |
Text( | |
title, | |
style: Theme.of(context).textTheme.titleMedium, | |
), | |
Text( | |
artist, | |
style: Theme.of(context).textTheme.bodySmall, | |
), | |
Text( | |
album, | |
style: Theme.of(context).textTheme.bodySmall, | |
), | |
], | |
), | |
), | |
Text( | |
duration, | |
style: Theme.of(context).textTheme.bodySmall, | |
), | |
], | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment