TextOverflow not working in Text Widget Flutter - flutter

i am trying to clip the description of the foodItem i have in a flutter app i tried adding 'overflow: TextOverflow.clip' to my Text() Widget, but that didn't really work... i'll share the specific Widget and then the full file..
Text('This is a very long description.....................',
overflow: TextOverflow.clip,
softWrap: true,
style: TextStyle(
fontSize: 9.0,
color: Colors.black38,
),
),
the full file..
import 'package:eva_icons_flutter/eva_icons_flutter.dart';
import 'package:flutter/material.dart';
import '../model/food.dart';
import '../style/theme.dart' as Style;
class FoodList extends StatelessWidget {
final foodItems = <Food>[
Food(
title: "Jimmy's Steak",
price: "34.00",
img: 'assets/icons/foods/food5.jpg',
rating: "4.2"
),
Food(
title: "Butter Steak",
price: "45.00",
img: 'assets/icons/foods/food6.jpg',
rating: "4.2"
),
Food(
title: "Sushi",
price: "10.00",
img: 'assets/icons/foods/food7.jpg',
rating: "4.7"
)
];
#override
Widget build(BuildContext context) {
return ListView(
scrollDirection: Axis.horizontal,
children: foodItems.map<Widget>((Food food) {
return GestureDetector(
onTap: () {
},
child: Padding(
padding: EdgeInsets.only(left: 20.0, top: 10.0, bottom: 20.0),
child: Container(
width: 170,
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(color: Colors.grey[300], width: 1.0),
borderRadius: BorderRadius.all(Radius.circular(10))),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Container(
height: 180.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.only(topLeft:Radius.circular(10), topRight:Radius.circular(10)),
image: DecorationImage(
image: AssetImage(food.img),
fit: BoxFit.cover
)
),
),
SizedBox(
height: 10.0,
),
Padding(
padding: const EdgeInsets.only(left: 10.0),
child: Text(
food.title,
style: TextStyle(
color: Colors.black,
fontSize: 12.0),
),
),
SizedBox(
height: 5.0,
),
Padding(
padding: const EdgeInsets.only(left:10.0, right: 10.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text('This is a very long description.....................',
overflow: TextOverflow.clip,
softWrap: true,
style: TextStyle(
fontSize: 9.0,
color: Colors.black38,
),
),
SizedBox(
width: 5.0,
),
/* Icon(EvaIcons.star, color: Style.Colors.mainColor, size: 8.0,),
Icon(EvaIcons.star, color: Style.Colors.mainColor, size: 8.0,),
Icon(EvaIcons.star, color: Style.Colors.mainColor, size: 8.0,),
Icon(EvaIcons.star, color: Style.Colors.mainColor, size: 8.0,),
Icon(EvaIcons.star, color: Colors.black38, size: 8.0,), */
SizedBox(
width: 5.0,
),
/* Text("(200)", style: TextStyle(
fontSize: 9.0,
color: Colors.black38
),),
*/ ],
),
Text( "\$" + food.price, style: TextStyle(
fontSize: 10.0,
color: Colors.black,
fontWeight: FontWeight.bold
),)
],
),
)
],
),
),
)
);
}).toList());
}
}
I tried using the ClipRect Widget as well, by wrapping my Text Widget into it but that still didn't work.. I am Kindo Of stuck here, any help would be much appreciated..

You can set a limit of String for text like below.
String text =
"This is a very long description.........his is a very long description.........his is a very long description.........his is a very long description.....................";
Text(
text.length > 30 ? '${text.substring(0, 30)}......' : text,
style: TextStyle(
fontSize: 9.0,
color: Colors.black38,
),
)
You could also check the below code.
Center(
child: Container(
padding: EdgeInsets.all(4.0),
color: Colors.lime,
width: 200.0,
child: Row(
children: <Widget>[
Flexible(
child: RichText(
overflow: TextOverflow.ellipsis,
strutStyle: StrutStyle(fontSize: 12.0),
text: TextSpan(
style: TextStyle(color: Colors.black),
text: 'A very long text :)'),
),
),
Container(
width: 100.0,
height: 100.0,
color: Colors.orangeAccent,
)
],
),
)),

