Related
want to add the bottom search bar and bottom icon bar using flutter in my home_dart page. can someone help me, please? already add 3 cards to the page. how can I add a search bar and bottom icon bar as shown in the picture? I'm trying to create a fashion app UI. I'm new to flutter. if someone can help me it would be great.
home_page.dart
import 'package:flutter/material.dart';
import 'package:fashion_app/color_filters.dart';
class HomePage extends StatefulWidget{
#override
_HomePageState createState ()=> _HomePageState();
}
class _HomePageState extends State <HomePage> {
final double _borderRadious = 24;
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Fashion store'),
),
body: ListView(
padding: const EdgeInsets.all(16),
children: [
buildColoredCard1(),
buildColoredCard2(),
buildColoredCard3()
],
),
);
}
Widget buildColoredCard1() =>
Card(
shadowColor: Colors.red,
elevation: 8,
clipBehavior: Clip.antiAlias,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(24),
),
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Colors.redAccent, Colors.red],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
),
padding: EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Colored card',
style: TextStyle(
fontSize: 20,
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 50),
Text(
'This card is rounded and has a gradient',
style: TextStyle(
fontSize: 20,
color: Colors.white,
),
),
],
),
),
);
Widget buildColoredCard2() =>
Card(
shadowColor: Colors.red,
elevation: 8,
clipBehavior: Clip.antiAlias,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(24),
),
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Colors.redAccent, Colors.red],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
),
padding: EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Colored card',
style: TextStyle(
fontSize: 20,
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 50),
Text(
'This card is rounded and has a gradient',
style: TextStyle(
fontSize: 20,
color: Colors.white,
),
),
],
),
),
);
Widget buildColoredCard3() =>
Card(
shadowColor: Colors.red,
elevation: 8,
clipBehavior: Clip.antiAlias,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(24),
),
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Colors.redAccent, Colors.red],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
),
padding: EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Colored card',
style: TextStyle(
fontSize: 20,
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 50),
Text(
'This card is rounded and has a gradient',
style: TextStyle(
fontSize: 20,
color: Colors.white,
),
),
],
),
),
);
}
//use this method for the search and let me know if it's work
Widget buildSearchInput() => Container(
decoration: BoxDecoration(
color: Colors.grey[200], borderRadius: BorderRadius.circular(20)),
child: Padding(
padding: const EdgeInsets.only(left: 10.0, right: 20),
child: Row(
children: [
Icon(
Icons.search,
size: 30,
color: Colors.grey,
),
Flexible(
child: TextField(
decoration: InputDecoration(border: InputBorder.none),
),
),
],
),
),
);
I want these animation between to be smooth, I tried using AnimatedSize, AnimatedOpacity and AnimatedPositioned but there were few errors. And I don't know how to use these with SliverAppBar. In other examples I saw people using LayoutBuilder but they didn't share the full code so I couldn't test it. I will share my code snippet but it has a really odd transition between the two states.
I want CircleAvatar to become smaller and change position
I want Icon(Icons.arrow_back) and Text('Previous Page') to disappear.
I also want my name and job to disappear.
I want that three Containers to become smaller and change position.
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Dialog Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Scaffold(
body: CustomScrollView(
slivers: [
SliverAppBar(
elevation: 0,
pinned: true,
expandedHeight: 190,
collapsedHeight: kToolbarHeight + 8,
flexibleSpace: FlexibleSpaceBar(
collapseMode: CollapseMode.none,
centerTitle: true,
titlePadding: EdgeInsetsDirectional.only(
start: 20.0,
end: 20.0,
top: 12.0,
bottom: 12.0,
),
title: SafeArea(
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
CircleAvatar(
radius: 16,
),
Row(
children: [
Container(
decoration: BoxDecoration(
color: Colors.white10,
borderRadius: BorderRadius.all(
Radius.circular(12),
),
),
padding: EdgeInsets.all(8.0),
child: Icon(Icons.person),
),
SizedBox(
width: 8,
),
Container(
decoration: BoxDecoration(
color: Colors.white10,
borderRadius: BorderRadius.all(
Radius.circular(12),
),
),
padding: EdgeInsets.all(8.0),
child: Icon(Icons.menu),
),
SizedBox(
width: 8,
),
Container(
decoration: BoxDecoration(
color: Colors.white10,
borderRadius: BorderRadius.all(
Radius.circular(12),
),
),
padding: EdgeInsets.all(8.0),
child: Icon(Icons.message),
),
],
),
],
),
],
),
),
background: SafeArea(
child: Column(
children: [
Container(
alignment: Alignment.topLeft,
child: Row(
children: [
IconButton(
icon: Icon(Icons.arrow_back),
onPressed: () {},
),
Text(
'PREVIOUS PAGE',
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
),
),
],
),
),
Padding(
padding: const EdgeInsets.only(
left: 20,
top: 12,
bottom: 24,
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CircleAvatar(
radius: 20,
),
SizedBox(
width: 12,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Sertan Hakkı İmamoğlu',
style: TextStyle(
fontSize: 18,
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
Text(
'Student',
style: TextStyle(
fontSize: 14,
color: Colors.grey,
),
),
SizedBox(
height: 12,
),
Row(
children: [
Container(
decoration: BoxDecoration(
color: Colors.white10,
borderRadius: BorderRadius.all(
Radius.circular(12),
),
),
padding: EdgeInsets.symmetric(
horizontal: 34,
vertical: 12,
),
child: Icon(Icons.menu),
),
SizedBox(
width: 4,
),
Container(
decoration: BoxDecoration(
color: Colors.white10,
borderRadius: BorderRadius.all(
Radius.circular(12),
),
),
padding: EdgeInsets.symmetric(
horizontal: 34,
vertical: 12,
),
child: Icon(Icons.person),
),
SizedBox(
width: 4,
),
Container(
decoration: BoxDecoration(
color: Colors.white10,
borderRadius: BorderRadius.all(
Radius.circular(12),
),
),
padding: EdgeInsets.symmetric(
horizontal: 34,
vertical: 12,
),
child: Icon(Icons.message),
),
],
)
],
)
],
),
),
],
),
),
),
),
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return Container(
color: index.isOdd ? Colors.white : Colors.black12,
height: 100.0,
child: Center(
child: Text('$index', textScaleFactor: 5),
),
);
},
childCount: 20,
),
),
],
),
),
);
}
}
Here's my take on your issue, as suggested by pskink I've used a SliverPersistentHeader and tried to make it responsive so when the size is reducing it has a bit of an animation.
Sample Code
class CustomPageHeader extends SliverPersistentHeaderDelegate {
CustomPageHeader({
required double collapsedHeight,
required double expandedHeight,
}) : minExtent = collapsedHeight, maxExtent = expandedHeight;
#override
final double minExtent;
#override
final double maxExtent;
Widget _buildBtn(IconData icon, double scale) {
double horizontal = 34.0 * scale;
horizontal = horizontal < 8 ? 8.0 : horizontal;
double vertical = 12.0 * scale;
vertical = vertical < 8 ? 8.0 : vertical;
return Container(
decoration: const BoxDecoration(
color: Colors.white10,
borderRadius: BorderRadius.all(
Radius.circular(12),
),
),
padding: EdgeInsets.symmetric(horizontal: horizontal, vertical: vertical),
child: Icon(icon),
);
}
#override
Widget build(
BuildContext context, double shrinkOffset, bool overlapsContent) {
final theme = Theme.of(context);
final backgroundColor =
theme.appBarTheme.backgroundColor ?? theme.colorScheme.primary;
final scale = 1 - shrinkOffset / maxExtent;
final isReduced = shrinkOffset >= maxExtent * 0.12;
final wrappedBtns = Wrap(
spacing: 8,
children: [
_buildBtn(Icons.menu, scale),
_buildBtn(Icons.person, scale),
_buildBtn(Icons.message, scale),
],
);
double avatarRadius = 20.0 * scale;
avatarRadius = avatarRadius > 16 ? avatarRadius : 16.0;
return Container(
padding: const EdgeInsets.only(
left: 20,
top: 12,
bottom: 12,
),
color: backgroundColor,
child: Column(
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CircleAvatar(radius: avatarRadius),
!isReduced
? const SizedBox(width: 12)
: Expanded(child: Container()),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (!isReduced)
Text(
'Sertan Hakkı İmamoğlu',
style: TextStyle(
fontSize: 18 * scale,
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
if (!isReduced)
Text(
'Student',
style: TextStyle(
fontSize: 14 * scale,
color: Colors.grey,
),
),
],
),
if (isReduced) wrappedBtns,
],
),
Flexible(
child: Container(
constraints: const BoxConstraints(maxHeight: 12),
),
),
if (!isReduced) wrappedBtns,
],
),
);
}
#override
bool shouldRebuild(_) => true;
}
Use it in your sliver list like this:
SliverPersistentHeader(
pinned: true,
delegate: CustomPageHeader(
collapsedHeight: kToolbarHeight + 8,
expandedHeight: 190,
),
),
Try the full test code on DartPad
The code is perfectible but should help you enough so you can improve it and continue by yourself.
I want to make UI like my upper image but I cant make like that But it is not being made as you are seeing in the image below.
I want to make leading of ListTile part like this .
But I can't make it please help me.
this is my code and UI
import 'package:flutter/material.dart';
class MyHomePage extends StatefulWidget {
#override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
#override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
padding: EdgeInsets.only(top: 30, left: 10, right: 10),
child: Column(
children: [
Row(
children: [
Text(
'Your rooms',
style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
),
Spacer(),
Card(
elevation: 1,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.0),
),
child: Padding(
padding: const EdgeInsets.all(5.0),
child: Row(
children: [
Text('add',
style: TextStyle(fontSize: 20, color: Colors.grey)),
Icon(
Icons.add,
size: 20,
color: Colors.grey,
)
],
),
),
)
],
),
SizedBox(
height: 20,
),
Container(
height: 110,
width: 380,
// color: Colors.red,
decoration: new BoxDecoration(
borderRadius: BorderRadius.circular(30),
color: Color(0xffbbf0e3),
),
child: Center(
child: ListTile(
leading: Container(
// height: 10,
width: 100,
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30.0)),
elevation: 1,
color: Colors.white,
child: Container(
decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(25),
shape: BoxShape.circle,
// color: Colors.red,
),
child: CircleAvatar(
radius: 25,
backgroundImage: NetworkImage(
'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTkNWsvdJGKCRYW_Wb-K40Po2JQ8LpooWoilw&usqp=CAU'),
),
),
),
),
// leading: Card(
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.circular(30.0)),
// elevation: 1,
// color: Colors.white,
// child: Container(
// height: 80,
// width: 75,
// decoration: BoxDecoration(
// // borderRadius: BorderRadius.circular(25),
// shape: BoxShape.circle,
// // color: Colors.red,
// ),
// child: CircleAvatar(
// radius: 25,
// backgroundImage: NetworkImage(
// 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTkNWsvdJGKCRYW_Wb-K40Po2JQ8LpooWoilw&usqp=CAU'),
// ),
// )),
title: Text(
"Living room",
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w700),
),
subtitle: Text(
'3 turned on',
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 20,
color: Colors.green),
),
trailing: Card(
elevation: 1,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.0),
),
child: Padding(
padding: const EdgeInsets.all(5.0),
child: Container(
width: 50,
child: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('5',
style: TextStyle(
fontSize: 20, color: Colors.grey)),
SizedBox(
width: 1,
),
Icon(
Icons.electrical_services,
textDirection: TextDirection.rtl,
size: 20,
color: Colors.grey,
)
],
),
),
),
),
),
),
)
],
),
),
);
}
}
I am making like this .
I removed some unnecessary Lines of Code and voilà there you go:
import 'package:flutter/material.dart';
class MyHomePage extends StatefulWidget {
#override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
#override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
padding: EdgeInsets.only(top: 30, left: 10, right: 10),
child: Column(
children: [
Row(
children: [
Text(
'Your rooms',
style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
),
Spacer(),
Card(
elevation: 1,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.0),
),
child: Padding(
padding: const EdgeInsets.all(5.0),
child: Row(
children: [
Text('add',
style: TextStyle(fontSize: 20, color: Colors.grey)),
Icon(
Icons.add,
size: 20,
color: Colors.grey,
)
],
),
),
)
],
),
SizedBox(
height: 20,
),
Container(
height: 110,
width: 380,
// color: Colors.red,
decoration: new BoxDecoration(
borderRadius: BorderRadius.circular(30),
color: Color(0xffbbf0e3),
),
child: Center(
child: ListTile(
leading: CircleAvatar( // I ONLY CHANGED THIS PART
radius: 25,
backgroundImage: NetworkImage(
'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTkNWsvdJGKCRYW_Wb-K40Po2JQ8LpooWoilw&usqp=CAU'),
),
// leading: Card(
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.circular(30.0)),
// elevation: 1,
// color: Colors.white,
// child: Container(
// height: 80,
// width: 75,
// decoration: BoxDecoration(
// // borderRadius: BorderRadius.circular(25),
// shape: BoxShape.circle,
// // color: Colors.red,
// ),
// child: CircleAvatar(
// radius: 25,
// backgroundImage: NetworkImage(
// 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTkNWsvdJGKCRYW_Wb-K40Po2JQ8LpooWoilw&usqp=CAU'),
// ),
// )),
title: Text(
"Living room",
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w700),
),
subtitle: Text(
'3 turned on',
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 20,
color: Colors.green),
),
trailing: Card(
elevation: 1,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.0),
),
child: Padding(
padding: const EdgeInsets.all(5.0),
child: Container(
width: 50,
child: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('5',
style: TextStyle(
fontSize: 20, color: Colors.grey)),
SizedBox(
width: 1,
),
Icon(
Icons.electrical_services,
textDirection: TextDirection.rtl,
size: 20,
color: Colors.grey,
)
],
),
),
),
),
),
),
)
],
),
),
);
}
}
Output
How to add circular border for dialog box in a flutter?,I tried the below code but I can't able to get the desired output, I already added circular border but it's not working, I need circular border for dialog,Refer the expected output for details, please guide
My code :
`
class CustomDialog extends StatelessWidget {
#override
Widget build(BuildContext context) {
const double padding = 1.0;
return Dialog(
backgroundColor: Colors.green,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(20.0))),
child: Column(mainAxisSize: MainAxisSize.min, children: [
Container(
margin: EdgeInsets.all(1),
width: double.infinity,
child: Text('title',
style: TextStyle(fontSize: 30, color: Colors.white)),
color: Colors.green,
),
Container(
color: Colors.white,
padding: EdgeInsets.all(10),
child: ListView(
shrinkWrap: true,
children: [
Container(
margin: EdgeInsets.only(left: 10, bottom: 10),
height: 30,
child: Text('one',
style: TextStyle(
fontSize: 20,
))),
Container(
margin: EdgeInsets.only(left: 10, bottom: 10),
height: 30,
child: Text('one',
style: TextStyle(
fontSize: 20,
))),
Container(
margin: EdgeInsets.only(left: 10, bottom: 10),
height: 30,
child: Text('one',
style: TextStyle(
fontSize: 20,
))),
],
),
),
Divider(
color: Colors.white,
),
Container(
color: Colors.white,
height: 50,
padding: EdgeInsets.all(5),
alignment: Alignment.centerRight,
child: Text(
'CANCEL',
style: TextStyle(fontSize: 20),
)),
])));
}
}
`
My expectation:
current output:
Just need to add ClipBehavior to Dialog.
import 'package:flutter/material.dart';
class CustomDialog extends StatelessWidget {
#override
Widget build(BuildContext context) {
const double padding = 1.0;
return Dialog(
backgroundColor: Colors.green,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20.0),
),
clipBehavior: Clip.antiAlias, // add clipBehavior
child: Column(mainAxisSize: MainAxisSize.min, children: [
Container(
margin: EdgeInsets.all(1),
width: double.infinity,
child: Text('title',
style: TextStyle(fontSize: 30, color: Colors.white)),
color: Colors.green,
),
Container(
color: Colors.white,
padding: EdgeInsets.all(10),
child: ListView(
shrinkWrap: true,
children: [
Container(
margin: EdgeInsets.only(left: 10, bottom: 10),
height: 30,
child: Text('one',
style: TextStyle(
fontSize: 20,
))),
Container(
margin: EdgeInsets.only(left: 10, bottom: 10),
height: 30,
child: Text('one',
style: TextStyle(
fontSize: 20,
))),
Container(
margin: EdgeInsets.only(left: 10, bottom: 10),
height: 30,
child: Text('one',
style: TextStyle(
fontSize: 20,
))),
],
),
),
Divider(
color: Colors.white,
),
Container(
color: Colors.white,
height: 50,
padding: EdgeInsets.all(5),
alignment: Alignment.centerRight,
child: Text(
'CANCEL',
style: TextStyle(fontSize: 20),
)),
]),
);
}
}
The issue was with the Container you used to wrap the other widgets, you can add specific border radius to each container to fix.
I added a demo and code to get what you wanted your output to look like:
class CustomDialog extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Dialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.0),
),
child: Container(
height: 340,
child: Column(
children: [
Container(
height: 60,
width: double.infinity,
padding: EdgeInsets.all(
15.0,
),
decoration: BoxDecoration(
color: Colors.green,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(
15.0,
),
topRight: Radius.circular(
15.0,
),
),
),
child: Text(
'Baby Names',
style: TextStyle(
fontSize: 20,
color: Colors.white,
),
),
),
...List.generate(
5,
(index) => Padding(
padding: const EdgeInsets.all(10.0),
child: Align(
alignment: Alignment.centerLeft,
child: Text(
'List Names',
style: TextStyle(
fontSize: 18,
),
),
),
),
),
Divider(
color: Colors.grey[200],
thickness: 1.5,
),
Padding(
padding: const EdgeInsets.all(10.0),
child: Align(
alignment: Alignment.centerRight,
child: Text(
'CANCEL',
style: TextStyle(
fontSize: 18,
color: Colors.green,
),
),
),
),
],
),
),
);
}
}
RESULT:
You added RoundedRectangleBorder(),
import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(
home: MyWidget(),
),
);
}
class MyWidget extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Dialog(
backgroundColor: Colors.green,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
child: Container(
padding: EdgeInsets.only(
top: 10.0,
bottom: 5,
left: 5,
right: 5,
),
margin: EdgeInsets.only(top: 5),
decoration: new BoxDecoration(
color: Colors.white,
shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(5),
boxShadow: [
BoxShadow(
color: Colors.black26,
blurRadius: 10.0,
offset: const Offset(0.0, 10.0),
),
],
),
child: Column(
mainAxisSize: MainAxisSize.min, // To make the card compact
children: <Widget>[
Text(
"Baby",
style: TextStyle(
fontSize: 24.0,
fontWeight: FontWeight.w700,
),
),
Divider(color: Colors.grey,),
SizedBox(height: 16.0),
Text(
"text",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 16.0,
),
),
SizedBox(height: 24.0),
Align(
alignment: Alignment.bottomRight,
child: FlatButton(
onPressed: () {
Navigator.of(context).pop(); // To close the dialog
},
child: Text("buttonText"),
),
),
],
),
),
);
}
}
I am new in flutter and I try to make scrollable UI.
I try to add Expanded widgets, ListViews Widgets , SingleChildScrollView widgets but didn't get the expected result.
Also, I try to wrap the stack inside Container and then inside SingleChildScrollView. But it throws error.
I tried many aspects to make my homepage scrollable. But, I got errors (Mentioned below)
I/flutter ( 6259): Another exception was thrown: RenderBox was not laid out: RenderSemanticsGestureHandler#e1279 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
I/flutter ( 6259): Another exception was thrown: RenderBox was not laid out: _RenderColoredBox#89cc6 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
I/flutter ( 6259): Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#9505f NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
I/flutter ( 6259): Another exception was thrown: 'package:flutter/src/rendering/sliver_multi_box_adaptor.dart': Failed assertion: line 549 pos 12: 'child.hasSize': is not true.
GestureDetector(
onTap: () {
FocusScope.of(context).unfocus();
new TextEditingController().clear();
},
child: Stack(
children: <Widget>[
Container(
height: 200,
child: TopBar(),
),
Container(
margin: EdgeInsets.only(top: 55),
child: Text(
"PriceTrackers",
style: TextStyle(
color: Colors.white,
fontSize: 50.0,
fontWeight: FontWeight.w900,
),
),
),
Container(
margin: EdgeInsets.fromLTRB(265, 0, 0, 0),
child: Text(
".",
style: TextStyle(
fontSize: 120,
color: Colors.white,
),
)),
ListView(
padding: EdgeInsets.fromLTRB(10, 10, 10, 0),
children: <Widget>[
Container(
margin: EdgeInsets.only(top: 200),
child: Form(
key: _formKey,
child: Column(children: <Widget>[
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Icon(Icons.store),
Text(
"Supported Store",
style: TextStyle(
fontSize: 20,
color: Colors.green,
),
),
Image.asset(
"Assets/img/amazon.png",
width: 20,
),
Image.asset(
"Assets/img/flipkart.png",
width: 20,
),
Image.asset(
"Assets/img/ajio.png",
width: 20,
),
Image.asset(
"Assets/img/snapdeal.png",
width: 20,
),
Image.asset(
"Assets/img/ss.jpg",
width: 20,
),
],
),
margin: EdgeInsets.fromLTRB(40, 10, 40, 10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.white,
// boxShadow: [
// BoxShadow(color: Colors.white, spreadRadius: 3),
// ],
),
),
// Add TextFormFields and RaisedButton here.
TextFormField(
controller: _controller,
enableInteractiveSelection: true,
textInputAction: TextInputAction.done,
decoration: InputDecoration(
border: OutlineInputBorder(
borderSide: BorderSide(color: Colors.green),
borderRadius: BorderRadius.circular(20),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.black),
borderRadius: BorderRadius.circular(20),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.blue),
borderRadius: BorderRadius.circular(20),
),
errorBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.red,
),
borderRadius: BorderRadius.circular(20),
),
hintText: "Enter Product URL",
suffixIcon: Icon(Icons.search),
),
// onFieldSubmitted: (term){
// FocusScope.of(context).unfocus();
// _controller.clear();
// },
showCursor: true,
autofocus: false,
// The validator receives the text that the user has entered.
validator: (value) {
if (value.isEmpty) {
return 'Please enter some text';
} else if (!value.contains("amazon") ||
!value.contains("flipkart") ||
!value.contains("myntra")) {
return "Please Enter Supported Store URL";
}
return null;
},
),
RaisedButton.icon(
icon: Icon(
Icons.search,
color: Colors.white,
),
color: Colors.black,
padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
elevation: 20.0,
onPressed: () async {
// Validate returns true if the form is valid, otherwise false.
if (_formKey.currentState.validate()) {
setState(() {
createAlbum(_controller.text).then((value) => {
Navigator.push(
context,
EnterExitRoute(
exitPage: HomePage(),
enterPage: LineChartSample2(
getData: value)))
});
});
Scaffold.of(context).showSnackBar(SnackBar(
content: Text(
'Processing Data',
style: TextStyle(color: Colors.white),
),
backgroundColor: Colors.green,
));
// If the form is valid, display a snackbar. In the real world,
// you'd often call a server or save the information in a database.
// Navigator.push(
// context,
// MaterialPageRoute(builder: (context) => LineChartSample2()),
// );
}
},
label: Text(
'View Price Graph',
style: TextStyle(
color: Colors.white,
),
),
),
Container(
margin: EdgeInsets.only(top: 20),
width: 380,
height: 200,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.blue[200],
blurRadius: 25.0, // soften the shadow
spreadRadius: 5.0, //extend the shadow
offset: Offset(
15.0, // Move to right 10 horizontally
15.0, // Move to bottom 10 Vertically
),
)
],
),
child: Row(
children: <Widget>[
Container(
width: 130,
height: 130,
padding: EdgeInsets.fromLTRB(5, 10, 5, 10),
child: FadeInImage(
fit: BoxFit.scaleDown,
// here `bytes` is a Uint8List containing the bytes for the in-memory image
placeholder: AssetImage("Assets/img/bag.png"),
image: NetworkImage(
'https://images-na.ssl-images-amazon.com/images/I/81j14WXbc%2BL._UL1500_.jpg'),
),
),
Expanded(
child: Container(
padding: EdgeInsets.fromLTRB(0, 20, 10, 0),
child: Column(
children: <Widget>[
Text(
"Redux Analogue Blue Dial Men’s &S... ",
maxLines: 2,
softWrap: true,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w400,
color: Colors.black),
),
Container(
margin: EdgeInsets.fromLTRB(0, 10, 0, 0),
child: Column(
children: <Widget>[
OutlineButton.icon(
onPressed: () => {},
icon: Icon(Icons.shopping_basket),
label: Text("But Now #28939")),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: <Widget>[
Text(
"Avg Price : 7,98,374",
style: TextStyle(
fontSize: 10,
fontWeight: FontWeight.w900,
),
),
Text(
"Avg Price :34,43,343",
style: TextStyle(
fontSize: 10,
fontWeight: FontWeight.w900,
),
)
],
),
Container(
margin: EdgeInsets.all(5),
),
FlatButton.icon(
icon: Icon(Icons.show_chart),
color: Colors.black,
textColor: Colors.white,
disabledColor: Colors.grey,
disabledTextColor: Colors.black,
padding: EdgeInsets.fromLTRB(
20, 5, 20, 5),
splashColor: Colors.blueAccent,
onPressed: () {
/*...*/
},
label: Text(
"Show Price Graph",
style: TextStyle(fontSize: 15.0),
),
)
],
)),
],
),
))
],
),
),
])),
),
],
),
Container(
margin: EdgeInsets.only(top: 650),
child: GridView.count(
primary: false,
padding: const EdgeInsets.all(20),
crossAxisSpacing: 10,
mainAxisSpacing: 10,
crossAxisCount: 2,
children: <Widget>[
Container(
padding: const EdgeInsets.all(8),
child: const Text("He'd have you all unravel at the"),
color: Colors.teal[100],
),
Container(
padding: const EdgeInsets.all(8),
child: const Text('Heed not the rabble'),
color: Colors.teal[200],
),
Container(
padding: const EdgeInsets.all(8),
child: const Text('Sound of screams but the'),
color: Colors.teal[300],
),
Container(
padding: const EdgeInsets.all(8),
child: const Text('Who scream'),
color: Colors.teal[400],
),
Container(
padding: const EdgeInsets.all(8),
child: const Text('Revolution is coming...'),
color: Colors.teal[500],
),
Container(
padding: const EdgeInsets.all(8),
child: const Text('Revolution, they...'),
color: Colors.teal[600],
),
],
)),
],
));
You can copy paste run full code below
Step 1: Use LayoutBuilder and ConstrainedBox
return LayoutBuilder(builder: (context, constraints) {
...
child: SingleChildScrollView(
child: ConstrainedBox(
constraints: BoxConstraints(maxHeight: double.infinity),
child: Stack(
Step 2: Change ListView to Column
Padding(
padding: EdgeInsets.fromLTRB(10, 10, 10, 0),
child: Column(
Step 3: GridView use shrinkWrap: true
working demo
full code
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
#override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
#override
Widget build(BuildContext context) {
return LayoutBuilder(builder: (context, constraints) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: GestureDetector(
onTap: () {
FocusScope.of(context).unfocus();
TextEditingController().clear();
},
child: SingleChildScrollView(
child: ConstrainedBox(
constraints: BoxConstraints(maxHeight: double.infinity),
child: Stack(
children: <Widget>[
Container(
height: 200,
child: Text("TopBar()"),
),
Container(
margin: EdgeInsets.only(top: 55),
child: Text(
"PriceTrackers",
style: TextStyle(
color: Colors.black,
fontSize: 50.0,
fontWeight: FontWeight.w900,
),
),
),
Container(
margin: EdgeInsets.fromLTRB(265, 0, 0, 0),
child: Text(
".",
style: TextStyle(
fontSize: 120,
color: Colors.white,
),
)),
Padding(
padding: EdgeInsets.fromLTRB(10, 10, 10, 0),
child: Column(
children: <Widget>[
Container(
margin: EdgeInsets.only(top: 200),
child: Form(
//key: _formKey,
child: Column(children: <Widget>[
Container(
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: <Widget>[
Icon(Icons.store),
Text(
"Supported Store",
style: TextStyle(
fontSize: 20,
color: Colors.green,
),
),
Image.network(
'https://picsum.photos/250?image=9',
width: 20,
),
Image.network(
'https://picsum.photos/250?image=10',
width: 20,
),
Image.network(
'https://picsum.photos/250?image=11',
width: 20,
),
Image.network(
'https://picsum.photos/250?image=12',
width: 20,
),
Image.network(
'https://picsum.photos/250?image=13',
width: 20,
),
],
),
margin: EdgeInsets.fromLTRB(40, 10, 40, 10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.white,
// boxShadow: [
// BoxShadow(color: Colors.white, spreadRadius: 3),
// ],
),
),
// Add TextFormFields and RaisedButton here.
TextFormField(
//controller: _controller,
enableInteractiveSelection: true,
textInputAction: TextInputAction.done,
decoration: InputDecoration(
border: OutlineInputBorder(
borderSide: BorderSide(color: Colors.green),
borderRadius: BorderRadius.circular(20),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.black),
borderRadius: BorderRadius.circular(20),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.blue),
borderRadius: BorderRadius.circular(20),
),
errorBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.red,
),
borderRadius: BorderRadius.circular(20),
),
hintText: "Enter Product URL",
suffixIcon: Icon(Icons.search),
),
// onFieldSubmitted: (term){
// FocusScope.of(context).unfocus();
// _controller.clear();
// },
showCursor: true,
autofocus: false,
// The validator receives the text that the user has entered.
validator: (value) {
if (value.isEmpty) {
return 'Please enter some text';
} else if (!value.contains("amazon") ||
!value.contains("flipkart") ||
!value.contains("myntra")) {
return "Please Enter Supported Store URL";
}
return null;
},
),
RaisedButton.icon(
icon: Icon(
Icons.search,
color: Colors.white,
),
color: Colors.black,
padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
elevation: 20.0,
onPressed: () async {
// Validate returns true if the form is valid, otherwise false.
},
label: Text(
'View Price Graph',
style: TextStyle(
color: Colors.white,
),
),
),
Container(
margin: EdgeInsets.only(top: 20),
width: 380,
height: 200,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.blue[200],
blurRadius: 25.0,
// soften the shadow
spreadRadius: 5.0,
//extend the shadow
offset: Offset(
15.0,
// Move to right 10 horizontally
15.0, // Move to bottom 10 Vertically
),
)
],
),
child: Row(
children: <Widget>[
Container(
width: 130,
height: 130,
padding:
EdgeInsets.fromLTRB(5, 10, 5, 10),
child: FadeInImage(
fit: BoxFit.scaleDown,
// here `bytes` is a Uint8List containing the bytes for the in-memory image
placeholder: NetworkImage(
"https://picsum.photos/250?image=9"),
image: NetworkImage(
'https://images-na.ssl-images-amazon.com/images/I/81j14WXbc%2BL._UL1500_.jpg'),
),
),
Expanded(
child: Container(
padding:
EdgeInsets.fromLTRB(0, 20, 10, 0),
child: Column(
children: <Widget>[
Text(
"Redux Analogue Blue Dial Men’s &S... ",
maxLines: 2,
softWrap: true,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w400,
color: Colors.black),
),
Container(
margin: EdgeInsets.fromLTRB(
0, 10, 0, 0),
child: Column(
children: <Widget>[
OutlineButton.icon(
onPressed: () => {},
icon: Icon(Icons
.shopping_basket),
label: Text(
"But Now #28939")),
Row(
mainAxisAlignment:
MainAxisAlignment
.spaceEvenly,
children: <Widget>[
Text(
"Avg Price : 7,98,374",
style: TextStyle(
fontSize: 10,
fontWeight:
FontWeight.w900,
),
),
Text(
"Avg Price :34,43,343",
style: TextStyle(
fontSize: 10,
fontWeight:
FontWeight.w900,
),
)
],
),
Container(
margin: EdgeInsets.all(5),
),
FlatButton.icon(
icon:
Icon(Icons.show_chart),
color: Colors.black,
textColor: Colors.white,
disabledColor: Colors.grey,
disabledTextColor:
Colors.black,
padding:
EdgeInsets.fromLTRB(
20, 5, 20, 5),
splashColor:
Colors.blueAccent,
onPressed: () {
/*...*/
},
label: Text(
"Show Price Graph",
style: TextStyle(
fontSize: 15.0),
),
)
],
)),
],
),
))
],
),
),
])),
),
],
),
),
Container(
margin: EdgeInsets.only(top: 650),
child: GridView.count(
shrinkWrap: true,
primary: false,
padding: const EdgeInsets.all(20),
crossAxisSpacing: 10,
mainAxisSpacing: 10,
crossAxisCount: 2,
children: <Widget>[
Container(
padding: const EdgeInsets.all(8),
child: const Text(
"He'd have you all unravel at the"),
color: Colors.teal[100],
),
Container(
padding: const EdgeInsets.all(8),
child: const Text('Heed not the rabble'),
color: Colors.teal[200],
),
Container(
padding: const EdgeInsets.all(8),
child: const Text('Sound of screams but the'),
color: Colors.teal[300],
),
Container(
padding: const EdgeInsets.all(8),
child: const Text('Who scream'),
color: Colors.teal[400],
),
Container(
padding: const EdgeInsets.all(8),
child: const Text('Revolution is coming...'),
color: Colors.teal[500],
),
Container(
padding: const EdgeInsets.all(8),
child: const Text('Revolution, they...'),
color: Colors.teal[600],
),
],
)),
],
),
),
)),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
),
);
});
}
}
You need to remove height from container.
SingleChildScrollView(
child: Container(
child: Stack(
children: <Widget>[
])))