سلام
اگر بخوایم یه قسمتی از صفحه اسکرول بخوره باید چکار کنیم؟
من این سوال رو قبلا پرسیده بودم
سلام. میتونید از SingleChildScrollView و یا ListView استفاده کنید.
این کاری که گفتین منطقی نیست چون ممکنه دیوایس کاربر کوچیک باشه و لیست پایین رو نتونه ببینه.
اما برای چنین تسکی میتونید از column استفاده کنید و لیست پایین رو داخل listview قرار بدین.
این پاسخها رو دادین
من listview رو داخل یه کانتینر گذاشتم و یه ارتفاع دادم و مشکل حل شد
ولی
از ارتفاع دستی برای لیستها علی الخصوص لیستهای عمودی سعی کنید استفاده نکنید چون داینامیک هست ارتفاع.
این پاسخ رو دادین
حالا سوال من اینه که با راه حل هایی که گفتین ارور میده یعنی با column و SingleChildScrollView
شاید هم من اشتباه متوجه شدم و جای درستی نزاشتم
من کد رو میزارم
میخوام این لیست ویو یه ارتفاعی داشته باشه و داخل خودش اسکرول بخوره
چون گفتین ارتفاع دادن راه درستی نیست دوباره سوال پرسیدم
Expanded(
child: ListView.builder(
itemCount: posts.length,
itemBuilder: (context, index) {
final post = posts[index];
return Post(post: post);
}),
)
class Post extends StatelessWidget {
final PostData post;
Post({super.key, required this.post});
@override
Widget build(BuildContext context) {
return InkWell(
onTap: () {
Navigator.of(context)
.push(MaterialPageRoute(builder: (context) => SimpleScreen(tabname: "home")));
},
child: Container(
margin: EdgeInsets.fromLTRB(32, 8, 32, 8),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16),
boxShadow: [BoxShadow(blurRadius: 10, color: Color(0x1a5282ff))]),
child: Row(
children: [
ClipRRect(
borderRadius: BorderRadius.circular(16),
child: Image.asset(
"assets/img/posts/small/${post.imageFileName}",
width: 120,
)),
Expanded(
child: Padding(
padding: const EdgeInsets.fromLTRB(16, 0, 16, 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
post.caption,
style: TextStyle(
fontFamily: FontFamily.avenir,
color: Color(0xff376AED),
fontWeight: FontWeight.w700,
fontSize: 14),
),
SizedBox(
height: 8,
),
Text(
post.title,
style: Theme.of(context).textTheme.subtitle2,
),
SizedBox(
height: 16,
),
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Icon(
CupertinoIcons.hand_thumbsup,
size: 16,
color: Theme.of(context).textTheme.bodyText2!.color,
),
SizedBox(
width: 4,
),
Text(
post.likes,
style: Theme.of(context).textTheme.bodyText2,
),
SizedBox(
width: 16,
),
Icon(
CupertinoIcons.clock,
size: 16,
color: Theme.of(context).textTheme.bodyText2!.color,
),
SizedBox(
width: 4,
),
Text(
post.time,
style: Theme.of(context).textTheme.bodyText2,
),
Expanded(
child: Container(
alignment: Alignment.centerRight,
child: Icon(
post.isBookmarked
? CupertinoIcons.bookmark_fill
: CupertinoIcons.bookmark,
size: 16,
color: Theme.of(context)
.textTheme
.bodyText2!
.color,
))),
],
)
],
),
),
)
],
),
),
);
}
}