音楽プレーヤー:曲情報
CoddyのFlutterジャーニー「画面サイズに合わせたレイアウト」セクションの一部。レッスン 27/30。
アートの下には、曲名とアーティスト名を配置します。名刺に書かれた名前のように、曲名は目が最初に見つけるべき行です。大きく太字にします。アーティスト名はその下に、控えめなグレーの文字で表示します。
アートは大きな形で、タイトルは小さな形なので、その間には余白が必要です。タイトルとアーティスト名はひとまとまりなので、その間の余白よりも大きくします。要素をグループ化する余白が、画面を読みやすくします。
チャレンジ
簡単アートの下に、次のものを追加します。
SizedBox(height: 24)Midnight Drive、サイズは24で太字SizedBox(height: 4)Colors.greyのThe Night Owls
自分で試してみよう
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
),
home: Scaffold(
appBar: AppBar(title: const Text('Now Playing')),
body: Padding(
padding: const EdgeInsets.all(24),
child: Column(
children: [
Stack(
children: [
Container(
width: double.infinity,
height: 300,
decoration: BoxDecoration(
color: Colors.deepPurple,
borderRadius: BorderRadius.circular(24),
),
child: const Center(
child: Icon(Icons.album, size: 120, color: Colors.white),
),
),
Positioned(
top: 12,
right: 12,
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(
color: Colors.black54,
borderRadius: BorderRadius.circular(8),
),
child: const Text(
'HD',
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
),
),
),
],
),
],
),
),
),
);
}
}
このレッスンには短いクイズがあります。レッスンを始めて解答し、進捗を記録しましょう。
画面サイズに合わせたレイアウトのすべてのレッスン
自分で練習してみよう: Flutterオンラインコンパイラ