How to fade text when text is overflowed? - flutter

I'm having a problem with handling texts when they overflow. I've tried overflow: TextOverflow.xxxx ,Expanded and Flexible but it's still doesn't work. Can anyone help me with this situation?
class _FeaturedCardState extends State<FeaturedCard>{
#override
Widget build(BuildContext context) {
return InkWell(
onTap: () {
showToast(widget.name, context);
},
child: Padding(
padding: EdgeInsets.only(top: 5.0),
child: Container(
height: MediaQuery.of(context).size.height / 9,
width: MediaQuery.of(context).size.width,
child: Card(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5.0)),
elevation: 3.0,
child: Row(
children: <Widget>[
Padding(
padding: EdgeInsets.all(5.0),
child: CircleAvatar(
radius: 20,
backgroundImage: AssetImage(widget.img),
backgroundColor: Colors.transparent,
),
),
SizedBox(width: 10),
Padding(
padding: EdgeInsets.fromLTRB(0.0, 3.0, 3.0, 3.0),
child: Wrap(
direction: Axis.vertical,
children: <Widget>[
SizedBox(height: 2),
Text(
widget.name,
style: TextStyle(
fontFamily: 'Montserrat',
fontSize: 15,
color: Colors.blueGrey,
),
),
SizedBox(height: 3),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Icon(
Icons.attach_money,
size: 11,
),
Text(
widget.salary,
style: TextStyle(
fontSize: 10,
fontFamily: 'Montserrat',
color: Colors.blue[300]
),
)
],
),
SizedBox(height: 3),
Text( // This is the text that overflows
widget.desc,
style: TextStyle(
fontFamily: 'Montserrat',
fontSize: 12,
),
maxLines: 1,
softWrap: false,
overflow: TextOverflow.fade,
),
],
),
)
],
),
),
),
),
);
}
I've searched a lot of atricles and it still doesn't help. If anyone could come up with a solution for this that'll be really great. Any help would be appreciated, thank you.

You can try this,
class _FeaturedCardState extends State<FeaturedCard> {
#override
Widget build(BuildContext context) {
return Padding(
padding: EdgeInsets.all(5.0),
child: Material(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5.0),
),
elevation: 3.0,
child: InkWell(
borderRadius: BorderRadius.circular(5.0),
onTap: (){
showToast(widget.name, context);
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: <Widget>[
CircleAvatar(
radius: 20,
backgroundImage: AssetImage(widget.img),
backgroundColor: Colors.transparent,
),
const SizedBox(width: 10),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Text(
widget.name,
style: TextStyle(
fontFamily: 'Montserrat',
fontSize: 15,
color: Colors.blueGrey,
),
),
const SizedBox(height: 3),
Text(
"\u0024${widget.salary}", // Char code for $ symbol "\u0024"
style: TextStyle(
fontSize: 10,
fontFamily: 'Montserrat',
color: Colors.blue[300],
),
),
const SizedBox(height: 3),
Text(
// This is the text that overflows
widget.desc,
style: TextStyle(
fontFamily: 'Montserrat',
fontSize: 12,
),
maxLines: 1,
softWrap: false,
overflow: TextOverflow.fade,
),
],
),
)
],
),
),
),
),
);
}
}

Add your Text in Container and set static width for Container
for example:
Container(
width: MediaQuery.of(context).size.width*0.7,
child: Text( "xxxxx",),
),

Related

Flutter comment_tree 0.3.0 How to remove replies under comments

