Flutter show icon overlap with column - flutter

I need to show the avatar and a column in a row which look like overlapping each other.
Something like this
I have done with the left side but don't know how can I add this type of icon which seems like overlapping with my column here is my code
Widget build(BuildContext context) {
double statusBarHeight = MediaQuery.of(context).padding.top;
double width = MediaQuery.of(context).size.width;
double height = MediaQuery.of(context).size.height;
return Scaffold(
body: Container(
width: double.infinity,
color: Color(0xff1b4881),
child: Column(
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
SizedBox(
height: height * 0.05,
),
Container(
padding: EdgeInsets.only(left: 10),
alignment: Alignment.topLeft,
child: new SizedBox(
child: FloatingActionButton(
backgroundColor: Colors.white,
child: Icon(Icons.arrow_back_ios, color: Color(0xff1b4881),),
onPressed: () {
Navigator.pop(context);
},
))),
SizedBox(
height: height * 0.03,
),
Container(
padding: EdgeInsets.only(right: 20),
color: Colors.white,
width: width * 0.7,
height: height * 0.1,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Rtn.XYZZ',
style: TextStyle(fontSize: 22),
),
Text(
'President',
style: TextStyle(fontSize: 22),
)
],
),
),
],
),
],
)),
);
}

Try this
Container(
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 20),
child: Stack(
alignment: Alignment.topCenter,
children: <Widget>[
Container(
height: 60,
width: MediaQuery.of(context).size.width,
margin: const EdgeInsets.only(top: 20, bottom: 20, right: 10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text('AskNilesh'),
Text('AskNilesh'),
],
),
decoration: BoxDecoration(
color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(20.0))),
),
Positioned(
right: 0,
top: 0,
child: ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(50.0)),
child: Container(
height: 100,
width: 100,
decoration: BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.all(Radius.circular(50.0))),
),
),
)
],
),
)
OUTPUT

you can the Stack Widget to overlap widgets:
Stack(
children: <Widget>[
Column(
children: <Widget>[
Text('Rtn.xxx'),
Text('secretory'),
],
),
Positioned(
left: 10,
right: 10,
top: 10,
bottom: 10,
child: CircleAvatar(
child: Image.asset('blablabla.png'),
),
)
],
)
then play with values of top, left, right, button in the Positioned widget to align the item exactly as you want it.

Related

How can I make a Flutter Scaffold scroll to not have TextFields covered

I have a somewhat complicated widget tree and can't figure this out. I've tried wrapping the Scaffold body in a SingleChildScrollView but for some reason it just makes the Container shrink and does not scroll. Here is the build function code:
return Stack(
children: [
Scaffold(
resizeToAvoidBottomInset: false,
body: Stack(
children: [
background(),
Padding(
padding: const EdgeInsets.only(top: 55),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset('assets/logo.png', height: 100),
const SizedBox(width: 5),
const Text('GLOBE',
style: TextStyle(
fontSize: 40,
fontWeight: FontWeight.bold,
color: Color(0xFF7FCCDC)))
],
),
),
Padding(
padding: const EdgeInsets.only(
top: 175, left: 35, right: 35, bottom: 50),
child: Container(
decoration: BoxDecoration(
color: const Color(0xFFFCFBF4).withOpacity(0.5),
borderRadius: BorderRadius.circular(20),
),
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
const SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
Text('Welcome!',
style: TextStyle(
fontSize: 30, color: Color(0xFF6B6FAB))),
],
),
loginForm()
],
),
),
),
],
),
),
if (_isLoading)
const Opacity(
opacity: 0.8,
child: ModalBarrier(dismissible: false, color: Colors.black),
),
if (_isLoading)
const Center(
child: CircularProgressIndicator(color: Color(0xFFb1bbd8)),
),
],
);
Return a scaffold and add a sized box of height and width same as device. As a body use stack. Then in children add the next stack.
return Scaffold(
resizeToAvoidBottomInset: false,
body: SizedBox(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
child: Stack(
children: [
background(),
SizedBox(
height:MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
child: SingleChildScrollView(
child: Column(
mainAxisSize : MainAxisSize.min,
children:[
Padding(
padding: const EdgeInsets.only(top: 55),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset('assets/logo.png', height: 100),
const SizedBox(width: 5),
const Text('GLOBE',
style: TextStyle(
fontSize: 40,
fontWeight: FontWeight.bold,
color: Color(0xFF7FCCDC)))
],
),
),
Padding(
padding: const EdgeInsets.only(
top: 100, left: 35, right: 35, bottom: 50),
child: Container(
decoration: BoxDecoration(
color: const Color(0xFFFCFBF4).withOpacity(0.5),
borderRadius: BorderRadius.circular(20),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
Text('Welcome!',
style: TextStyle(
fontSize: 30, color: Color(0xFF6B6FAB))),
],
),
loginForm()
],
),
),
),
]
)
)
if (_isLoading)
const Opacity(
opacity: 0.8,
child: ModalBarrier(dismissible: false, color: Colors.black),
),
if (_isLoading)
const Center(
child: CircularProgressIndicator(color: Color(0xFFb1bbd8)),
),
]
)
)
)
TextField has a property called scrollPadding.
scrollPadding: EdgeInsets.only(bottom: 40)
By default it is set to EdgeInsets.all(20.0)

Flutter: Positioned inside stack cuts off my widget

I am using stuck to overlapping my widget. this is my widget:
#override
Widget build(BuildContext context) {
return SingleChildScrollView(
controller: controller,
child: SizedBox(
height: double.maxFinite,
child: Column(
children: [
Container(
width: double.maxFinite,
constraints: BoxConstraints(maxHeight: 200),
color: Colors.blue,
child: Stack(
// clipBehavior: Clip.none,
children: [
Positioned(
bottom: -25,
left: 0,
right: 0,
child: Container(
width: 60,
height: 60,
padding: EdgeInsets.all(8),
color: Colors.blue,
child: CircleAvatar(
backgroundColor: Colors.white,
child: Icon(Icons.mail)),
),
),
],
),
)
],
),
),
);
}
this is an image :
as you can see my image was cut off.I added clipBehavior: Clip.none, to stack but it just increase the height of stack :
I want the button to come down from the blue container. Like all the pictures I took, without cut off.
#override
Widget build(BuildContext context) {
return SingleChildScrollView(
controller: controller,
child: SizedBox(
height: double.maxFinite,
child: Column(
children: [
Container(
width: double.maxFinite,
constraints: BoxConstraints(maxHeight: 200),
color: Colors.blue,
child: Stack(
// clipBehavior: Clip.none,
children: [
Container(
width: MediaQuery of(context).size.width,
height : 300,
margin : EdgeInsets.only(bottom: 50),
color: Colors.blue,
),
Positioned(
bottom : 0,
left:0, right:0,
child: Container (height : 300, width: MediaQuery.of(context).width,
child: CircleAvatar())
)
],
),
)
],
),
),
);
}
I fix this issue :
#override
Widget build(BuildContext context) {
return SingleChildScrollView(
controller: controller,
child: SizedBox(
height: double.maxFinite,
child: Column(
children: [
Container(
width: double.maxFinite,
height: 200,
color: Colors.blue,
child: Stack(
clipBehavior: Clip.none,
children: [
Align(
alignment: Alignment.center,
child: Container(
child: Column(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("test",
style:
TextStyle(fontSize: 25, color: Colors.white)),
],
),
),
),
Positioned(
bottom: -25,
left: 0,
right: 0,
child: CircleAvatar(
backgroundColor: Colors.white,
child: Icon(Icons.campaign)),
),
],
),
)
],
),
),
);
}
}
result:

bottom overflowed by 1000 pixels

I'm trying to make a header (picture with a card half inside pic and half outside and it worked in a stack.
but I'm in trouble when I have to make many containers below so when adding below the stack im having bottom overflowed.
I removed from code the unnecessary code so u can test it in your editor for help :)
any one can help me??
import 'package:flutter/material.dart';
class ServiceDetails extends StatefulWidget {
#override
_ServiceDetails createState() => _ServiceDetails();
}
class _ServiceDetails extends State<ServiceDetails> {
#override
Widget build(BuildContext context) {
var h = MediaQuery.of(context).size.height;
var w = MediaQuery.of(context).size.width;
return Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
child: Stack(
children:[
Column(
children:[
Container(
height: h * .4,
width: w,
// color: Colors.grey[50],
child: Image.asset('images/hairdresser1.jpg', fit: BoxFit.fitWidth,)
),
new Container(
height: h * .0,
color: Colors.grey[50],
)
]
),
Container(
alignment: Alignment.topCenter,
padding: new EdgeInsets.only(
top: MediaQuery.of(context).size.height * .33,
right: 15.0,
left: 15.0
),
child: Container(
height: 150,
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.0),
),
elevation: 0.0,
color: Colors.white,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding: EdgeInsets.only(left: 20, bottom: 5, top: 20),
child: Text(
"Hair Dresser",
style: new TextStyle(
color: Colors.black,
fontSize: 20,
fontWeight: FontWeight.bold
)
)
),
Container(
padding: EdgeInsets.only(left: 20, bottom: 5),
child: Text(
"With our proffisional barbers, new experience is guaranteed",
style: new TextStyle(
color: Colors.grey,
fontSize: 13
)
)
),
],
)
)
)
),
],
)
),
Container(
padding: EdgeInsets.all(15),
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.0),
),
elevation: 0.0,
color: Colors.white,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding: EdgeInsets.only(left: 20, bottom: 5, top: 20),
child: Text(
"Frequently Used",
style: new TextStyle(
color: Colors.black,
fontSize: 15,
fontWeight: FontWeight.bold
)
)
),
Divider(),
Container(
padding: EdgeInsets.zero,
height: 210,
width: w,
)
],
)
)
),
Container(
padding: EdgeInsets.all(15),
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.0),
),
elevation: 0.0,
color: Colors.white,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding: EdgeInsets.only(left: 20, bottom: 5, top: 20),
child: Text(
"Frequently Used",
style: new TextStyle(
color: Colors.black,
fontSize: 15,
fontWeight: FontWeight.bold
)
)
),
Divider(),
Container(
padding: EdgeInsets.zero,
height: 210,
width: w,
)
],
)
)
),
)
]
)
);
}
}
Wrap your column with SingleChildScrollView and widget tree be like
Scaffold
-SingleChildScrollView
- Column
Use SingleChildScrollView To scroll the page.
SingleChildScrollView requires a scroll controller to change your code as follows
class _ServiceDetails extends State<ServiceDetails> {
ScrollController scrollController = ScrollController();
#override
Widget build(BuildContext context) {
var h = MediaQuery.of(context).size.height;
var w = MediaQuery.of(context).size.width;
return Scaffold(
body: Scrollbar(
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
controller: scrollController,
child: Column(
------------------------------
),
),
),
);
}
}

How to clamp scroll view and container at the end

I have a single child scroll view inside of stack trying to clamp the bottom container and the scrollview at the end how would be able to achieve that? the scroll view doesn't end before the container at the bottom. Tried changing the physics to clamping but still not working?What am i missing here?
return Stack(
children: [
SingleChildScrollView(
physics: AlwaysScrollableScrollPhysics(),
child: Column(
children: [
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: BiggerBuildProduct(
onPressed: null,
bigImageUrl: product.image[0],
price: product.price.toString(),
name: product.name,
description: product.description,
),
),
Column(
children: <Widget>[
SizedBox(
height: 10,
),
Container(
width: double.infinity,
child: Column(
children: <Widget>[
Container(
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(
color: Colors.grey[200], width: 2.0),
),
height: 50,
child: Padding(
padding:
const EdgeInsets.only(left: 8.0, right: 8.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
'Product Details',
style: TextStyle(fontSize: 18),
),
CopyButton(
isIOS: isIOS,
product: product,
)
],
),
),
),
Container(
color: Colors.white,
width: MediaQuery.of(context).size.width,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(product.description),
),
),
],
),
),
SizedBox(
height: 10,
),
BuildServiceItems()
],
),
],
)),
Align(
alignment: Alignment.bottomCenter,
child: Container(
padding: EdgeInsets.only(bottom: 20),
height: 100,
color: Colors.white,
width: MediaQuery.of(context).size.width,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
AppButton(
padding: EdgeInsets.all(0),
isIOS: isIOS,
height: 60,
width: MediaQuery.of(context).size.width * 0.45,
icon: FrinoIcons.f_share,
buttonType: ButtonType.Resell,
text: 'Share Product',
onPressed: () => onImageDownLoad(product),
),
AppButton(
padding: EdgeInsets.all(0),
height: 60,
width: MediaQuery.of(context).size.width * 0.45,
isIOS: isIOS,
icon: FrinoIcons.f_cart_add,
buttonType: ButtonType.DarkRed,
text: 'Add To Cart',
onPressed: () => onAddCartPressed(context, product, isIOS),
),
],
),
),
),
],
);
}

Dismissible without border radius

I'm creating a Dismissible with Flutter and my Container child have a border radius of 40.0 and when I long press (Flat Button animation) it shows that is rounded BUT when I drag it's not, like you can see in the image bellow.
Is this possible?
Container(
margin: const EdgeInsets.only(bottom: 0.0, top: 15.0, right: 10.0, left: 10.0),
child: FlatButton(
//color: Colors.grey.withOpacity(0.1),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(40.0),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Stack(
children: <Widget>[
CircleAvatar(
child: ClipOval(
child: (document['photoUrl'] != null)
? CachedNetworkImage(
placeholder: (context, url) => Icon(
Icons.face,
size: 60.0,
color: Colors.white,
),
imageUrl: document['photoUrl'],
width: 60.0,
height: 60.0,
fit: BoxFit.cover,
fadeInDuration: Duration(milliseconds: 100),
)
: Image.asset(
"assets/images/placeholder_small_avatar.jpg",
fit: BoxFit.cover,
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
),
),
radius: 30.0,
backgroundColor: Colors.grey[400],
),
],
),
Expanded(
child: Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text(
'${document['nickname']}',
style: TextStyle(
color: Colors.black87,
fontWeight: FontWeight.bold,
fontSize: 16.0,
),
),
],
),
alignment: Alignment.centerLeft,
margin: const EdgeInsets.only(left: 5.0, bottom: 5.0),
),
Container(
child: MessageTile(ctx: context, peerId: document['userId'], id: id),
margin: const EdgeInsets.only(left: 5.0, bottom: 5.0),
)
],
),
margin: const EdgeInsets.only(
left: 10.0,
),
),
),
],
),
onPressed: () {
//bla bla
},
padding: const EdgeInsets.fromLTRB(8.0, 7.0, 8.0, 7.0),
),
),
You can try with Flutter Slidable Package
or else try this method too
ClipRRect(
borderRadius: BorderRadius.circular(12.0),
child: Dismissible(
child: YourWidget();
)
)