Text not resizing when using AutoSizeText - flutter

I'm new to developing in Flutter and I'm having an issue when using AutoSizeText isn't working as i thought it would. You can see on the screen grab that my date text is overflowing.
My code for reference. If anyone could point me in the right direction of where i'm going wrong i would be gladly appreciate it!
body: SafeArea(
child: GestureDetector(
onTap: () => FocusScope.of(context).unfocus(),
child: Stack(
children: [
Container(
width: double.infinity,
height: double.infinity,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Color(0x76168183),
FlutterFlowTheme.of(context).primaryColor
],
stops: [0, 1],
begin: AlignmentDirectional(0, -1),
end: AlignmentDirectional(0, 1),
),
),
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Padding(
padding: EdgeInsetsDirectional.fromSTEB(10, 10, 10, 0),
child: Container(
decoration: BoxDecoration(
color:
FlutterFlowTheme.of(context).secondaryBackground,
borderRadius: BorderRadius.circular(5),
border: Border.all(
color: Color(0xFF168183),
width: 1,
),
),
child: Stack(
children: [
Column(
mainAxisSize: MainAxisSize.min,
children: [
Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
OrderdateWidget(),
],
),
Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
AutoSizeText(
dateTimeFormat(
'MMMMEEEEd',
getCurrentTimestamp,
locale: FFLocalizations.of(context)
.languageCode,
),
textAlign: TextAlign.center,
style: FlutterFlowTheme.of(context)
.bodyText1
.override(
fontFamily: 'SharpSans',
color: Color(0xFF222F3A),
fontSize: 32,
fontWeight: FontWeight.w800,
useGoogleFonts: GoogleFonts.asMap()
.containsKey(
FlutterFlowTheme.of(context)
.bodyText1Family),
),
),
],
),
Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
AutoSizeText(
FFLocalizations.of(context).getText(
'yump08wx' /* Delivery address */,
),
style: FlutterFlowTheme.of(context)
.bodyText1
.override(
fontFamily: 'SharpSans',
color: Color(0xFF222F3A),
fontSize: 16,
fontWeight: FontWeight.w600,
useGoogleFonts: GoogleFonts.asMap()
.containsKey(
FlutterFlowTheme.of(context)
.bodyText1Family),
),
),
],
),
Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
children: [
AutoSizeText(
FFAppState().deliveryAddressName,
textAlign: TextAlign.center,
style: FlutterFlowTheme.of(context)
.bodyText1
.override(
fontFamily: 'SharpSans',
fontSize: 22,
fontWeight: FontWeight.w800,
useGoogleFonts: GoogleFonts.asMap()
.containsKey(
FlutterFlowTheme.of(context)
.bodyText1Family),
),
),
],
),
],
),
],
),
),
),
Expanded(
child: Container(
height: 100,
decoration: BoxDecoration(),
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Padding(
padding:
EdgeInsetsDirectional.fromSTEB(0, 5, 0, 0),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(
10, 0, 10, 0),
child: Container(
width:
MediaQuery.of(context).size.width,
decoration: BoxDecoration(
color: FlutterFlowTheme.of(context)
.primaryBtnText,
borderRadius:
BorderRadius.circular(5),
border: Border.all(
color: FlutterFlowTheme.of(context)
.primaryColor,
),
),
child: AutoSizeText(
FFLocalizations.of(context).getText(
'61jj7cic' /* Please select point of service... */,
),
textAlign: TextAlign.center,
maxLines: 1,
style: FlutterFlowTheme.of(context)
.bodyText1
.override(
fontFamily: 'SharpSans',
color: Color(0xFF222F3A),
fontSize: 18,
fontWeight: FontWeight.w600,
useGoogleFonts: GoogleFonts
.asMap()
.containsKey(
FlutterFlowTheme.of(
context)
.bodyText1Family),
),
),
),
),
),
],
),
),
Expanded(
child: Container(
height: 100,
decoration: BoxDecoration(),
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(
5, 10, 5, 10),
child: Builder(
builder: (context) {
final posGroup =
FFAppState().posGroupJson.toList();
return GridView.builder(
padding: EdgeInsets.zero,
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 1,
crossAxisSpacing: 0,
mainAxisSpacing: 10,
childAspectRatio: 3,
),
shrinkWrap: true,
scrollDirection: Axis.vertical,
itemCount: posGroup.length,
itemBuilder: (context, posGroupIndex) {
final posGroupItem =
posGroup[posGroupIndex];
return Padding(
padding:
EdgeInsetsDirectional.fromSTEB(
20, 0, 20, 10),
child: Material(
color: Colors.transparent,
elevation: 3,
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(5),
),
child: Container(
width: 100,
height: 100,
decoration: BoxDecoration(
color: Color(0xFF168183),
borderRadius:
BorderRadius.circular(5),
border: Border.all(
color: FlutterFlowTheme.of(
context)
.primaryBtnText,
),
),
child: InkWell(
child: InkWell(
onTap: () async {
setState(() =>
FFAppState()
.posGroupName =
getJsonField(
posGroupItem,
r'''$..posGroupName''',
).toString());
setState(() =>
FFAppState()
.posGroupId =
getJsonField(
posGroupItem,
r'''$..posGroupId''',
).toString());
await Navigator.push(
context,
PageTransition(
type:
PageTransitionType
.fade,
duration: Duration(
milliseconds: 0),
reverseDuration:
Duration(
milliseconds:
0),
child:
PointOfServiceWidget(
parmPOSGroupId:
getJsonField(
posGroupItem,
r'''$..posGroupId''',
).toString(),
),
),
);
},
child: Column(
mainAxisSize:
MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment
.center,
children: [
AutoSizeText(
getJsonField(
posGroupItem,
r'''$..posGroupName''',
).toString(),
style: FlutterFlowTheme
.of(context)
.bodyText1
.override(
fontFamily:
'SharpSans',
color: Colors
.white,
fontSize: 20,
fontWeight:
FontWeight
.w500,
useGoogleFonts: GoogleFonts
.asMap()
.containsKey(
FlutterFlowTheme.of(context)
.bodyText1Family),
),
),
],
),
),
),
),
),
);
},
);
},
),
),
),
),
],
),
),
),
],
),
),
],
),
),
),
);