I use the component as in the description, I can’t figure out how to remove the answer (child component) in the component itself, or at least how to check if it exists, then show it, if not, then don’t show it.
https://gist.github.com/lomanu4/3abba49f6fbcecbde4c07df82c3ce11c
class _ComentCardState extends State<ComentCard> {
bool childcomment = false;
#override
Widget build(BuildContext context) {
return Column(children: [
Container(
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
child: CommentTreeWidget<Comment, Comment?>(
Comment(
avatar: 'null',
userName: widget.snap['name'],
content: '${widget.snap['text']} '),
[
Comment(avatar: 'null', userName: 'null', content: 'null'),
],
treeThemeData: childcomment
? TreeThemeData(lineColor: Colors.green[500]!, lineWidth: 3)
: TreeThemeData(lineColor: Colors.green[500]!, lineWidth: 3),
avatarRoot: (context, data) => PreferredSize(
preferredSize: const Size.fromRadius(18),
child: Row(
children: [
CircleAvatar(
radius: 18,
backgroundColor: Colors.grey,
backgroundImage:
NetworkImage(widget.snap['profilePic'].toString()),
),
],
),
),
avatarChild: (context, data) => const PreferredSize(
preferredSize: Size.fromRadius(12),
child: CircleAvatar(
radius: 12,
backgroundColor: Colors.grey,
backgroundImage: AssetImage('lib/assets/homescreen.png'),
),
),
contentChild: (context, data) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding:
const EdgeInsets.symmetric(vertical: 8, horizontal: 8),
decoration: BoxDecoration(
color: Colors.grey[100],
borderRadius: BorderRadius.circular(12)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'dangngocduc',
style: Theme.of(context).textTheme.caption?.copyWith(
fontWeight: FontWeight.w600, color: Colors.black),
),
const SizedBox(
height: 4,
),
Text(
'${data!.content}',
style: Theme.of(context).textTheme.caption?.copyWith(
fontWeight: FontWeight.w300, color: Colors.black),
),
],
),
),
DefaultTextStyle(
style: Theme.of(context).textTheme.caption!.copyWith(
color: Colors.grey[700], fontWeight: FontWeight.bold),
child: Padding(
padding: const EdgeInsets.only(top: 4),
child: Row(
children: const [
SizedBox(
width: 8,
),
Text('Reply'),
],
),
),
)
],
);
},
contentRoot: (context, data) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding:
const EdgeInsets.symmetric(vertical: 8, horizontal: 8),
decoration: BoxDecoration(
color: Colors.grey[100],
borderRadius: BorderRadius.circular(12)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
widget.snap['name'],
style: Theme.of(context).textTheme.caption!.copyWith(
fontWeight: FontWeight.w600, color: Colors.black),
),
const SizedBox(
height: 4,
),
Text(
'${data.content}',
style: Theme.of(context).textTheme.caption!.copyWith(
fontWeight: FontWeight.w300, color: Colors.black),
),
const SizedBox(
height: 4,
),
],
),
),
DefaultTextStyle(
style: Theme.of(context).textTheme.caption!.copyWith(
color: Colors.grey[700], fontWeight: FontWeight.bold),
child: Padding(
padding: const EdgeInsets.only(top: 4),
child: Row(
children: [
SizedBox(
width: 8,
),
Text('Like'),
SizedBox(
width: 24,
),
Expanded(child: Text('Reply')),
Container(
padding: const EdgeInsets.all(8),
child: const Icon(
Icons.favorite_border,
size: 16,
),
)
],
),
),
),
],
);
},
),
),
]);
}

Add buttons below the body