Related

Unable to get the desired result using BackDropFilter in Flutter

For a couple of times now I've played around BackDropFilter() in Flutter and it looks like I can't seem to warp my head around how it works or maybe I feel I don't have the power I should have with it, lol. Can you put me in the right direction, please?
I want the backdrop only on the Container but instead, it goes beyond the Container to the cover image.
This image contains what I want
While this is what I get
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ClipRRect(
borderRadius: const BorderRadius.only(
bottomLeft: Radius.circular(50),
bottomRight: Radius.circular(50),
),
child: Stack(
children: [
// Featured Image
Hero(
tag: product.id,
child: Container(
height: size.height * 0.6,
decoration: BoxDecoration(
image: DecorationImage(
fit: BoxFit.cover,
image: CachedNetworkImageProvider(
product.featuredImage!,
),
),
),
),
),
// App Bar
SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 20,
vertical: 10,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
// Back Button
MenuButton(
onTap: () => Navigator.pop(context),
padding: const EdgeInsets.all(12),
icon: Icon(
Platform.isAndroid
? Ionicons.arrow_back
: CupertinoIcons.back,
color: Constants.iconColor,
),
),
// Add to fav button
MenuButton(
onTap: () {},
padding: const EdgeInsets.all(12),
icon: const Icon(
Ionicons.heart,
color: Constants.iconColor,
),
),
],
),
),
),
Positioned(
bottom: 0,
child: Container(
color: const Color.fromARGB(189, 49, 49, 49),
height: size.height * 0.2,
width: size.width,
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 3.5, sigmaY: 3.5),
child: Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
product.title!,
style: Theme.of(context).textTheme.headline4,
),
Text(
product.subtitle!,
style: Theme.of(context)
.textTheme
.headline5!
.copyWith(
fontSize: 16, color: Colors.white54),
),
// Rate
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(
Ionicons.star,
color: Constants.mainAppColor,
),
const SizedBox(width: 12),
Text(
product.rate.toString(),
style:
Theme.of(context).textTheme.headline5,
),
const SizedBox(width: 12),
Text(
'(${product.rate})',
style: Theme.of(context)
.textTheme
.headline6!
.copyWith(
color: Colors.white54,
fontSize: 15),
),
],
),
),
],
),
],
),
),
),
),
],
),
),
SizedBox(height: size.height * 0.02),
//
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Description",
style: Theme.of(context).textTheme.headline6!.copyWith(
fontSize: 18, color: Colors.white.withOpacity(0.7)),
),
SizedBox(height: size.height * 0.015),
RichText(
text: TextSpan(
children: [
TextSpan(text: '${product.description!}... '),
const TextSpan(
text: 'Read More',
style: TextStyle(color: Constants.mainAppColor),
),
],
style: Theme.of(context)
.textTheme
.headline6!
.copyWith(fontSize: 16),
),
maxLines: 2,
),
],
),
),
)
],
),
Try this
import 'dart:io';
import 'dart:math';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class HomePage extends StatelessWidget {
HomePage({Key? key}) : super(key: key);
Product product = Product(
id: "001",
featuredImage:
'https://upload.wikimedia.org/wikipedia/commons/thumb/c/c8/Cappuccino_at_Sightglass_Coffee.jpg/1280px-Cappuccino_at_Sightglass_Coffee.jpg',
title: "Cappuccino",
subtitle: "With Oat Milk",
rate: "4.5");
#override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return Scaffold(
backgroundColor: Colors.black,
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ClipRRect(
borderRadius: const BorderRadius.only(
bottomLeft: Radius.circular(50),
bottomRight: Radius.circular(50),
),
child: Stack(
children: [
// Featured Image
Hero(
tag: product.id!,
child: Container(
height: size.height * 0.6,
decoration: BoxDecoration(
image: DecorationImage(
fit: BoxFit.cover,
image: CachedNetworkImageProvider(
product.featuredImage!,
),
),
),
),
),
// App Bar
SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 20,
vertical: 10,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
// Back Button
MenuButton(
onTap: () => Navigator.pop(context),
padding: const EdgeInsets.all(12),
icon: Icon(
Platform.isAndroid
? Icons.arrow_back
: CupertinoIcons.back,
color: Colors.white,
),
),
// Add to fav button
MenuButton(
onTap: () {},
padding: const EdgeInsets.all(12),
icon: const Icon(
Icons.favorite,
color: Colors.white,
),
),
],
),
),
),
Positioned(
//top: size.height * 0.30,
bottom: 0,
child: ClipRRect(
borderRadius: BorderRadius.circular(50),
child: Container(
color: const Color.fromARGB(189, 49, 49, 49),
// color: Colors.green,
//height: size.height * 0.75,
padding: const EdgeInsets.all(20),
width: size.width,
child: Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(
height: 20,
),
Text(
product.title!,
style: Theme.of(context)
.textTheme
.headline4!
.copyWith(
fontSize: 24, color: Colors.white),
),
Text(
product.subtitle!,
style: Theme.of(context)
.textTheme
.headline5!
.copyWith(
fontSize: 16, color: Colors.white54),
),
const SizedBox(
height: 20,
),
// Rate
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(
Icons.star,
color: Colors.orangeAccent,
),
const SizedBox(width: 12),
Text(
product.rate.toString(),
style: Theme.of(context)
.textTheme
.headline5!
.copyWith(
color: Colors.white, fontSize: 15),
),
const SizedBox(width: 12),
Text(
'(6.986)',
style: Theme.of(context)
.textTheme
.headline6!
.copyWith(
color: Colors.white54,
fontSize: 15),
),
],
),
const SizedBox(
height: 20,
),
],
),
],
),
),
),
),
],
),
),
SizedBox(height: size.height * 0.02),
//
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Description",
style: Theme.of(context).textTheme.headline6!.copyWith(
fontSize: 18, color: Colors.white.withOpacity(0.7)),
),
SizedBox(height: size.height * 0.015),
RichText(
text: TextSpan(
children: [
TextSpan(
text: '${product.description!}... ',
style: const TextStyle(color: Colors.white),
),
const TextSpan(
text: 'Read More',
style: TextStyle(color: Colors.orangeAccent),
),
],
style: Theme.of(context)
.textTheme
.headline6!
.copyWith(fontSize: 16),
),
maxLines: 2,
),
],
),
),
)
],
),
);
}
}
class Product {
String? id;
String? featuredImage;
String? subtitle;
String? title;
String? rate;
String? description;
Product(
{this.id,
this.featuredImage,
this.title,
this.rate,
this.subtitle,
this.description =
"A Cappuccino is a coffee-based drink made primarily from espresso and "});
}
class MenuButton extends StatelessWidget {
const MenuButton(
{Key? key,
required void Function() onTap,
required EdgeInsets padding,
required Icon icon})
: super(key: key);
#override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.all(20.0),
decoration: BoxDecoration(
color: Colors.black, borderRadius: BorderRadius.circular(20.0)),
);
}
}
It looks like this

