Skip to content

Commit 446079b

Browse files
authored
refactor(SearchResultWidget): replace Row with ListTile (#789)
1 parent 532224c commit 446079b

File tree

1 file changed

+30
-49
lines changed

1 file changed

+30
-49
lines changed

examples/flutter/github_search/lib/widget/search_result_widget.dart

Lines changed: 30 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -17,57 +17,38 @@ class SearchResultWidget extends StatelessWidget {
1717
return InkWell(
1818
key: ValueKey(item.url),
1919
onTap: () => showItem(context, item),
20-
child: Container(
21-
alignment: FractionalOffset.center,
22-
margin: const EdgeInsets.fromLTRB(16.0, 12.0, 16.0, 12.0),
23-
child: Row(
24-
crossAxisAlignment: CrossAxisAlignment.start,
25-
children: <Widget>[
26-
Container(
27-
margin: const EdgeInsets.only(right: 16.0),
28-
child: Hero(
29-
tag: item.fullName,
30-
child: ClipOval(
31-
child: Image.network(
32-
item.avatarUrl,
33-
width: 56.0,
34-
height: 56.0,
35-
),
36-
),
20+
child: Padding(
21+
padding:
22+
const EdgeInsets.symmetric(horizontal: 16.0, vertical: 12.0),
23+
child: ListTile(
24+
leading: Hero(
25+
tag: item.fullName,
26+
child: ClipOval(
27+
child: Image.network(
28+
item.avatarUrl,
29+
width: 56.0,
30+
height: 56.0,
3731
),
3832
),
39-
Expanded(
40-
child: Column(
41-
crossAxisAlignment: CrossAxisAlignment.start,
42-
children: <Widget>[
43-
Container(
44-
margin: const EdgeInsets.only(
45-
top: 6.0,
46-
bottom: 4.0,
47-
),
48-
child: Text(
49-
item.fullName,
50-
maxLines: 1,
51-
overflow: TextOverflow.ellipsis,
52-
style: const TextStyle(
53-
fontFamily: 'Montserrat',
54-
fontSize: 16.0,
55-
fontWeight: FontWeight.bold,
56-
),
57-
),
58-
),
59-
Text(
60-
item.url,
61-
style: const TextStyle(
62-
fontFamily: 'Hind',
63-
),
64-
maxLines: 1,
65-
overflow: TextOverflow.ellipsis,
66-
)
67-
],
68-
),
69-
)
70-
],
33+
),
34+
title: Text(
35+
item.fullName,
36+
maxLines: 1,
37+
overflow: TextOverflow.ellipsis,
38+
style: const TextStyle(
39+
fontFamily: 'Montserrat',
40+
fontSize: 16.0,
41+
fontWeight: FontWeight.bold,
42+
),
43+
),
44+
subtitle: Text(
45+
item.url,
46+
style: const TextStyle(
47+
fontFamily: 'Hind',
48+
),
49+
maxLines: 1,
50+
overflow: TextOverflow.ellipsis,
51+
),
7152
),
7253
),
7354
);

0 commit comments

Comments
 (0)