The code below (I shortened the code for simplicity) displays the characteristics of the device. I placed all the characteristics in the body and displayed them in a certain way. Tell me how I can make two buttons (marked in red in the photo) under the body. Or put them in the body? tell me the best way to do it.
return Scaffold(
appBar: AppBar(
automaticallyImplyLeading: false,
),
body: Align(
alignment: Alignment.topCenter,
child: Container(
constraints: const BoxConstraints(maxWidth: 800, maxHeight: 400),
decoration: BoxDecoration(
color: Colors.black,
borderRadius: BorderRadius.circular(5.0),),
child: SingleChildScrollView(
child: Card(
child: Column(
children: [
ListTile(
title: const Text('Brand:', style: TextStyle(fontWeight: FontWeight.w400, fontSize: 25)),
trailing: Text('${device.brand} ', style: const TextStyle(fontWeight: FontWeight.w400, fontSize: 20 ))),
const Divider(color: Colors.black, endIndent: 10, indent: 10),
ListTile(
title: const Text('Operation system:', style: TextStyle(fontWeight: FontWeight.w400, fontSize: 25)),
trailing: Text('${device.operation_system} ', style: const TextStyle(fontWeight: FontWeight.w400, fontSize: 20 ))),
],
),
),
)
),
));
You can use bottomNavigationBar on Scaffold
Scaffold(
bottomNavigationBar: Padding(
padding: const EdgeInsets.all(8.0), //the one you prefer
child: Row(
children: [
Expanded(
child: OutlinedButton(
onPressed: () {},
child: Text("NNNNNN"),
),
),
SizedBox(
//space between button
width: 16,
),
Expanded(
child: OutlinedButton(
onPressed: () {},
child: Text("NNNNNN"),
),
),
],
),
),
Also, you can wrap Container with Column widget
body: Column(
children: [
Container(...)//your widget
Padding(
padding: const EdgeInsets.all(8.0), //the one you prefer
child: Row(
children: [
Expanded(child: OutlinedButton(...)),
SizedBox(width:x),
Expanded(child: OutlinedButton(...)),
Full snippet on second approach
return Scaffold(
body: Column(
children: [
Container(
constraints: const BoxConstraints(maxWidth: 800, maxHeight: 400),
decoration: BoxDecoration(
color: Colors.black,
borderRadius: BorderRadius.circular(5.0),
),
child: SingleChildScrollView(
child: Card(
child: Column(
children: [
ListTile(
title: const Text('Brand:',
style: TextStyle(
fontWeight: FontWeight.w400, fontSize: 25)),
trailing: Text('${device.brand} ',
style: const TextStyle(
fontWeight: FontWeight.w400, fontSize: 20))),
const Divider(
color: Colors.black, endIndent: 10, indent: 10),
ListTile(
title: const Text('Operation system:',
style: TextStyle(
fontWeight: FontWeight.w400, fontSize: 25)),
trailing: Text('${device.operation_system} ',
style: const TextStyle(
fontWeight: FontWeight.w400, fontSize: 20))),
],
),
),
)),
// Spacer(), /// you you want at the bottom
Padding(
padding: const EdgeInsets.all(8.0), //the one you prefer
child: Row(
children: [
Expanded(
child: OutlinedButton(
onPressed: () {},
child: Text("NNNNNN"),
),
),
SizedBox(
//space between button
width: 16,
),
Expanded(
child: OutlinedButton(
onPressed: () {},
child: Text("NNNNNN"),
),
),
],
),
)
],
),
);
You can check more about widgets, Column and layout.

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
],
))
],
),
),
),
],
),
),
));
}
}

Bottom Overflowed by 81 Pixels