How to make responsive content in Container Flutter

How can I make the responsive Content in Container,
when I put anything in a container and the Height content is oversize what is the solution for this? I need to fix it when the user input too much information about the post and I warp it with less/more plugins and when the user uses it the screen is over pixel for sure
I use media query on the container that means I fix the size is okay so it's will happen if too much text
Widget _postWidget() {
return Container(
height: MediaQuery.of(context).size.height * 0.40,
width: MediaQuery.of(context).size.width * 1,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: 1,
child: Container(
padding: EdgeInsets.symmetric(horizontal: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
flex: 1,
child: Container(
height: 45, //height, //155,
width: 45, //width, //155,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: const Color(0xff7c94b6),
image: DecorationImage(
image: NetworkImage(''),
fit: BoxFit.cover,
),
),
),
),
Expanded(
flex: 6,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 10),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
RichText(
text: TextSpan(
text: '[C]post.username ',
style: TextStyle(
color: Colors.black,
fontFamily: 'SukhumvitSetBold',
fontWeight: FontWeight.bold),
children: const <TextSpan>[
TextSpan(
text: '3h',
style: TextStyle(
color: Colors.grey,
fontFamily: 'SukhumvitSetBold',
fontWeight: FontWeight.w400)),
],
),
),
Text(
'[user]Desuka',
style: TextStyle(
color: Colors.grey[500],
fontFamily: 'SukhumvitSetMedium',
),
)
],
),
),
),
Expanded(
flex: 2,
child: SizedBox(
width: 200.0,
height: 30.0,
child: OutlinedButton(
child: Text(
'Join+',
style: TextStyle(
color: HexColor("7225FF"),
),
),
onPressed: () => print("it's pressed"),
style: ElevatedButton.styleFrom(
side: BorderSide(
width: 1.5,
color: HexColor("7225FF"),
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(32.0),
),
),
))),
],
),
),
),
InkWell(
child: Container(
margin: const EdgeInsets.only(
top: 10,
bottom: 10,
right: 20,
left: 20,
),
width: double.infinity,
height: 170.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16.0),
image: DecorationImage(
image: NetworkImage(
'https://gitlab.com/2Shours/alphapic/raw/master/22.jpeg'),
fit: BoxFit.cover,
),
),
),
),
SizedBox(
height: 5,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20.0),
child: Column(
children: [
Text(
'Travis Scott x Nike Fregment',
style: TextStyle(
color: Colors.black,
fontFamily: 'SukhumvitSetBold',
fontSize: 16,
fontWeight: FontWeight.bold),
),
],
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20.0),
child: Column(
children: [
ReadMoreText(
'The Flutter framework builds its layout via the composition of widgets, everything that you construct programmatically is a widget and these are compiled together to create the user interface. ',
style: TextStyle(
color: Colors.black,
fontSize: 15,
fontFamily: 'SukumvitSetMedium'),
trimLines: 2,
colorClickableText: HexColor("7225FF"),
trimMode: TrimMode.Line,
trimCollapsedText: 'More',
trimExpandedText: ' Less',
),
],
),
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 10.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Row(
children: <Widget>[
Row(
children: <Widget>[
IconButton(
icon: Icon(
(IconData(
0xe902,
fontFamily: 'heartPost',
)),
color: Colors.purple,
size: 20,
),
iconSize: 30.0,
onPressed: () => print('Like post'),
),
Text(
'2222',
style: TextStyle(
fontSize: 14.0,
fontFamily: 'SukhumvitSetMedium',
fontWeight: FontWeight.w600,
),
),
],
),
SizedBox(width: 10.0),
Row(
children: <Widget>[
IconButton(
icon: Icon(
IconData(0xe901, fontFamily: 'commentPost')),
iconSize: 20.0,
onPressed: () {}),
Text(
'2222',
style: TextStyle(
fontSize: 14.0,
fontFamily: 'SukhumvitSetMedium',
fontWeight: FontWeight.w600,
),
),
],
),
SizedBox(width: 20.0),
Row(
children: <Widget>[
IconButton(
icon: Icon(IconData(0xe906, fontFamily: 'offerPost')),
iconSize: 20.0,
onPressed: () {},
),
Text(
'Offer',
style: TextStyle(
fontSize: 14.0,
fontFamily: 'SukhumvitSetMedium',
fontWeight: FontWeight.w600,
),
),
],
),
],
),
IconButton(
icon: Icon(
(IconData(
0xe908,
fontFamily: 'wishlistPost',
)),
color: Colors.purple,
size: 20,
),
iconSize: 30.0,
onPressed: () => print('Save post'),
),
],
),
),
],
),
);
}