wrap AutoSizeText with Expanded:
Expanded(
child: AutoSizeText(/*...*/),
),

Related

How to align widget with Wrap

I want to align image with the text. I have modified the code to make it happen, but it doesn't show any change.
The image and the text is supposed to be like this.
Instead like the picture above, mine is like this.
Here is my code, I'm using Wrap btw:
Column(
children: [
SizedBox(
width: 350,
child: Wrap(
alignment: WrapAlignment.start,
direction: Axis.horizontal,
crossAxisAlignment: WrapCrossAlignment.center,
children: [
SvgPicture.asset(
Assets.icons.image9.path,
fit: BoxFit.cover,
),
Wrap(
children: [
Padding(
padding: EdgeInsets.only(left: 15),
child: Text(
'Gekyume Onfroy',
style: heading3(
color: ColorName.neutralBackgroundWhite,
),
),
),
],
),
...
onSelected: (_) {},
child: SvgPicture.asset(Assets.icons.moreVertical.path),
),
),
SizedBox(width: 17),
Text(
'Access Code : 6666',
style: body1(color: ColorName.neutralBackgroundWhite),
),
],
),
Do not use wrap, as it will go horizontal to vertical, if mobile device does not have enough space. You have to use Rows and Column instead, check the bottom code for implementation and screenshot:
Container(
padding: const EdgeInsets.symmetric(horizontal: 14.0, vertical: 16.0),
decoration: BoxDecoration(
color: Colors.blue[900],
borderRadius: BorderRadius.circular(12)
),
// width: 350,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(
height: 60,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
image: const DecorationImage(image: NetworkImage('https://cartoonavatar.com/wp-content/uploads/2021/12/02-300x300.png')),
),
width: 60,
),
const SizedBox(width: 10),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: const [
Text('Gekyume Onfroy', maxLines:1, overflow: TextOverflow.ellipsis, style: TextStyle(fontSize: 20, color: Colors.white)),
Spacer(),
Text('Access Code : 6666', style: TextStyle(fontSize: 14, color: Colors.white),)
],
),
),
const SizedBox(width: 10),
IconButton(padding: EdgeInsets.zero, onPressed: () {}, icon: const Icon(Icons.more_vert, color: Colors.white))
],
),
),
const SizedBox(height: 10),
const Divider(color: Colors.white, thickness: 2,),
const SizedBox(height: 10),
Row(
children: [
const Icon(Icons.call, color: Colors.white),
const SizedBox(width: 10),
const Text('628-123-456-666', style: TextStyle(color: Colors.white)),
const Spacer(),
Container(
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(
color: Colors.blue[300],
borderRadius: BorderRadius.circular(4)
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
Text('Last Activity', style: TextStyle(color: Colors.white),),
Icon(Icons.navigate_next, color: Colors.white, size: 14,)
],
),
)
],
)
],
),
),