I'm pretty much self-tutoring flutter and I'm working on a personal project. I wrapped it to singlechildscrollview but it still produces the problem. The code below:
class ScheduleDetail extends StatefulWidget {
var data;
ScheduleDetail(this.data);
#override
// ScheduleDetail({Key key, this.todos}) : super(key: key);
_ScheduleDetailState createState() => _ScheduleDetailState();
}
class _ScheduleDetailState extends State<ScheduleDetail>{
String foos = 'One';
#override
void initState() {
super.initState();
}
#override
Widget build(BuildContext context) {
ScreenUtil.instance =
ScreenUtil(width: 750, height: 1425, allowFontScaling: true)
..init(context);
return Scaffold(
extendBodyBehindAppBar: true,
appBar: AppBar(
// title: Text("String Master"),
title: SvgPicture.asset('assets/images/Logo_small.svg'),
centerTitle: true,
backgroundColor: Colors.transparent,
),
body: BackgroundImageWidget(
child: Center(
child: Container(
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
height: ScreenUtil.getInstance().setHeight(150),
),
Container(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil.getInstance().setWidth(40),
),
child: Text(
AppStrings.scheduleTitle,
style: TextStyles.appName,
textAlign: TextAlign.center,
),
),
Container(
height: ScreenUtil.getInstance().setHeight(50),
),
SingleChildScrollView(
child: ConstrainedBox(
constraints: BoxConstraints(maxHeight: MediaQuery.of(context).size.height * 0.82),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Expanded(
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil.getInstance().setWidth(40),
),
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
_buildTopCard(),
SizedBox(height: 10),
_buildTimeCard(),
SizedBox(height: 10),
ListTile(
title: Text(
"Calendar",
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.green,
fontSize: 16
),
),
),
Container(color: Colors.grey, height: 1),
_buildNoticeExpansionTile(),
Container(color: Colors.grey, height: 1),
_buildMemoExpansionTile(),
],
)),
),
],
)
)
),
],
)),
)));
}
Widget _buildTopCard() {
return Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(7.0),
),
elevation: 15,
child: ClipPath(
clipper: ShapeBorderClipper(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(7.0))),
child: Stack(
children: <Widget>[
Container(
height: 150,
decoration: BoxDecoration(
border: Border(
top: BorderSide(color: Colors.green, width: 30)),
color: Colors.white,
),
alignment: Alignment.centerLeft,
child: Column(
children: <Widget>[
ListTile(
title: Text(widget.data['eventTitle'],
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.green,
),
),
subtitle: Text(
widget.data['location'],
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.grey.shade600
),
),
),
Container(
padding: EdgeInsets.only(left: 10, right: 10),
child:
Divider(color: Colors.grey),
),
Container(
padding: EdgeInsets.only(left: 10, right: 10),
child: Row (
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
widget.data['startDate'] + " " + widget.data['timeStart'],
style: TextStyle(
color: Colors.grey.shade600,
fontStyle: FontStyle.italic,
fontSize: 14
),
),
Spacer(flex: 2),
Text(
widget.data['startDate'] + " " + widget.data['timeEnd'],
style: TextStyle(
color: Colors.grey.shade600,
fontSize: 14,
fontStyle: FontStyle.italic,
),
),
]
)
),
],
)
),
Positioned(
left: 10,
top: 7,
width: 325,
child: Container(
padding: EdgeInsets.only(bottom: 10, left: 5, right: 5),
color: Colors.transparent,
child: Row (
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
widget.data['startDate'],
style: TextStyle(fontWeight: FontWeight.bold, color: Colors.white, fontSize: 14),
),
Spacer(flex: 2),
Text(
widget.data['timeStart'],
style: TextStyle(fontWeight: FontWeight.bold, color: Colors.white, fontSize: 14),
),
],
)
),
),
],
)
),
);
}
Widget _buildTimeCard() {
return Container(
height: 125,
width: 400,
margin: EdgeInsets.all(5.0),
decoration: BoxDecoration(
color: Colors.black,
border: Border.all(
color: Colors.green,
width: 0.5,
),
borderRadius: BorderRadius.circular(7.0),
),
child: Center(
child: Text(
'TIME OF EVENT',
style: TextStyle(fontWeight: FontWeight.bold, color: Colors.white, fontSize: 14),
),
),
);
}
Widget _buildNoticeExpansionTile() {
return Theme(
data: Theme.of(context).copyWith(unselectedWidgetColor: Colors.white, accentColor: Colors.white),
child: ExpansionTile(
title: new Text(
"Notice",
style: TextStyle(
color: Colors.green,
fontSize: 16
),
),
backgroundColor: Colors.transparent,
children: <Widget>[
Container(
child: ListView.builder(
padding: EdgeInsets.all(0.0),
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: widget.data['notice'] != null ? widget.data['notice'].length : 0,
itemBuilder: (BuildContext context, int index){
return
Padding(
padding: EdgeInsets.only(left: 15, bottom: 10),
child: Text(
"\u2022 " + widget.data['notice'][index],
style: TextStyle(
color: Colors.white,
fontSize: 14
),
)
);
}
)
),
]
)
);
}
Widget _buildMemoExpansionTile() {
return
Theme(
data: Theme.of(context).copyWith(unselectedWidgetColor: Colors.white, accentColor: Colors.white),
child: ExpansionTile(
title: new Text(
"Memo",
style: TextStyle(
color: Colors.green,
fontSize: 16
),
),
backgroundColor: Colors.transparent,
children: <Widget>[
ListView.builder(
padding: EdgeInsets.all(0.0),
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: widget.data['memo'] != null ? widget.data['memo'].length : 0,
itemBuilder: (BuildContext context, int index){
return
Padding(
padding: EdgeInsets.only(left: 15, bottom: 10),
child: Text(
(index + 1).toString() + ". " + widget.data['memo'][index],
style: TextStyle(
color: Colors.white,
fontSize: 14
),
)
);
}
)
]
)
);
}
}
Perhaps my mistake could be from one of those objects that I have used. However, I can't figure it out even though I searched around the internet. My intention is when the expandable tiles have 'overlapped' the screen size, you would be able to scroll it all the way down.
Wrap the SingleChildScrollView in Expanded Widget.
You can make use of the flutter dev tools for identifying overlapping issues.
I simplified the scaffold then wrapped SingleChildScrollView within Flexible.