Flutter Card Layout

So I'm new to flutter, and I'm trying to make a card. But I can't seem to get my desired output.
I tried to separate the different widgets, by using rows and columns, but I kept messing it up.
This is my target output
Target output
This is my current progressCurrent progress
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: buildhomePageAppBar(),
body: buildExhibitorBody(),
);
}
Widget buildExhibitorBody() {
return Container(
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
buildExhibitorText(),
SizedBox(
height: 10,
),
buildExhibitorCards(),
SizedBox(height: 10),
],
),
),
);
}
Widget buildhomePageAppBar() {
double profileDimension = 35;
return AppBar(
backgroundColor: Colors.white,
titleSpacing: 0,
title: Padding(
padding: EdgeInsets.only(
left: 20,
),
child: Row(
children: [
Padding(
padding: EdgeInsets.only(
top: 5,
bottom: 5,
),
child: Image(
image: AssetImage('assets/images/plain_logo.png'),
height: 30,
),
),
SizedBox(width: 5),
Text(
'Virtex',
style: TextStyle(
color: Colors.black87,
fontFamily: 'Poppins',
fontSize: 16,
fontWeight: FontWeight.bold,
),
)
],
),
),
actions: [
Padding(
padding: EdgeInsets.only(
top: 10,
bottom: 10,
),
child: Container(
height: profileDimension,
width: profileDimension,
alignment: Alignment.center,
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(
color: Colors.black54,
width: 2,
),
borderRadius: BorderRadius.circular(50),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(50),
child: Image(
width: profileDimension,
height: profileDimension,
image: AssetImage(
'assets/images/profile-image.jpeg',
),
fit: BoxFit.cover,
),
),
),
),
SizedBox(width: 20),
],
);
}
Widget buildExhibitorText() {
return Padding(
padding: EdgeInsets.only(
left: 20,
right: 20,
top: 20,
bottom: 10,
),
child: Container(
child: new Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Expanded(
child: Text(
"Exhibitors",
textAlign: TextAlign.justify,
style: TextStyle(
fontFamily: "DMSans",
letterSpacing: -0.2,
fontSize: 20.0,
color: Colors.black,
fontWeight: FontWeight.w400,
),
),
),
],
),
),
);
}
Widget buildExhibitorCards() { // I think my problem is I don't know how to do the layout here
return Container(
width: 400,
height: 150,
child: Column(children: <Widget>[
Card(
elevation: 1,
child: Padding(
padding: const EdgeInsets.only(),
child: Row(children: [
buildCardImage(),
buildCardExhibitor(),
buildCardIndustry(),
buildCardGo(),
])),
),
]),
);
}
Widget buildCardExhibitor() {
return Row(mainAxisAlignment: MainAxisAlignment.center, children: [
Container(
padding: EdgeInsets.all(10),
width: 40,
height: 40,
child: Center(
child: Row(
children: <Widget>[
Text(
"EN",
style: TextStyle(
fontSize: 15.0,
color: Colors.white,
fontWeight: FontWeight.bold,
),
textAlign: TextAlign.center,
),
Text('Exhibitor Name')
],
),
),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(
Radius.circular(200),
),
color: Colors.red,
),
),
]);
}
Widget buildCardImage() {
return Container(
height: 100,
width: 100,
child: Image(
image: AssetImage('assets/images/onboarding-2.jpg'),
height: 100,
),
);
}
Widget buildCardIndustry() {
return Padding(
padding: EdgeInsets.only(
left: 40,
right: 40,
),
child: Container(
child: new Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Text(
"Industry 1",
style: TextStyle(
fontFamily: "DMSans",
color: Colors.grey,
letterSpacing: 0.3,
fontSize: 12,
),
),
Text(
"Industry 2",
style: TextStyle(
fontFamily: "DMSans",
letterSpacing: -0.3,
fontSize: 12,
color: Colors.grey,
fontWeight: FontWeight.w500,
),
),
],
),
),
);
}
Widget buildCardGo() {
return Row(mainAxisAlignment: MainAxisAlignment.end, children: [
Text(
'Go to Booth',
style: TextStyle(
color: Colors.blue,
fontFamily: 'Poppins',
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
SizedBox(width: 5),
IconButton(
icon: Icon(
MdiIcons.fromString('arrow-right'),
size: 30,
color: Colors.black,
),
onPressed: () {
Navigator.of(context).pop();
},
),
]);
}
}
I would greatly appreciate any kind of help.
Look:
My own Code
import 'package:flutter/material.dart';
class CardLayout extends StatelessWidget {
Widget buildCardImage = Container(
margin: EdgeInsets.only(right: 10.0),
width: 150,
height: 150,
decoration: BoxDecoration(
image: DecorationImage(
fit: BoxFit.fill,
image: NetworkImage("https://picsum.photos/250?image=9"),
),
),
);
Widget buildCardExhibitor =
Row(mainAxisAlignment: MainAxisAlignment.start, children: [
Container(
padding: EdgeInsets.all(10.0),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(
Radius.circular(200),
),
color: Colors.red,
),
child: Text(
"EN",
style: TextStyle(
fontSize: 15.0,
color: Colors.white,
fontWeight: FontWeight.bold,
),
textAlign: TextAlign.center,
),
),
SizedBox(
width: 10.0,
),
Text(
'Exhibitor Name',
style: TextStyle(
fontSize: 15.0,
color: Colors.black,
fontWeight: FontWeight.bold,
),
textAlign: TextAlign.center,
),
]);
Widget buildCardIndustry = Padding(
padding: EdgeInsets.all(8.0),
child: Container(
child: new Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Container(
padding:
EdgeInsets.only(left: 10.0, right: 10.0, top: 5, bottom: 5),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(
Radius.circular(100),
),
color: Colors.blueGrey.shade400,
),
child: Text(
'Industry 1',
style: TextStyle(
fontFamily: "DMSans",
color: Colors.white,
letterSpacing: 0.3,
fontSize: 12,
),
),
),
SizedBox(
width: 10.0,
),
Container(
padding:
EdgeInsets.only(left: 10.0, right: 10.0, top: 5, bottom: 5),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(
Radius.circular(100),
),
color: Colors.blueGrey.shade400,
),
child: Text(
'Industry 2',
style: TextStyle(
fontFamily: "DMSans",
color: Colors.white,
letterSpacing: 0.3,
fontSize: 12,
),
),
),
],
),
),
);
Widget buildCardGo = Row(mainAxisAlignment: MainAxisAlignment.end, children: [
Text(
'Go to Booth',
style: TextStyle(
color: Colors.blue,
fontFamily: 'Poppins',
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
SizedBox(width: 3),
IconButton(
icon: Icon(
Icons.arrow_forward_rounded,
size: 30,
color: Colors.blue,
),
onPressed: () {
//Navigator.pop(context);
},
),
]);
#override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
appBar: AppBar(
title: Text('Exhibitor'),
actions: [
IconButton(
icon: Icon(Icons.filter_list_rounded),
onPressed: () {
Navigator.pop(context);
})
],
),
body: Container(
margin: EdgeInsets.only(top: 10.0),
width: MediaQuery.of(context).size.width,
//height: 150.0, // remove this line -------------- (1) [EDIT]
child: Column(
// wrap card with column and add listtile as children -------------- (2) [EDIT]
children: [
ListTile(
leading: Text('Exhibitor'),
trailing: IconButton(
icon: Icon(Icons.filter_list_rounded),
onPressed: () {
Navigator.pop(context);
}),
),
Card(
elevation: 5.0,
color: Colors.white,
child: Padding(
padding: EdgeInsets.all(5.0),
child: Row(
children: <Widget>[
buildCardImage,
Expanded(
child: Column(
children: <Widget>[
buildCardExhibitor,
buildCardIndustry,
buildCardGo
],
))
],
),
),
),
],
),
),
));
}
}

