Skip to content

Commit 8e95406

Browse files
committed
feat: add new PlatformListTile
1 parent 2c0953c commit 8e95406

File tree

3 files changed

+109
-1
lines changed

3 files changed

+109
-1
lines changed

lib/src/platform/decorated_platform_textfield.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ class DecoratedPlatformTextField extends StatelessWidget {
372372
/// Should the label be shown at all on cupertino?
373373
final bool cupertinoShowLabel;
374374

375-
/// When the label is shown in cupertino, should it be rathered placed on top (instead of before) the input field?
375+
/// When the label is shown in cupertino, should it be rather placed on top (instead of before) the input field?
376376
final bool cupertinoAlignLabelOnTop;
377377

378378
/// When the suffix should be shown on cupertino

lib/src/platform/platform.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ export 'dialog_helper.dart';
2323
export 'platform_icons.dart';
2424
export 'platform_toggle_buttons.dart';
2525
export 'platform_inkwell.dart';
26+
export 'platform_list_tile.dart';
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import 'package:flutter/cupertino.dart';
2+
import 'package:flutter/material.dart';
3+
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
4+
5+
/// Uses either a `ListTile` or a `CupertinoListTile`
6+
class PlatformListTile extends StatelessWidget {
7+
const PlatformListTile({
8+
Key? key,
9+
this.widgetKey,
10+
this.leading,
11+
required this.title,
12+
this.subtitle,
13+
this.trailing,
14+
this.isThreeLine = false,
15+
this.onTap,
16+
this.onLongPress,
17+
this.visualDensity,
18+
this.selected = false,
19+
this.mouseCursor,
20+
this.dense,
21+
this.shape,
22+
this.contentPadding,
23+
this.enabled = true,
24+
this.focusColor,
25+
this.hoverColor,
26+
this.focusNode,
27+
this.autofocus = false,
28+
this.tileColor,
29+
this.selectedTileColor,
30+
this.enableFeedback,
31+
this.horizontalTitleGap,
32+
this.minVerticalPadding,
33+
this.minLeadingWidth,
34+
}) : super(key: key);
35+
36+
final Key? widgetKey;
37+
final Widget? leading;
38+
final Widget title;
39+
final Widget? subtitle;
40+
final Widget? trailing;
41+
final bool isThreeLine;
42+
final void Function()? onTap;
43+
44+
/// Callback for long press gesture - only usable on Material
45+
final void Function()? onLongPress;
46+
47+
/// Material-only mouse cursor
48+
final MouseCursor? mouseCursor;
49+
final bool selected;
50+
final bool? dense;
51+
final VisualDensity? visualDensity;
52+
final ShapeBorder? shape;
53+
final EdgeInsetsGeometry? contentPadding;
54+
final bool enabled;
55+
final Color? focusColor;
56+
final Color? hoverColor;
57+
final Color? tileColor;
58+
final Color? selectedTileColor;
59+
final FocusNode? focusNode;
60+
final bool autofocus;
61+
final bool? enableFeedback;
62+
final double? horizontalTitleGap;
63+
final double? minVerticalPadding;
64+
final double? minLeadingWidth;
65+
66+
@override
67+
Widget build(BuildContext context) {
68+
return PlatformWidget(
69+
material: (context, platform) => ListTile(
70+
key: widgetKey,
71+
leading: leading,
72+
title: title,
73+
subtitle: subtitle,
74+
trailing: trailing,
75+
isThreeLine: isThreeLine,
76+
dense: dense,
77+
visualDensity: visualDensity,
78+
shape: shape,
79+
contentPadding: contentPadding,
80+
enabled: enabled,
81+
onTap: onTap,
82+
onLongPress: onLongPress,
83+
mouseCursor: mouseCursor,
84+
selected: selected,
85+
focusColor: focusColor,
86+
hoverColor: hoverColor,
87+
focusNode: focusNode,
88+
autofocus: autofocus,
89+
tileColor: tileColor,
90+
selectedTileColor: selectedTileColor,
91+
enableFeedback: enableFeedback,
92+
horizontalTitleGap: horizontalTitleGap,
93+
minVerticalPadding: minVerticalPadding,
94+
minLeadingWidth: minLeadingWidth,
95+
),
96+
cupertino: (context, platform) => CupertinoListTile(
97+
key: widgetKey,
98+
leading: leading,
99+
title: title,
100+
subtitle: subtitle,
101+
trailing: trailing,
102+
leadingSize: (dense ?? false) ? 14 : 28,
103+
onTap: onTap,
104+
),
105+
);
106+
}
107+
}

0 commit comments

Comments
 (0)