In Flutter List view, i created a large container with listview, inside it i have two containers. The container with the text on the top should not be scrollable. Since it is the container in the background, if i disable the scrolling, the whole is struck. i just need to disable a text with heading"Announcement" to be non scrollable. I tried many ways. nothing is working out.
Example
class _HomegemState extends State<Homegem> {
@override
Widget cont() {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black12,
blurRadius: 8.0,
spreadRadius: 0.5,
)
],
borderRadius: BorderRadius.circular(20),
border: Border.all(
color: Colors.white10,
),
),
child:Column(
mainAxisSize: MainAxisSize.max,
children: [
Padding(
padding: EdgeInsets.symmetric(vertical: 9.0),
child: Text(
'Covid-19 instructions',
style: TextStyle(
fontFamily: 'Roboto',
fontWeight: FontWeight.bold,
fontSize: 16,
),
),
),
Padding(
padding: EdgeInsets.fromLTRB(18,0,16,0),
child: Text(
'Tenants are advised to wear mask and follow social distancing protocols inside the facility.\n Most people infected with the COVID-19 virus will experience mild to moderate respiratory illness and recover without requiring special treatment.\n Most people infected with the COVID-19 virus will experience mild to moderate respiratory illness and recover without requiring special treatment.\n luctus nec ullamcorper mattis, pulvinar dapibus leo \n',
style: TextStyle(
fontFamily: 'Roboto',
fontSize: 15,
// letterSpacing: 1.5,
),
textAlign: TextAlign.justify ,
),
),
],
),
),
);
}
Widget conttwo() {
return Padding(
padding: EdgeInsets.all(10),
child: Container(
// width: MediaQuery.of(context).size.width/1.05,
// height: MediaQuery.of(context).size.height * 0.18,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10),
border: Border.all(
color: Colors.white10,
),
boxShadow: [
BoxShadow(
color: Colors.black12,
blurRadius: 8.0,
spreadRadius: 0.5,
)
],
),
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Padding(
padding: EdgeInsets.symmetric(vertical: 8.0),
child: Text(
'Lorem ipsum',
style: TextStyle(
fontFamily: 'Roboto',
fontWeight: FontWeight.bold,
fontSize: 16,
),
),
),
Padding(
padding: EdgeInsets.fromLTRB(12, 0, 13, 0),
child: Text(
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo luctus nec ullamcorper mattis, pulvinar dapibus leo luctus nec ullamcorper mattis, pulvinar dapibus leo',
style: TextStyle(
fontFamily: 'Poppins',
fontSize: 15,
// letterSpacing: 1.6,
),
textAlign: TextAlign.justify,
),
)
],
),
),
);
}
body: SafeArea(
child: Column(
children: [
Container(
// height: MediaQuery.of(context).size.height / 3.15,
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
SizedBox(
height: 80,
),
Container(
width: MediaQuery.of(context).size.width/2.6,
height: MediaQuery.of(context).size.height * 0.11,
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black12,
blurRadius: 8.0,
spreadRadius: 0.5,
// offset: Offset(
// 15.0, // Move to right 10 horizontally
// 15.0, // Move to bottom 10 Vertically
// ),
)
],
borderRadius: BorderRadius.circular(10),
border: Border.all(
color: Colors.white10,
),
),
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Icon(
Icons.campaign_outlined,
color: Colors.black,
size: 45,
),
Text(
'Announcement',
style: TextStyle(
fontFamily: 'Roboto',
fontSize: 14,
fontWeight: FontWeight.w900,
color: Color(0xfff2B2B2B),
),
)
],
),
//BoxShadow
),
Container(
width: MediaQuery.of(context).size.width/2.6,
height: MediaQuery.of(context).size.height * 0.11,
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black12,
blurRadius: 8.0,
spreadRadius: 0.5,
)
],
borderRadius: BorderRadius.circular(10),
border: Border.all(
color: Colors.white10,
),
),
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Icon(
Icons.mood_bad_sharp,
color: Colors.black,
size: 45,
),
Text(
'Offers',
style: TextStyle(
fontFamily: 'Roboto',
fontSize: 14,
fontWeight: FontWeight.w900,
color: Color(0xfff2B2B2B),
),
)
],
),
)
],
),
Padding(
padding: EdgeInsets.fromLTRB(0, 7, 0, 0),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
SizedBox(
height: 110,
),
Container(
width: MediaQuery.of(context).size.width/2.6,
height: MediaQuery.of(context).size.height * 0.11,
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black12,
blurRadius: 8.0,
spreadRadius: 0.5,
)
],
borderRadius: BorderRadius.circular(10),
border: Border.all(
color: Colors.white10,
),
),
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Icon(
Icons.account_circle_rounded,
color: Colors.black,
size: 45,
),
Text(
'Lorem ipsum',
style: TextStyle(
fontFamily: 'Roboto',
fontSize: 14,
fontWeight: FontWeight.w900,
color: Color(0xfff2B2B2B),
),
)
],
),
),
Container(
width: MediaQuery.of(context).size.width/2.6,
height: MediaQuery.of(context).size.height * 0.11,
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.black12,
blurRadius: 8.0,
spreadRadius: 0.5,
)
],
color: Colors.white,
borderRadius: BorderRadius.circular(10),
border: Border.all(
color: Colors.white12,
),
),
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Icon(
Icons.account_box_sharp,
color: Colors.black,
size: 45,
),
Text(
'Lorem ipsum',
style: TextStyle(
fontFamily: 'Roboto',
fontSize: 14,
fontWeight: FontWeight.w900,
color: Color(0xfff2B2B2B),
),
)
],
),
)
],
),
),
],
),
),
// PreferredSize(child: child,
//
// preferredSize: Size.fromHeight(50.0),)
PreferredSize(child: Padding(
padding: const EdgeInsets.all(6.0),
child: Column(
children: [
Container(
width: MediaQuery.of(context).size.width/1,
//
height: MediaQuery.of(context).size.height * 0.42,
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black12,
blurRadius: 8.0,
spreadRadius: 0.5,
)
],
borderRadius: BorderRadius.only(topLeft: Radius.circular(25),topRight: Radius.circular(25)),
),
child:ListView(
children: [
Column(
mainAxisSize: MainAxisSize.max,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'ANNOUNCEMENT',
style: TextStyle(
fontFamily: 'Roboto',
fontWeight: FontWeight.bold,
fontSize: 22,
decoration: TextDecoration.underline,
),
),
),
cont(),
conttwo(),
],
),
],
),
),
],
),
),
preferredSize: Size.fromHeight(1.0),),
),
),
);
}
}
Going with Patrick's answer but with a little modification.
Column(
children: [
Text('ANNOUNCEMENT'),
SizedBox(
height:500 //give a height of your choice
ListView(
children: [
cont(),
conttwo(),
],
),
),
],
),