Flutter - Blockbuilder - Getter received null

I need to pass several getter through cubit to retieve data for each variable productAnalytics failed to be retrieve as cubit can provide one variable at a time.
When I restructure the Blockbuilder to return each Expand widget, it failes.
What is the best way to retrieve data for each widget in the codes below?
BlocBuilder(
cubit: inventoryBloc,
// cubit:productAnalytics,
builder: (context, state) {
if (state is GetInventoryAnalyticsInProgressState
||
state is GetProductAnalyticsInProgressState) {
return Center(
child: CircularProgressIndicator(),
);
}
if (state is GetInventoryAnalyticsFailedState
||
state is GetProductAnalyticsFailedState
) {
return Text('FAILED');
}
if (state is GetInventoryAnalyticsCompletedState ||
state is GetProductAnalyticsCompletedState
) {
inventoryAnalytics = state.inventoryAnalytics;
productAnalytics = state.productAnalytics;
return
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Expanded(
child: ClipRRect(
borderRadius: BorderRadius.circular(5),
child: Material(
child:
InkWell(
splashColor: CompanyColors.color[700].withOpacity(0.5),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => AllCategoriesScreen(cartBloc: null, firebaseUser: null, categoryList: [],),
));
},
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 5, sigmaY: 1),
child: Container(
padding: const EdgeInsets.all(10.0),
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topRight,
end: Alignment.bottomLeft,
colors: [
CompanyColors.color[100].withOpacity(0.8),
CompanyColors.color[100].withOpacity(0.95),
], ),
// color: CompanyColors.color[500].withOpacity(0.10),
borderRadius: BorderRadius.circular(5.0),
border: Border.all(
width: 1.0,
style: BorderStyle.solid,
color: CompanyColors.color[700].withOpacity(1),
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text(
'VOTRE PORTEFEUILLE',
overflow: TextOverflow.clip,
textAlign: TextAlign.center,
style: GoogleFonts.poppins(
color: CompanyColors.color[50],
fontSize: 15,
fontWeight: FontWeight.w500,
),
),
SizedBox(
height: 5.0,
),
Container(
width: 55.0,
height: 55.0,
alignment: Alignment.center,
padding: const EdgeInsets.all(15.0),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: CompanyColors.color[700].withOpacity(0.9),
),
child: Text(
'${inventoryAnalytics.allCategories}',
style: GoogleFonts.poppins(
color: CompanyColors.color[50],
fontSize: 18.0,
fontWeight: FontWeight.w600,
),
),
),
SizedBox(
height: 10.0,
),
Row(
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
// Expanded(
// child: Text(
// '${orderAnalytics.totalOrders}',
// style: GoogleFonts.poppins(
// color: CompanyColors.color[800]87,
// fontSize: 18.0,
// fontWeight: FontWeight.w600,
// ),
// ),
// ),
],
),
],
),
),
),
),
),
),
),
SizedBox(
width: 15.0,
),
Expanded(
child: ClipRRect(
borderRadius: BorderRadius.circular(5),
child: Material(
child:
InkWell(
splashColor: CompanyColors.color[600].withOpacity(0.5),
onTap: () {
HapticFeedback.heavyImpact();
Navigator.push(
context,
MaterialPageRoute(builder: (context) => ShopPage()),
);
},
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 5, sigmaY: 1),
child: Container(
padding: const EdgeInsets.all(10.0),
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topRight,
end: Alignment.bottomLeft,
colors: [
CompanyColors.color[100].withOpacity(0.7),
CompanyColors.color[100].withOpacity(0.95),
], ),
// color: CompanyColors.color[500].withOpacity(0.10),
borderRadius: BorderRadius.circular(5.0),
border: Border.all(
width: 1.0,
style: BorderStyle.solid,
color: CompanyColors.color[600].withOpacity(1),
),
),
child: Column(
// background:
crossAxisAlignment:
CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text(
'COMMANDER POUR UN CLIENT',
textAlign: TextAlign.center,
overflow: TextOverflow.clip,
style: GoogleFonts.poppins(
color: CompanyColors.color[50],
fontSize: 15,
fontWeight: FontWeight.w500,
),
),
SizedBox(
height: 10.0,
),
Container(
width: 55.0,
height: 55.0,
alignment: Alignment.center,
padding: const EdgeInsets.all(15.0),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: CompanyColors.color[600].withOpacity(0.9),
),
child: Text(
'${productAnalytics.allProducts}',
style: GoogleFonts.poppins(
color: CompanyColors.color[50],
fontSize: 18.0,
fontWeight: FontWeight.w600,
),
),
),
SizedBox(
height: 10.0,
),
Row(
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
],
),
],
),
),
),
),),
),),
],
);
}
return SizedBox();
},
),```

Flutter | TabView in body NestedScrollView. How to remove an empty space?

I use NestedScrollView, I have TabView in the body. If the widget in the tabview is half-empty, then an empty space remains.
As far as I understand, this is due to the fact that my headerSliverBuilder is too long, and the tabview is created at the full height of the screen.
I want to make the same functionality as in the Instagram profile. TabView with posts, saves.
SafeArea(
bottom: IphoneHasNotch.hasNotch ? false : true,
child: NestedScrollView(
headerSliverBuilder: (context, value) {
return [
SliverToBoxAdapter(
child: Container(
decoration: BoxDecoration(
color: Colors.white
),
child: Column(
children: [
Padding(
padding: const EdgeInsets.only(bottom: 15),
child: CreateHeaderWithOutBack(
title: 'Profile',
action: GestureDetector(
onTap: () => showModal(),
child: Icon(FeatherIcons.moreVertical, size: getWidth(25)),
)
),
)
]
)
)
),
SliverToBoxAdapter(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: getHeight(180),
width: MediaQuery.of(context).size.width,
child: Stack(
children: [
ClipRect(
child: ImageFiltered(
imageFilter: ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0),
child: Image.network(userData.avatar != null && userData.avatar.length > 0 ? userData.avatar : 'https://klike.net/uploads/posts/2019-05/1556708032_1.jpg',fit: BoxFit.cover, width: MediaQuery.of(context).size.width,height: getHeight(140),)
),
),
Positioned.fill(
child: Align(
alignment: Alignment.bottomLeft,
child: InkWell(
child: Hero(
tag: 'imageHero',
child: Container(
margin: EdgeInsets.symmetric(horizontal: 20),
height: getWidth(102),
width: getWidth(102),
decoration: BoxDecoration(
color: Colors.white,
shape: BoxShape.circle
),
padding: EdgeInsets.all(2),
child: Center(
child: CreateImageAvatar(name: userData.name, url: userData.avatar, size: getWidth(100),)
),
)
),
onTap: () {
Navigator.push(
context,PageRouteBuilder(pageBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) => DetailScreen(userData.avatars),
opaque: false
));
},
)
),
)
],
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: 10),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Flexible(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(userData.name + ', ' + userData.age.toString(),
style: TextStyle(fontSize: 21, fontWeight: FontWeight.w600),
),
userData.city != null && userData.city.length > 0 ? Padding(
padding: const EdgeInsets.only(top: 2,bottom: 10),
child: Text(userData.city,
style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500, color: kTextColor.withOpacity(0.6)),
),
) : Container(),
userData.company != null && userData.company.length > 0 ? Padding(
padding: const EdgeInsets.only(bottom: 5),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SvgPicture.asset('assets/images/work.svg', color: Color(0xFFBEBEBE), width: getWidth(15),),
SizedBox(width: 5),
Text(userData.company,
style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500, color: Color(0xFFBEBEBE)),
),
],
),
) : Container(),
],
),
),
widget.id == -1 ?GestureDetector(
onTap: (){
Provider.of<AppData>(context,listen: false).updateUserDataProfile(userData);
Navigator.pushNamed(context, EditProfile.routeName);
},
child: Container(
decoration: BoxDecoration(
color: Color(0xFFF6F6F6),
borderRadius: BorderRadius.circular(5),
border: Border.all(color: Color(0xFFEFEFEF), width: 1)
),
padding: EdgeInsets.symmetric(vertical: 8,horizontal: 15),
child: Text('Edit',
style: TextStyle(color: Color(0xFF9E9E9E), fontWeight: FontWeight.w500, fontSize: getHeight(12)),
),
),
) : Container()
],
),
userData.bio != null && userData.bio.length > 0 ? Padding(
padding: const EdgeInsets.only(top: 5),
child: Text(userData.bio,
style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500, color: Color(0xFF6D6D6D)),
),
) : Container(),
SizedBox(height: 20),
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
CreateBadgeProfile(title: userData.friends.toString(), disc: 'friends',),
SizedBox(width: 10),
CreateBadgeProfile(title: userData.news.toString(), disc: 'posts',),
],
),
],
),
)
],
),
),
SliverPadding(
padding: EdgeInsets.only(top: 25),
sliver: SliverToBoxAdapter(
child: Container(
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: Color(0xFFEAEAEA),
width: 1.0,
),
),
),
child: TabBar(
indicatorWeight: 2.0,
unselectedLabelColor: kTextColor.withOpacity(0.4),
labelStyle: TextStyle(fontFamily: 'Gilroy',fontWeight: FontWeight.w500, fontSize: 14, color: kTextColor.withOpacity(0.4)),
controller: _tabController,
tabs: <Widget> [
Tab(text: 'About'),
Tab(text: 'Posts'),
]
labelColor: kTextColor,
indicatorColor: kPrimaryColor,
),
),
),
)
];
},
body: Container(
child: TabBarView(
controller: _tabController,
children: [
Bio(userData: userData,),
NewsFeed(id:widget.id,post: 'post'),
],
),
)
),
);

Scroll only one Widget inside Stack() in Flutter

I'm new to Flutter and I'm trying to build my first app.
I want my HomePage to have a small image on the top and its content on the rest of the page. When scrolling, I want the image to behave like a Parallax effect, staying fixed and the grey ClipPath() widget scrolling over it.
I've already tried a few approaches and I'm not sure if I'm using the correct elements on this page but this was the only way I managed to position everything the way I wanted so far.
However, even using SingleChildScrollView() as this the Container/ClipPath() father, I still can't scroll the page.
Could you please help me with that? Thank you all.
// hope.page.dart:
import 'package:flutter/material.dart';
import 'package:remind_md/ui/shared/clippers/content.clipper.dart';
class HomePage extends StatefulWidget {
#override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
toolbarHeight: 40,
actions: <Widget>[
// action button
IconButton(
icon: Icon(Icons.notifications, color: Colors.white),
onPressed: () {
},
),
// action button
IconButton(
icon: Icon(Icons.settings, color: Colors.white),
onPressed: () {
},
),
],
),
body: Stack(
children: <Widget>[
Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Color(0xff82d9e8), Color(0xff27acc1)],
begin: Alignment.bottomLeft,
end: Alignment.topRight
)
),
child: OverflowBox(
alignment: Alignment(-0.75,-1.05),
maxHeight: MediaQuery.of(context).size.height * 2,
child: Image.asset(
'images/home_doctors.png',
scale: 1.05,
),
)
),
Positioned(
top: MediaQuery.of(context).size.height*0.2 ,
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Container(
child: ClipPath(
clipper: ContentClipper(),
child: Container(
padding: EdgeInsets.only(top: 40),
width: MediaQuery.of(context).size.width,
color: Color(0xfff4f4f4),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Container(
width: 200,
height: 100,
child: Card(
elevation: 2,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(7)),
child: Padding(
padding: const EdgeInsets.all(5.0),
child: Stack(
children: <Widget>[
Positioned(
right: 3,
top: 0,
child: Opacity(
opacity: 0.2,
child: Image.asset('images/card_calendar.png', width: 100, height: 75)
),
),
Positioned(
top: 0,
left: 5,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'12 dias',
textAlign: TextAlign.left,
style: TextStyle(fontFamily: 'BrunoAce', fontSize: 26, color: Color(0xff27acc1))
),
Text(
'até próxima',
textAlign: TextAlign.left,
style: TextStyle(fontFamily: 'BrunoAce', fontSize: 18, color: Color(0xff27acc1))
),
Text(
'consulta.',
textAlign: TextAlign.justify,
style: TextStyle(fontFamily: 'BrunoAce', fontSize: 18, color: Color(0xff27acc1))
),
],
),
)
]
),
),
),
),
Container(
width: 200,
height: 100,
child: Card(
elevation: 2,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(7)),
child: Padding(
padding: const EdgeInsets.all(5.0),
child: Stack(
children: <Widget>[
Positioned(
right: 3,
top: 0,
child: Opacity(
opacity: 0.2,
child: Image.asset('images/pill_case.png', width: 100, height: 75)
),
),
Positioned(
top: 0,
left: 5,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'31 dias',
textAlign: TextAlign.left,
style: TextStyle(fontFamily: 'BrunoAce', fontSize: 26, color: Color(0xff27acc1))
),
Text(
'até comprar',
textAlign: TextAlign.left,
style: TextStyle(fontFamily: 'BrunoAce', fontSize: 18, color: Color(0xff27acc1))
),
Text(
'medicamento.',
textAlign: TextAlign.justify,
style: TextStyle(fontFamily: 'BrunoAce', fontSize: 18, color: Color(0xff27acc1))
),
],
),
)
]
),
),
),
)
],
),
Card(
elevation: 2,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(7)),
child: Row(
children: <Widget>[
Container(
child: Image.asset('images/card_pills.png'),
height: 80,
width: 80,
decoration: BoxDecoration(
color: Color(0xfff47e71),
borderRadius: BorderRadius.all(Radius.circular(7))
),
)
],
),
),
Card(
elevation: 2,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(7)),
child: Row(
children: <Widget>[
Container(
child: Image.asset('images/card_stet_heart.png'),
height: 80,
width: 80,
decoration: BoxDecoration(
color: Color(0xff3865b9),
borderRadius: BorderRadius.all(Radius.circular(7))
),
)
],
),
),
Card(
elevation: 2,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(7)),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: <Widget>[
Text('Histórico', style: TextStyle(fontFamily: 'BrunoAce', fontSize: 24, color: Color(0xff27acc1), ) ),
Divider(),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Image.asset('images/list_credit_card.png'),
Text('1 - <MEDICAMENTO> - 19/08/2020', style: TextStyle(fontFamily: 'BrunoAce', fontSize: 16, color: Color(0xff27acc1) ) ),
],
),
Divider(),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Image.asset('images/list_credit_card.png'),
Text('1 - <MEDICAMENTO> - 19/08/2020', style: TextStyle(fontFamily: 'BrunoAce', fontSize: 16, color: Color(0xff27acc1) ) ),
],
),
Divider(),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Image.asset('images/list_pill.png'),
Text('30 - <MEDICAMENTO> - 19/08/2020', style: TextStyle(fontFamily: 'BrunoAce', fontSize: 16, color: Color(0xff27acc1) ) ),
],
),
Divider(),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Image.asset('images/list_pill.png'),
Text('1 - <MEDICAMENTO> - 19/08/2020', style: TextStyle(fontFamily: 'BrunoAce', fontSize: 16, color: Color(0xff27acc1) ) ),
],
),
Divider()
],
),
),
)
],
)
)
),
),
),
),
]
),
);
}
}
Wrap the SingleChildScrollView widget with an expanded widget. It should do the work. Because for the singleChildScrollView to work, it does not some height and width to scroll. Hope it helps.

SingleChildScrollView doesn't scroll screen with ListView.builder

I'm trying to get it so that all of the items in ListView.builder can be displayed on the screen and seen by scrolling. However, I think because the ListView.builder is in a stack, it is not allowing the whole screen to scroll. I don't want the ListView.builder to scroll on its own, I want only the whole page to be scrollable. Thanks in advance.
import 'sign_up_page.dart';
import 'package:intl/intl.dart';
import 'settings_page.dart';
import 'new_event_page.dart';
import 'event_settings_page.dart';
class HomeScreen extends StatefulWidget {
static const String id = 'home_screen';
#override
_HomeScreenState createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
#override
Widget build(BuildContext context) {
double width;
double height;
int mediumScreenSize = 800;
int largeScreenSize = 1000;
width = MediaQuery.of(context).size.width;
height = MediaQuery.of(context).size.height;
return Scaffold(
backgroundColor: Color.fromRGBO(255, 255, 255, 1),
body: SingleChildScrollView(
child: Column(
children: <Widget>[
Stack(
children:[
Container(
child: AspectRatio(
aspectRatio: mediumScreenSize < height ? 0.76 : 0.87,
),
decoration: BoxDecoration(
color: Color(0xff212a3d),
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(40), bottomRight: Radius.circular(40)
),
),
),
Container(
height: height,
child: Column(
children: [
AspectRatio(
aspectRatio: 10,
),
Stack(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
padding: EdgeInsets.all(width/35),
child: Text('Home',
style: TextStyle(
fontFamily: 'Chivo Bold',
fontSize: mediumScreenSize < height ? 22.0 : 21.0,
color: Colors.white,
),
),
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Padding(
padding: EdgeInsets.only(right: width/10),
child: ButtonTheme(
padding: EdgeInsets.all(0),
minWidth: width/10,
child: FlatButton(onPressed: () {
Navigator.pushNamed(context, SettingsPage.id);
},
child: Image.asset('images/gear.png', height: 22),
),
),
),
],
),
],
),
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
SizedBox(
height: height/5,
),
Container(
padding: EdgeInsets.only(left: width/7.5),
//TO DO: replace fullName variable when user updates user information
child: Text('Welcome' + UserInformation.userStatus + ',' + '\n' + UserInformation.fullName, style: TextStyle(
fontFamily: 'Poppins SemiBold',
fontWeight: FontWeight.w600,
fontSize: mediumScreenSize < height ? 26.0 : 25.0,
letterSpacing: 0.5,
color: Colors.white,
),
),
),
],
),
AspectRatio(
aspectRatio: height > mediumScreenSize ? 4: 7,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: width/1.2,
child: AspectRatio(
aspectRatio: 6.5,
child: FlatButton(
shape: RoundedRectangleBorder(
borderRadius: new BorderRadius.circular(28.0),
),
color: Color.fromRGBO(102, 161, 192, 1),
onPressed: () {
EventInformation.eventDate = DateFormat.yMMMMd().format(DateTime.now());
Navigator.pushNamed(context, NewEventPage.id);
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
padding: EdgeInsets.only(top: width * 0.015),
child: Image.asset(
'images/+.png',
height: width/16,
),
),
Text(
' Add new event',
style: TextStyle(
color: Colors.white,
fontFamily: 'Chivo Regular',
fontSize: mediumScreenSize < height ? 16.0 : 15.0,
),
),
],
),
),
),
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: EdgeInsets.only(top: width/15, bottom: width/40),
child: Container(
child: Text('My Events:', style: TextStyle(
fontFamily: 'Overpass SemiBold',
fontWeight: FontWeight.w600,
fontSize: mediumScreenSize < height ? 16.0 : 15.0,
letterSpacing: 1.0,
color: Colors.white,
),
),
),
),
],
),
UserInformation.events.length == 0 ? Container (
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
AspectRatio(
aspectRatio: height > mediumScreenSize ? 2.5: 4,
),
Text('No events listed', textAlign: TextAlign.center,
style: TextStyle(color: Colors.grey, fontFamily: 'Chivo Bold', fontSize: mediumScreenSize < height ? 20.0 : 19.0),),
Text('\nAdd a new event by selecting the "+" button above', textAlign: TextAlign.center,
style: TextStyle(color: Colors.grey, fontFamily: 'Chivo Regular'),),
],
),):
Expanded(
child: ListView.builder(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: UserInformation.events.length,
itemBuilder: (context, index) {
return Container(
margin: EdgeInsets.only(bottom: width/20),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
InkWell(
onTap: () {
Navigator.pushNamed(context, EventSettingsPage.id);
},
child: Container(width: width/1.2,
height: width/5.5,
decoration: new BoxDecoration(
color: Color(0xffffffff),
borderRadius: BorderRadius.circular(15),
boxShadow: [BoxShadow(
color: Color(0x15525768),
offset: Offset(-12,15),
blurRadius: 22,
spreadRadius: 0
),BoxShadow(
color: Color(0x0c525768),
offset: Offset(12,-15),
blurRadius: 22,
spreadRadius: 0
) ],
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
padding: EdgeInsets.only(left: width/10),
child: Text(UserInformation.events[index],
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Color(0xff212a3d),
fontFamily: 'Overpass Bold',
fontSize: mediumScreenSize < height ? 16.0 : 15.0,
),
),
),
Container(
padding: EdgeInsets.only(right: width/15),
child: new Image.asset(
'images/mini_arrow.png',
height: 30.0,
),
),
],
),
),
),
],
),
);
}
),
),
],
),
),
],
),
],
),
),
);
}
}
add this two line in your listview :-ListView.builder( physics: NeverScrollableScrollPhysics(),
child: Scaffold(
backgroundColor: Color.fromRGBO(255, 255, 255, 1),
body: SingleChildScrollView(
physics: ClampingScrollPhysics(),
child: Column(
children: <Widget>[
Stack(
children:[
Container(
height: mediumScreenSize < height ? width/0.8 : width/0.8,
width: double.infinity,
decoration: BoxDecoration(
color: Color(0xff212a3d),
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(40), bottomRight: Radius.circular(40)
),
),
),
Column(
children: [
Stack(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
margin: EdgeInsets.only(top: width/9),
child: Text('Home',
style: TextStyle(
fontFamily: 'Chivo Bold',
fontSize: mediumScreenSize < height ? 22.0 : 21.0,
color: Colors.white,
),
),
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Container(
margin: EdgeInsets.only(top: width/13),
padding: EdgeInsets.only(right: width/10),
child: ButtonTheme(
padding: EdgeInsets.all(0),
minWidth: width/10,
child: FlatButton(onPressed: () {
Navigator.pushNamed(context, SettingsPage.id);
},
child: Image.asset('images/gear.png', height: 22),
),
),
),
],
),
],
),
SizedBox(
height: width/4,
),
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Container(
padding: EdgeInsets.only(left: width/7.5),
child: Text('Welcome' + UserInformation.userStatus + ',' + '\n' + UserInformation.fullName, style: TextStyle(
fontFamily: 'Poppins SemiBold',
fontWeight: FontWeight.w600,
fontSize: mediumScreenSize < height ? 26.0 : 25.0,
letterSpacing: 0.5,
color: Colors.white,
),
),
),
],
),
SizedBox(
height: width/4.75,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: width/1.2,
child: AspectRatio(
aspectRatio: 6.5,
child: FlatButton(
shape: RoundedRectangleBorder(
borderRadius: new BorderRadius.circular(28.0),
),
color: Color.fromRGBO(102, 161, 192, 1),
onPressed: () {
EventInformation.displayEventDate = DateFormat.yMMMMd().format(DateTime.now());
Navigator.pushNamed(context, NewEventPage.id);
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
padding: EdgeInsets.only(top: width * 0.015),
child: Image.asset(
'images/+.png',
height: width/16,
),
),
Text(
' Add new event',
style: TextStyle(
color: Colors.white,
fontFamily: 'Chivo Regular',
fontSize: mediumScreenSize < height ? 16.0 : 15.0,
),
),
],
),
),
),
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: EdgeInsets.only(top: width/15),
child: Container(
child: Text('My Events:', style: TextStyle(
fontFamily: 'Overpass SemiBold',
fontWeight: FontWeight.w600,
fontSize: mediumScreenSize < height ? 16.0 : 15.0,
letterSpacing: 1.0,
color: Colors.white,
),
),
),
),
],
),
],
),
Padding(
padding: EdgeInsets.only(top: width/ 0.9),
child: UserInformation.events.length == 0 ? Container (
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
AspectRatio(
aspectRatio: height > mediumScreenSize ? 2.5: 4,
),
Text('No events listed', textAlign: TextAlign.center,
style: TextStyle(color: Colors.grey, fontFamily: 'Chivo Bold', fontSize: mediumScreenSize < height ? 20.0 : 19.0),),
Text('\nAdd a new event by selecting the "+" button above', textAlign: TextAlign.center,
style: TextStyle(color: Colors.grey, fontFamily: 'Chivo Regular'),),
],
),):
ListView.builder(
padding: EdgeInsets.only(top: width/20, bottom: width/20),
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: UserInformation.events.length,
itemBuilder: (context, index) {
return Container(
margin: EdgeInsets.only(bottom: width/20),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
InkWell(
onTap: () {
Navigator.pushNamed(context, EventSettingsPage.id);
},
child: Container(width: width/1.2,
height: width/5.5,
decoration: new BoxDecoration(
color: Color(0xffffffff),
borderRadius: BorderRadius.circular(15),
boxShadow: [BoxShadow(
color: Color(0x15525768),
offset: Offset(-12,15),
blurRadius: 22,
spreadRadius: 0
),BoxShadow(
color: Color(0x0c525768),
offset: Offset(12,-15),
blurRadius: 22,
spreadRadius: 0
) ],
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
padding: EdgeInsets.only(left: width/10),
child: Text(UserInformation.events[index],
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Color(0xff212a3d),
fontFamily: 'Overpass Bold',
fontSize: mediumScreenSize < height ? 16.0 : 15.0,
),
),
),
Container(
padding: EdgeInsets.only(right: width/15),
child: new Image.asset(
'images/mini_arrow.png',
height: 30.0,
),
),
],
),
),
),
],
),
);
}
),
),
],
),
],
),
),
),
This is the way I figured out how to do it without any hardcoded height inputs. The problem was the ListView.builder was in a Container with no specified height.
Inside ListView.builder : use property physics and give NeverScrollableScrollPhysics() as a value ex:
physics: NeverScrollableScrollPhysics(),