ClipRRect not working properly using carousel inside listview(scrollview)

I am using a carousel from the package https://pub.dev/packages/carousel_slider, inside my listview (scrollview). I want to make my images have a round corner border.
I used clipRRect and it works (clip corner image with round border). But something strange happens to my apps. Here my result, I upload to google drive, please download first
https://drive.google.com/open?id=1YNRk3q87-wD080eNvLa9OQ1j2KytvaJW
And here my code
class HomeScreen extends StatelessWidget {
Widget menus(){
return Container(
margin: EdgeInsets.symmetric(horizontal: 21, vertical: 18),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
'Layanan favorit',
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w700,
),
),
Text(
'Lihat Semua',
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w700,
color: Color(0xFFFF2800)
),
),
],
),
Container(
margin: EdgeInsets.only(top: 12),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
IconMenu(
text: 'Token Listrik',
image: SvgPicture.asset(ICON_ELECTRICITY),
),
IconMenu(
text: 'Pulsa',
image: SvgPicture.asset(ICON_BALANCE),
),
IconMenu(
text: 'Paket Data',
image: SvgPicture.asset(ICON_DATA),
),
],
),
),
Container(
margin: EdgeInsets.only(top: 28),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
IconMenu(
text: 'Kereta Api',
image: SvgPicture.asset(ICON_TRAIN),
),
IconMenu(
text: 'e Money',
image: SvgPicture.asset(ICON_EMONEY),
),
IconMenu(
text: 'Pasca Bayar',
image: SvgPicture.asset(ICON_POSTPAID),
),
],
),
)
],
),
);
}
Widget offers(){
return Container(
margin: EdgeInsets.symmetric(vertical: 18),
child: Column(
children: <Widget>[
Container(
margin: EdgeInsets.symmetric(horizontal: 21),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
'Hot offers',
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w700,
),
),
Text(
'Lihat Semua',
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w700,
color: Color(0xFFFF2800)
),
),
],
),
),
Container(
margin: EdgeInsets.only(top: 8),
child: CarouselOffers(),
)
],
),
);
}
#override
Widget build(BuildContext context) {
// TODO: implement build
return SafeArea(
child: Scaffold(
appBar: HomeAppBar(),
body: Container(
child: ListView(
children: <Widget>[
Card(
margin: EdgeInsets.fromLTRB(21, 21, 21, 18),
child: Column(
children: <Widget>[
Container(
padding: EdgeInsets.fromLTRB(20, 11, 20, 11),
decoration: BoxDecoration(
borderRadius: new BorderRadius.only(
topLeft: Radius.circular(8.0),
topRight: Radius.circular(8.0)),
color: Theme.of(context).primaryColor
),
child: Row(
children: <Widget>[
Expanded(
child: Container(
child: Text(
'Kasku Balance',
style: TextStyle(
color: Colors.white,
fontSize: 15,
fontWeight: FontWeight.w700
),
),
),
),
Container(
margin: EdgeInsets.only(right: 8),
child: Text(
'Rp 2.000.000',
style: TextStyle(
color: Colors.white,
fontSize: 15,
fontWeight: FontWeight.w700
)
),
),
Container(
child: GestureDetector(
child: Icon(
Icons.refresh,
color: Colors.white,
),
),
),
],
),
),
Container(
padding: EdgeInsets.only(top: 16, bottom: 16),
decoration: BoxDecoration(
borderRadius: new BorderRadius.only(
bottomLeft: Radius.circular(8.0),
bottomRight: Radius.circular(8.0)),
color: Colors.white
),
child: Row(
children: <Widget>[
Expanded(
child: Column(
children: <Widget>[
Container(
child: SvgPicture.asset(ICON_TOPUP),
),
Container(
margin: EdgeInsets.only(top: 12),
child: Text(
'Isi Saldo',
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 12,
color: Color(0xFF231F20)
),
),
)
],
),
),
Container(
width: 1,
height: 54,
color: Color(0xFFD8D8D8),
),
Expanded(
child: Column(
children: <Widget>[
Container(
child: SvgPicture.asset(ICON_PAY),
),
Container(
margin: EdgeInsets.only(top: 12),
child: Text(
'Bayar',
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 12,
color: Color(0xFF231F20)
),
),
)
],
),
),
Container(
width: 1,
height: 54,
color: Color(0xFFD8D8D8),
),
Expanded(
child: Column(
children: <Widget>[
Container(
child: SvgPicture.asset(ICON_TRANSFER),
),
Container(
margin: EdgeInsets.only(top: 12),
child: Text(
'Transfer',
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 12,
color: Color(0xFF231F20)
),
),
)
],
),
),
],
),
),
],
),
elevation: 5,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
),
menus(),
offers(),
news(),
news2()
],
),
),
bottomNavigationBar: BottomNavigationBar(
items: <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.home),
title: Text('Home'),
),
BottomNavigationBarItem(
icon: Icon(Icons.business),
title: Text('Jelajah'),
),
BottomNavigationBarItem(
icon: Icon(Icons.school),
title: Text('Layanan'),
),
BottomNavigationBarItem(
icon: Icon(Icons.school),
title: Text('Transaksi'),
),
BottomNavigationBarItem(
icon: Icon(Icons.school),
title: Text('Profile'),
),
],
type: BottomNavigationBarType.fixed,
),
),
);
}
}
class CarouselOffers extends StatefulWidget{
#override
_CarouselOffersState createState() => _CarouselOffersState();
}
class _CarouselOffersState extends State<CarouselOffers> {
int _current = 0;
List<Widget> widgets(){
return ['https://cdn2.tstatic.net/lampung/foto/bank/images/bukalapak-promo-bulan-ramadan_20180511_135232.jpg', 'https://cdn2.tstatic.net/lampung/foto/bank/images/bukalapak-promo-bulan-ramadan_20180511_135232.jpg'].map((i) {
return Builder(
builder: (BuildContext context) {
return Container(
width: MediaQuery.of(context).size.width,
margin: EdgeInsets.symmetric(horizontal: 5.0),
child: ClipRRect(
borderRadius: BorderRadius.circular(8.0),
child: Image.network(
i,
fit: BoxFit.fill,
),
),
);
},
);
}).toList();
}
#override
Widget build(BuildContext context) {
return Column(
children: <Widget>[
CarouselSlider(
pauseAutoPlayOnTouch: Duration(seconds: 3),
aspectRatio: 16/6,
items: widgets(),
onPageChanged: (index) {
setState(() {
_current = index;
});
},
autoPlay: true,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: map<Widget>(widgets(), (index, url) {
return Container(
width: 6.0,
height: 6.0,
margin: EdgeInsets.symmetric(vertical: 10.0, horizontal: 4.0),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: _current == index ? Theme.of(context).primaryColor : Color.fromRGBO(0, 0, 0, 0.4)
),
);
}),
)
],
);
}
}
what is wrong with my code? any ideas?
Sorry for late answer.
Everything is fine when using real device. I do not know why ClipperRRect not working properly when using emulator (Genymotion).