SingleChildScrollView not working in Column

I am building an app facing a singleChildScrollView not able to scroll the page the text has been cut from bottom after the contact button i want to scroll the page but but spending so much time can't fix problem.
enter image description here
enter code here
import 'package:flutter/material.dart';
class DetailScreen extends StatefulWidget {
final electricain;
DetailScreen(this.electricain);
#override
_DetailScreenState createState() => _DetailScreenState();
}
class _DetailScreenState extends State<DetailScreen> {
#override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
child: Stack(
children: <Widget>[
Container(
height: MediaQuery.of(context).size.height / 3 + 20,
width: MediaQuery.of(context).size.width,
child: Stack(
fit: StackFit.expand,
children: <Widget>[
Image.asset(
'assets/images/detail_bg.jpg',
fit: BoxFit.fill,
),
Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
color: Colors.purple.withOpacity(0.1),
),
],
),
),
Positioned(
top: 50,
left: 20,
child: IconButton(
icon: Icon(
Icons.arrow_back_ios,
color: Colors.white,
),
onPressed: () {
Navigator.pop(context);
},
),
),
Positioned(
top: MediaQuery.of(context).size.height / 3.6 - 40,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(60),
),
),
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 30),
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
SizedBox(
height: 130,
),
Text(
'Description',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20,
),
),
SizedBox(
height: 10,
),
Text(
'${widget.electricain['desc']}',
style: TextStyle(
color: Colors.grey,
),
textAlign: TextAlign.justify,
),
SizedBox(
height: 10,
),
Text(
"\n Services List",
style: TextStyle(
fontSize: 20.0, fontWeight: FontWeight.bold),
),
SizedBox(height: 10),
Text(
'${widget.electricain['services']}',
style: TextStyle(
color: Colors.grey,
),
),
SizedBox(height: 30),
MaterialButton(
onPressed: () {},
color: Colors.orange,
child: Text(
"Contact",
style: TextStyle(
color: Colors.white, fontSize: 16.0),
),
),
SizedBox(height: 10),
Text(
'${widget.electricain['services']}',
style: TextStyle(
color: Colors.grey,
),
),
],
),
),
),
),
),
),
Positioned(
top: MediaQuery.of(context).size.height / 3 - 90,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 30),
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Container(
width: MediaQuery.of(context).size.width / 3 - 20,
height: MediaQuery.of(context).size.height / 6 + 20,
decoration: BoxDecoration(
color: widget.electricain['bgColor'],
borderRadius: BorderRadius.circular(20),
),
child: Stack(
fit: StackFit.expand,
children: <Widget>[
Positioned(
top: 10,
right: -25,
child: Image.asset(
widget.electricain['imgUrl'],
scale: 1.7,
),
),
],
),
),
SizedBox(
width: 20,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
widget.electricain['electricainName'],
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20,
),
),
SizedBox(
height: 5,
),
Text(
widget.electricain['shopName'],
style: TextStyle(
fontWeight: FontWeight.w300,
color: Colors.grey,
),
),
SizedBox(
height: 10,
),
Row(
children: <Widget>[
Icon(
Icons.star,
size: 16,
color: Color(0xffFF8573),
),
SizedBox(width: 5),
Text(
widget.electricain['rating'],
style: TextStyle(
color: Color(0xffFF8573),
),
),
SizedBox(
width: 5,
),
Text(
'(${widget.electricain['rateAmount']})',
style: TextStyle(
color: Colors.grey,
),
),
],
)
],
),
],
),
),
),
],
),
),
);
}
}
try this:
LayoutBuilder(builder: (context, constraints) {
return SingleChildScrollView(
child: ConstrainedBox(
constraints: BoxConstraints(minWidth: constraints.maxWidth, minHeight: constraints.maxHeight),
child: IntrinsicHeight(
child: Column(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
//your children here
]
),
)
)
);
})
IntrinsicHeight class
A widget that sizes its child to the child's intrinsic height.
This class is useful, for example, when unlimited height is available and you would like a child that would otherwise attempt to expand infinitely to instead size itself to a more reasonable height.

