[英]How do i put a listview under a box decroation with buttons inside?
iam still new in flutter and i wanted to make a homepage with a button and a listview in my app.我在 flutter 还是新手,我想在我的应用程序中制作一个带有按钮和列表视图的主页。 so here is my expected homepage that i already designed所以这是我已经设计好的预期主页
as you guys can see i wanted to have a listvew in the button half of my homepage, and a boxdecoration with buttons infront of an image in the top half.正如你们所看到的,我想在主页的按钮部分有一个列表视图,在上半部分的图像前面有一个带有按钮的框装饰。
but so far my homepage looks like this但到目前为止我的主页看起来像这样
actual homepage so far到目前为止的实际主页
here is my code for the homepage so far到目前为止,这是我的主页代码
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get/get_navigation/get_navigation.dart';
import 'package:medreminder/NewsArticle/news_home.dart';
import 'package:medreminder/Reminder/ui/theme.dart';
import 'Reminder/home_reminder.dart';
import 'Reminder/ui/widgets/button.dart';
import 'package:medreminder/main.dart';
import 'package:medreminder/home_page.dart';
void main() {
// debugPaintSizeEnabled = true;
runApp(const HomePage());
}
class HomePage extends StatelessWidget {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
backgroundColor: context.theme.backgroundColor,
appBar: AppBar(
backgroundColor: Color(0XFF0080FE),
title: const Text('Medicine Reminder App'),
),
body: Column(
children: [
Stack(
children: [
Image.asset(
'images/MenuImg.jpg',
width: 600,
height: 170,
fit: BoxFit.cover,
),
],
),
const SizedBox(height: 15.0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Column(
children: [
IconButton(
icon: Image.asset('images/reminder.png'),
iconSize: 50,
onPressed: () {
Navigator.of(context, rootNavigator: true).push(
MaterialPageRoute(builder: (context) => const ReminderHomePage()),
);
},
),
Text("Reminder\n", style: normalStyle,)
],
),
Column(
children: [
IconButton(
icon: Image.asset('images/news.png'),
iconSize: 50,
onPressed: () {
Navigator.of(context, rootNavigator: true).push(
MaterialPageRoute(builder: (context) => const NewsHomePage()),
);
},
),
Text(" News \n& Article", style: normalStyle)
],
),
Column(
children: [
IconButton(
icon: Image.asset('images/recipe.png'),
iconSize: 50,
onPressed: () {},
),
Text("Healty Food \n Recipe", style: normalStyle)
],
),
],
),
],
),
),
);
}
}
any help would mean so much to me, thank you guys任何帮助对我来说意义重大,谢谢你们
Please read more about Container's boxDecoration and ListView widgets请阅读有关 Container 的 boxDecoration 和 ListView 小部件的更多信息
ListView.builder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: 5,
itemBuilder: (context, index) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
decoration: BoxDecoration(
border: Border.all(color: Colors.black),
borderRadius: BorderRadius.circular(20)),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Container(
height: 50,
width: 50,
decoration: BoxDecoration(boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 1,
blurRadius: 1,
// offset: Offset(0,
// 1), // changes position of shadow
),
], color: Colors.white),
),
),
SizedBox(
width: 10,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [Text('Title'), Text('SubTitle')],
)
],
),
),
),
);
},
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.