Created
December 26, 2022 23:49
-
-
Save temoki/67c25c0e7594f18c7cb386b50970db49 to your computer and use it in GitHub Desktop.
[Flutter tips] Themeで囲ってデフォルトのアイコンサイズを変える
This file contains 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(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
final theme = Theme.of(context); | |
return MaterialApp( | |
title: 'Test', | |
debugShowCheckedModeBanner: false, | |
theme: ThemeData( | |
primarySwatch: Colors.blue, | |
), | |
home: Card( | |
child: Column( | |
children: [ | |
const Text('Default icon size.'), | |
const Icon(Icons.usb), | |
const SizedBox(height: 16), | |
// Themeで囲って、デフォルトのアイコンサイズを変える | |
const Text('Change default icon size.'), | |
Theme( | |
data: theme.copyWith(iconTheme: theme.iconTheme.copyWith(size: 48)), | |
child: const Icon(Icons.usb), | |
), | |
], | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment