Skip to content

Commit ea4adef

Browse files
authored
Merge pull request #47 from shravyackm/new-listtile
New listtile
2 parents 859a6dc + e6efd21 commit ea4adef

File tree

1 file changed

+52
-93
lines changed

1 file changed

+52
-93
lines changed

lib/components/list_tile/gf_list_tile.dart

Lines changed: 52 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ import 'package:getflutter/colors/gf_color.dart';
44
import 'package:getflutter/components/avatar/gf_avatar.dart';
55

66
class GFListTile extends StatelessWidget {
7+
///type of [String] used to pass text, alternative to title property and gets higher priority than title
8+
final String titleText;
9+
10+
///type of [String] used to pass text, alternative to subtitle property and gets higher priority than subtitle
11+
final String subtitleText;
12+
713
/// The GFListTile's background color. Can be given [Colors] or [GFColor]
814
final dynamic color;
915

@@ -19,110 +25,63 @@ class GFListTile extends StatelessWidget {
1925
/// The description to display inside the [GFListTile]. see [Text]
2026
final Widget description;
2127

22-
/// The description to display inside the [GFListTile]. see [Text]
23-
final Widget trailing;
24-
2528
/// The icon to display inside the [GFListTile]. see [Icon]
2629
final Widget icon;
2730

28-
///type of [bool] corresponds to true or false to show or hide the divider
29-
final bool showDivider;
30-
31-
/// The empty space that surrounds the card. Defines the card's outer [Container.padding]..
32-
final EdgeInsetsGeometry padding;
33-
34-
/// The divider's height extent.
35-
///
36-
/// The divider itself is always drawn as a horizontal line that is centered
37-
/// within the height specified by this value.
38-
///
39-
/// If this is null, then the [DividerThemeData.space] is used. If that is
40-
/// also null, then this defaults to 16.0.
41-
final double dividerHeight;
42-
43-
/// The thickness of the line drawn within the divider.
44-
///
45-
/// A divider with a [thickness] of 0.0 is always drawn as a line with a
46-
/// height of exactly one device pixel.
47-
///
48-
/// If this is null, then the [DividerThemeData.dividerThickness] is used. If
49-
/// that is also null, then this defaults to 0.0.
50-
final double dividerThickness;
51-
52-
/// The amount of empty space to the leading edge of the divider.
53-
///
54-
/// If this is null, then the [DividerThemeData.indent] is used. If that is
55-
/// also null, then this defaults to 0.0.
56-
final double dividerIndent;
57-
58-
/// The amount of empty space to the trailing edge of the divider.
59-
///
60-
/// If this is null, then the [DividerThemeData.endIndent] is used. If that is
61-
/// also null, then this defaults to 0.0.
62-
final double dividerEndIndent;
63-
64-
/// The color to use when painting the line.
65-
///
66-
/// If this is null, then the [DividerThemeData.color] is used. If that is
67-
/// also null, then [ThemeData.dividerColor] is used.
68-
final Color dividerColor;
69-
7031
/// Creates ListTile with leading, title, trailing, image widget for almost every type of ListTile design.
71-
const GFListTile(
72-
{Key key,
73-
this.color,
74-
this.avatar,
75-
this.title,
76-
this.subTitle,
77-
this.description,
78-
this.icon,
79-
this.showDivider = true,
80-
this.padding,
81-
this.trailing,
82-
this.dividerEndIndent,
83-
this.dividerHeight,
84-
this.dividerIndent,
85-
this.dividerThickness,
86-
this.dividerColor})
87-
: super(key: key);
32+
const GFListTile({
33+
Key key,
34+
this.titleText,
35+
this.subtitleText,
36+
this.color,
37+
this.avatar,
38+
this.title,
39+
this.subTitle,
40+
this.description,
41+
this.icon,
42+
}) : super(key: key);
8843

8944
@override
9045
Widget build(BuildContext context) {
91-
return Column(
92-
crossAxisAlignment: CrossAxisAlignment.start,
93-
children: <Widget>[
94-
Container(
95-
margin: padding,
96-
color: color,
97-
child: ListTile(
98-
leading: avatar,
99-
title: title,
100-
subtitle: subTitle != null || description != null
101-
? Column(
46+
return Container(
47+
constraints: BoxConstraints(minHeight: 50),
48+
padding: EdgeInsets.all(8),
49+
decoration: BoxDecoration(
50+
color: color,
51+
borderRadius: BorderRadius.all(Radius.circular(5)),
52+
),
53+
child: Row(
54+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
55+
children: <Widget>[
56+
avatar != null ? avatar : Container(),
57+
Expanded(
58+
child: Padding(
59+
padding: EdgeInsets.only(left: 10, right: 10),
60+
child: Column(
10261
crossAxisAlignment: CrossAxisAlignment.start,
10362
children: <Widget>[
104-
subTitle ?? Container(),
63+
titleText != null
64+
? Text(
65+
titleText,
66+
style: TextStyle(
67+
fontSize: 17,
68+
fontWeight: FontWeight.w500,
69+
color: getGFColor(GFColor.dark)),
70+
)
71+
: title ?? Container(),
72+
subtitleText != null
73+
? Text(
74+
subtitleText,
75+
style: TextStyle(
76+
fontSize: 14.5, color: Colors.black54),
77+
)
78+
: subTitle ?? Container(),
10579
description ?? Container()
10680
],
107-
)
108-
: Container(),
109-
trailing: Padding(padding: EdgeInsets.only(top: 16.0), child: icon),
110-
),
111-
),
112-
showDivider == true
113-
? Divider(
114-
height: dividerHeight == null ? 16.0 : dividerHeight,
115-
thickness: dividerThickness == null ? 1.0 : dividerThickness,
116-
color: dividerColor == null
117-
? Theme.of(context).dividerColor
118-
: dividerColor,
119-
indent: dividerIndent == null ? 0.0 : dividerIndent,
120-
endIndent: dividerEndIndent == null ? 0.0 : dividerEndIndent,
121-
)
122-
: Container(
123-
height: 10.0,
124-
)
125-
],
81+
))),
82+
icon != null ? icon : Container(),
83+
],
84+
),
12685
);
12786
}
12887
}

0 commit comments

Comments
 (0)