-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathsettings_tile.dart
More file actions
51 lines (45 loc) · 1.29 KB
/
settings_tile.dart
File metadata and controls
51 lines (45 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import 'package:flutter/material.dart';
import 'list_tile_separator.dart';
/// A reusable settings list tile widget that combines a [ListTile]
/// with an optional [ListTileSeparator] below it.
///
/// Displays a leading [Icon], a text [title], an optional [trailing]
/// widget, and can show or hide the separator via [showSeparator].
class SettingsTile extends StatelessWidget {
const SettingsTile({
required this.title,
required this.icon,
required this.onTap,
this.iconColor,
this.trailing,
this.textStyle,
this.showSeparator = true,
this.enabled = true,
this.opacity = 1.0,
super.key,
});
final String title;
final IconData icon;
final Color? iconColor;
final Widget? trailing;
final TextStyle? textStyle;
final bool showSeparator;
final VoidCallback onTap;
final bool enabled;
final double opacity;
@override
Widget build(BuildContext context) {
final tile = Opacity(
opacity: opacity,
child: ListTile(
leading: Icon(icon, color: iconColor),
title: Text(title, style: textStyle),
trailing: trailing,
onTap: onTap,
enabled: enabled,
),
);
if (!showSeparator) return tile;
return Column(mainAxisSize: MainAxisSize.min, children: [tile, const ListTileSeparator()]);
}
}