Skip to content

Instantly share code, notes, and snippets.

@temoki
Created December 26, 2022 23:49
Show Gist options
  • Save temoki/67c25c0e7594f18c7cb386b50970db49 to your computer and use it in GitHub Desktop.
Save temoki/67c25c0e7594f18c7cb386b50970db49 to your computer and use it in GitHub Desktop.
[Flutter tips] Themeで囲ってデフォルトのアイコンサイズを変える
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