ListTileクラスの文字のデフォルトのフォントサイズを変更したい。
ListTitleクラスでつかTextクラスのフォントサイズはTextThemaクラスのsubtitle1プロパティで設定されておりsizeは16だ。
なぜsubtitle1のプロパティなのかはドキュメントを探しても見当たらないのでわかる人がいたら教えてほしい。
よってTextクラスのデフォルトのフォントサイズを変えるには以下のように記載する。
textTheme: TextTheme(
subtitle1: TextStyle(fontSize: 180.0),
),
コードの全体も記載する。
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
static const String _title = 'Flutter Code Sample';
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
textTheme: TextTheme(
subtitle1: TextStyle(fontSize: 180.0),
),
),
title: _title,
home: Scaffold(
appBar: AppBar(title: const Text(_title)),
body: const Center(
child: MyStatefulWidget(),
),
),
);
}
}
class MyStatefulWidget extends StatefulWidget {
const MyStatefulWidget({Key? key}) : super(key: key);
@override
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
}
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
bool _lights = false;
@override
Widget build(BuildContext context) {
return Column(children: [
ListTile(title: Text("ListTitle"), leading: Icon(Icons.ac_unit)),
]);
}
}