23
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Flutter style設定(カラー、フォントサイズ、フォントスタイル等)

Last updated at Posted at 2019-10-28

部分的スタイリング変更は下記のように書けると思います。下記の例だとTestという文字をスタイリングしています。

test.dart
child: Text(
  'Test',
   style: TextStyle(
     fontWeight: FontWeight.bold,
     fontSize: 20,
     color: Theme.of(context).primaryColor,
     ),
  ),

変更する箇所をglobalに設定したい場合は、下記のthemeのtextThemeの記述のように書けます。
textTheme > textということになります。

main.dart
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Test App',
      theme: ThemeData(
          primarySwatch: Colors.grey,
          accentColor: Colors.amber,
          fontFamily: 'Quicksand',
          textTheme: ThemeData.light().textTheme.copyWith(
                title: TextStyle(
                  fontFamily: 'OpenSans',
                  fontWeight: FontWeight.bold,
                  fontSize: 18,
                ),
              ),
          appBarTheme: AppBarTheme(
            textTheme: ThemeData.light().textTheme.copyWith(
                  title: TextStyle(
                    fontFamily: 'OpenSans',
                    fontSize: 20,
                    fontWeight: FontWeight.bold,
                  ),
                ),
          )),
23
15
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
23
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?