Skip to content

Instantly share code, notes, and snippets.

@Lxxyx
Created June 21, 2025 07:25
Show Gist options
  • Save Lxxyx/ca414cec95c28a337c2e01eeda465bd0 to your computer and use it in GitHub Desktop.
Save Lxxyx/ca414cec95c28a337c2e01eeda465bd0 to your computer and use it in GitHub Desktop.
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: ListView.builder(
itemCount: 10,
itemBuilder: (context, index) {
return MusicItemCard(
title: 'Music $index',
artist: 'Artist $index',
album: 'Album $index',
);
},
),
);
}
}
class MusicItemCard extends StatelessWidget {
final String title;
final String artist;
final String album;
const MusicItemCard({
super.key,
required this.title,
required this.artist,
required this.album,
});
@override
Widget build(BuildContext context) {
return Card(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Row(
children: [
const Icon(
Icons.music_note,
size: 40,
),
const SizedBox(width: 16),
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,
),
],
),
const Spacer(),
const Icon(Icons.play_circle),
],
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment