Closed
Description
Similar to ElevatedButtonTheme
, TextButtonTheme
, It would be nice to have IconButtonTheme
, to style different icon buttons in a sliver app bar for example.
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData.dark(useMaterial3: true),
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(),
body: Center(
child: MyWidget(),
),
),
);
}
}
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Theme(
data: Theme.of(context).copyWith(
elevatedButtonTheme: ElevatedButtonThemeData(
style: const ButtonStyle(
backgroundColor: MaterialStatePropertyAll(Colors.orange),
),
),
),
child: Column(
children: [
IconButton(
onPressed: () {},
icon: const Icon(Icons.more_vert),
),
IconButton(
style: const ButtonStyle(
backgroundColor: MaterialStatePropertyAll(Colors.orange),
),
onPressed: () {},
icon: const Icon(Icons.more_vert),
),
ElevatedButton(
onPressed: () {},
child: const Icon(Icons.more_vert),
),
],
),
);
}
}