handling application layout in flutter app

I have Entry page to my app like below, I am getting bottom overflow , image size issue , text font issue, when I run on the phone with less than 5 inches,
If I run the same app on over 5 inches I am getting like below
Can anyone who have worked on developing flutter apps help me on how I can adjust according to the screen?
also How to adjust text size, image size every other things as per the screen size?
below is my code:
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
Color colorTheme;
class LoginPage extends StatefulWidget {
#override
_LoginPageState createState() => new _LoginPageState();
}
class _LoginPageState extends State<LoginPage> {
TextEditingController controllerEmail = TextEditingController();
TextEditingController controllerPassword = TextEditingController();
String username, password;
Widget loginButtonChild = const Text(
"Log in",
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white, fontFamily: "OpenSans-Regular", fontSize: 16),
);
Widget loginButtonWithCircle = Row(
children: <Widget>[
const Text(
"Log in",
style: TextStyle(
color: Colors.white,
fontFamily: "OpenSans-Regular",
),
),
CircularProgressIndicator(),
],
);
#override
Widget build(context) {
double maxHeight = MediaQuery.of(context).size.height;
// ScreenUtil.instance = ScreenUtil.getInstance()..init(context);
return Scaffold(
resizeToAvoidBottomPadding: true,
body: SingleChildScrollView(
child: LimitedBox(
maxHeight: maxHeight * 1,
child: Stack(
//fit: StackFit.expand,
children: <Widget>[
Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: EdgeInsets.only(
top: MediaQuery.of(context).size.height * 0.05,
left: MediaQuery.of(context).size.width * 0.05),
child: Image.asset('assets/Heat Map.png',
width: 100, height: 20, fit: BoxFit.fill),
)
],
),
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Stack(
children: <Widget>[
Container(
decoration: BoxDecoration(
borderRadius:
BorderRadius.all(Radius.circular(15))),
padding: EdgeInsets.all(
// MediaQuery.of(context).size.width * 0.09,
MediaQuery.of(context).size.width * 0.1,
),
child: Image.asset(
'assets/layer_1_3.png',
// color: Color(0xFFe31735),
// width: 300,
width: MediaQuery.of(context).size.width * 0.72,
// height: 300,
height: MediaQuery.of(context).size.height * 0.5,
fit: BoxFit.contain,
),
),
Positioned(
left: 78.0,
bottom: 10.0,
child: RichText(
text: TextSpan(
text: 'APP',
style: TextStyle(
fontWeight: FontWeight.bold, color: Colors.black),
children: <TextSpan>[
TextSpan(
text: '\nDevelopment',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.normal,
),
),
TextSpan(
text: '\nFlutter',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.normal,
),
),
],
),
maxLines: 3,
overflow: TextOverflow.ellipsis,
softWrap: true,
),
),
],
),
SingleChildScrollView(
child: new Container(
padding: const EdgeInsets.fromLTRB(20.0, 0.0, 40.0, 40.0),
child: new Form(
child: new Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Row(
children: <Widget>[
Padding(
padding: EdgeInsets.only(top: 20),
child: Icon(Icons.person_outline,
size: 38, color: Colors.black),
),
SizedBox(width: 10.0),
new Expanded(
child: new TextFormField(
style: TextStyle(color: Colors.black),
controller: controllerEmail,
//cursorColor: , make it yellow later TODO
decoration: new InputDecoration(
labelText: "Username",
enabledBorder: new UnderlineInputBorder(
borderSide: new BorderSide(
color: Colors.red,
))),
keyboardType: TextInputType.text,
),
),
],
),
Row(
children: <Widget>[
Padding(
padding: EdgeInsets.only(top: 20),
child: Icon(
Icons.lock_outline,
size: 38,
color: Colors.black,
),
),
SizedBox(width: 10.0),
new Expanded(
child: new TextFormField(
controller: controllerPassword,
style: TextStyle(color: Colors.red),
decoration: new InputDecoration(
labelText: "Password",
enabledBorder: new UnderlineInputBorder(
borderSide: new BorderSide(
color: Colors.red,
))),
obscureText: true,
keyboardType: TextInputType.text,
),
),
],
),
Padding(
padding: EdgeInsets.only(
top: 0,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
FlatButton(
onPressed: () {
},
child: Text(
"Forgot password?",
style: TextStyle(
color: Colors.grey,
fontFamily: "OpenSans-Regular",
),
),
)
],
),
),
SizedBox(
height: MediaQuery.of(context).size.width * 0.04,
),
RaisedButton(
shape: RoundedRectangleBorder(
borderRadius:
new BorderRadius.circular(25.0),
side: BorderSide(color: Colors.red)),
color: Colors.red,
child: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Padding(
padding: EdgeInsets.only(left: 48),
child: loginButtonChild,
),
const SizedBox(
width: 45.0,
height: 45.0,
),
Icon(Icons.arrow_forward,
color: Colors.white),
],
),
onPressed: () {
}),
],
),
),
),
),
],
),
],
),
),
),
);
}
}
You can use SingleChildScrollView to avoid overflow error just wrap your widget with SingleChildScrollView
Example:-
SingleChildScrollView(
child: Container(
height: MediaQuery.of(context).size.height,
child:YourWidget();
)
)