Skip to content

Commit 0c1bb1b

Browse files
committed
refactor: the nested ListView should not scrollable
- Use physics NeverScrollableScrollPhysics
1 parent 5cb102d commit 0c1bb1b

File tree

3 files changed

+41
-42
lines changed

3 files changed

+41
-42
lines changed

client/lib/screens/detail_screen.dart

+39-42
Original file line numberDiff line numberDiff line change
@@ -46,53 +46,50 @@ class DetailScreen extends StatelessWidget {
4646
YoutubeWidget(youtubeId: extractYoutubeId(args.video.link))),
4747
Flexible(
4848
flex: 6,
49-
child: ListView(children: [
50-
Container(
51-
margin: const EdgeInsets.only(top: 5, left: 10, right: 10),
52-
child: Column(
53-
children: [
54-
FittedBox(child: HeaderWidget(video: args.video)),
55-
const SizedBox(height: 15),
56-
FutureBuilder<Detail>(
57-
future:
58-
context.read<GrpcClient>().getDetail(args.video.prId),
59-
builder: (context, AsyncSnapshot<Detail> snapshot) {
60-
if (!snapshot.hasData) {
61-
return const Center(
62-
child: CircularProgressIndicator());
63-
}
49+
child: Padding(
50+
padding: const EdgeInsets.all(10).copyWith(bottom: 0),
51+
child: ListView(
52+
children: [
53+
FittedBox(child: HeaderWidget(video: args.video)),
54+
const SizedBox(height: 15),
55+
FutureBuilder<Detail>(
56+
future:
57+
context.read<GrpcClient>().getDetail(args.video.prId),
58+
builder: (context, AsyncSnapshot<Detail> snapshot) {
59+
if (!snapshot.hasData) {
60+
return const Center(child: CircularProgressIndicator());
61+
}
6462

65-
detail = snapshot.data;
63+
detail = snapshot.data;
6664

67-
final papers = detail?.papers ?? [];
68-
final relevantPapers = detail?.relevantPapers ?? [];
69-
final sameAuthorPapers = detail?.sameAuthorPapers ?? [];
65+
final papers = detail?.papers ?? [];
66+
final relevantPapers = detail?.relevantPapers ?? [];
67+
final sameAuthorPapers = detail?.sameAuthorPapers ?? [];
7068

71-
return Column(
72-
crossAxisAlignment: CrossAxisAlignment.stretch,
73-
children: [
74-
PaperAbstractWidget(paper: papers.first),
75-
const SizedBox(height: 15),
69+
return Column(
70+
crossAxisAlignment: CrossAxisAlignment.stretch,
71+
children: [
72+
PaperAbstractWidget(paper: papers.first),
73+
const SizedBox(height: 15),
7674

77-
// Shows Recommendation only when there's one.
78-
if (papers.length +
79-
relevantPapers.length +
80-
sameAuthorPapers.length >=
81-
1)
82-
RecommendationWidget(detail: detail!),
83-
const SizedBox(height: 15),
75+
// Shows Recommendation only when there's one.
76+
if (papers.length +
77+
relevantPapers.length +
78+
sameAuthorPapers.length >=
79+
1)
80+
RecommendationWidget(detail: detail!),
81+
const SizedBox(height: 15),
8482

85-
if (papers.isNotEmpty)
86-
RepositoryWidget(
87-
repositories: papers.first.repositories,
88-
)
89-
]);
90-
},
91-
)
92-
],
93-
),
94-
)
95-
]),
83+
if (papers.isNotEmpty)
84+
RepositoryWidget(
85+
repositories: papers.first.repositories,
86+
)
87+
]);
88+
},
89+
)
90+
],
91+
),
92+
),
9693
)
9794
],
9895
),

client/lib/widgets/detail/recommendation.dart

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class RecommendationWidget extends StatelessWidget {
2424
)),
2525
ListView.builder(
2626
shrinkWrap: true,
27+
physics: const NeverScrollableScrollPhysics(),
2728
itemCount: refPapers.length,
2829
itemBuilder: (BuildContext context, int index) =>
2930
_Paper(paper: refPapers[index]))

client/lib/widgets/detail/repository.dart

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class RepositoryWidget extends StatelessWidget {
2626
)),
2727
ListView.builder(
2828
shrinkWrap: true,
29+
physics: const NeverScrollableScrollPhysics(),
2930
itemCount: visibleRepositories.length,
3031
itemBuilder: (context, index) =>
3132
_RepositoryItem(repo: visibleRepositories[index]),

0 commit comments

Comments
 (0)