Flutter carousel slider image over image partially - flutter

i wanted to create a carousel slider with an image over an image. I have achieved to overlay a second image over the first with a stack, but also with positioned widget, but the problem is the overflow is not visible but i want to see it. As you can see on the image below the rounded circle overflows but the overflow is not visible.
img1
class _HelpPageState extends State<HelpPage> {
final List<Color> colorList = [
Colors.blue,
Colors.red,
Colors.green,
Colors.deepPurple,
Colors.yellow,
];
#override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Stack(children: [
ListView(
// crossAxisAlignment: CrossAxisAlignment.start,
children: [
CarouselSlider(
options: CarouselOptions(
//height: 270,
autoPlay: true,
enlargeCenterPage: true,
viewportFraction: 1.0,
aspectRatio: 16 / 9,
autoPlayInterval: Duration(seconds: 3),
autoPlayAnimationDuration: Duration(milliseconds: 800),
autoPlayCurve: Curves.linearToEaseOut),
items: colorList
.map((color) => Container(
height: 230,
width: 500,
decoration: BoxDecoration(
borderRadius: const BorderRadius.only(
bottomLeft: Radius.circular(60),
bottomRight: Radius.circular(60),
),
color: color
),
child: Stack(
fit: StackFit.expand,
alignment: Alignment.bottomCenter,
overflow: Overflow.visible,
children: [
new Positioned(
bottom: -20,
child: Container(
constraints: new BoxConstraints(
maxHeight: 50.0, maxWidth: 50.0),
decoration: new BoxDecoration(
boxShadow: [
BoxShadow(
color: Color(0xFFdedede),
offset: Offset(2, 2)),
],
color: Colors.white,
shape: BoxShape.circle,
),
child: GestureDetector(
onTap: () => print("ha"),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Image.asset("icons/360.png",
scale: 0.5),
),
),
),
),
],
),
))
.toList(),
)
])
])),
);
/*return MaterialApp(
title: 'Help Page',
theme: new ThemeData(primarySwatch: Colors.red),
home: Scaffold(
appBar: AppBar(
centerTitle: true,
title: const Text('Help'),
),
// ignore: unnecessary_new
body: Container(
height: 250,
width: 500,
decoration: BoxDecoration(
color: Colors.lightGreen,
boxShadow: [
BoxShadow(
color: Colors.green.withOpacity(0.2),
blurRadius: 15,
offset: const Offset(0, 5),
),
],
borderRadius: const BorderRadius.only(
bottomLeft: Radius.circular(60),
bottomRight: Radius.circular(60),
),
image: DecorationImage(
image: AssetImage("images/cityliner2.jpg"),
fit: BoxFit.fitWidth,
),
),
child: Stack(
alignment: Alignment.bottomCenter,
overflow: Overflow.visible,
children: [
new Positioned(
bottom: -30,
child: Container(
constraints:
new BoxConstraints(maxHeight: 50.0, maxWidth: 50.0),
decoration: new BoxDecoration(
boxShadow: [
BoxShadow(color: Color(0xFFdedede), offset: Offset(2, 2)),
],
color: Colors.white,
shape: BoxShape.circle,
),
child: GestureDetector(
onTap: () => print("ha"),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Image.asset("icons/360.png", scale: 0.5),
),
),
),
),
],
),
),
drawer: MainDrawer(),
),
);*/
}
}
The code which is commented will result in the right behaviour but without carousel. As soon i try it with a listview following a carouselslider i get the overflow issue as above. I also tried adding "overflow: overflow.visible" but as it is depreciated there is no effect visible.
Anyone out there who can help me please.
img2

use clipbehaviour instead
clipBehaviour=Clip.none

Related

while bool variable is true I want to display CurcularProgressIndicator() for some duration, but its not showing in flutter

//This is the Class of one of my app page (MainPage)
It has showindicator() function which is turning _isloader into true for 10 seconds.
class MainPage extends StatefulWidget {
MainPage({Key? key}) : super(key: key);
#override
State<MainPage> createState() => _MainPageState();
}
class _MainPageState extends State<MainPage> {
bool _isloader = false;
Future<void> showindicator() async {
_isloader = true;
print("_isloader before $_isloader");
await Future.delayed(Duration(seconds: 10));
print("_isloader after$_isloader");
_isloader = false;
Get.to(PersonalAssessment());
print("_isloader afteroperation$_isloader");
}
//This the Main Widget Build function
#override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: MyColors.backgrey,
body: ListView(
children: [
Stack(
children: [
Center(
child: Container(
margin: EdgeInsets.only(
left: 20,
right: 20,
top: 20,
),
child: GlowGlass(
Customheight: 200,
Customwidth: double.maxFinite,
Firstcolor: Colors.black.withOpacity(.8),
Secondcolor: MyColors.Primarypurple.withOpacity(.4),
),
),
),
Center(
child: Container(
height: 200,
width: 250,
margin: EdgeInsets.only(
left: 20,
right: 20,
top: 20,
),
child: CarouselSlider(
items: Appconstants.mainimages
.map(
(e) => Container(
height: 200,
width: double.maxFinite,
decoration: BoxDecoration(
// color: MyColors.Primarypurple,
image: DecorationImage(
fit: BoxFit.cover,
image: AssetImage(
e,
),
),
),
),
)
.toList(),
options: CarouselOptions(
scrollDirection: Axis.vertical,
autoPlay: true,
aspectRatio: 16 / 9,
viewportFraction: 1,
enlargeCenterPage: true,
)),
),
),
Center(
child: Container(
margin: EdgeInsets.only(
top: 230,
left: 10,
right: 10,
),
child: ClipRRect(
borderRadius: BorderRadius.circular(30),
child: Container(
height: 400,
width: 400,
color: Colors.white,
child: Column(
children: [
SizedBox(height: 20),
//here I wrapped Widgets into GestureDetector, so when I tap
showindicator() runs _isloader turn to true for 10 seconds and for 10 seconds CircularProgressIndicator() displays on screen but unfortunately its not showing on screen although showindicator() works perfectly.
GestureDetector(
onTap: () {
showindicator();
Center(child:
CircularProgressIndicator());
},
child: Column(
children: [
Container(
height: 200,
width: 360,
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.black54,
blurRadius: 10,
)
],
color: MyColors.backgrey,
borderRadius: BorderRadius.circular(20),
),
child: Row(
children: [
Container(
margin: EdgeInsets.only(left: 10),
height: 170,
width: 150,
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: MyColors.Primarypurple,
blurRadius: 10,
)
],
// color: Colors.blue,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30),
bottomLeft: Radius.circular(30),
bottomRight: Radius.circular(30),
topRight: Radius.circular(30),
),
image: DecorationImage(
fit: BoxFit.cover,
image: AssetImage(
"lib/Assets/images/dekstop.PNG"),
),
),
),
],
),
),
],
),
),
],
),
),
),
)),
],
),
],
),
);
}
}
You can wrap Your CircularProgressIndicator inside Visiblity Widget!
GestureDetector(
onTap: () {
showindicator();
},
child: Column(
children: [
Container(
height: 200,
width: 200,
child: Visibility(
visible: _isloader,
child: CircularProgressIndicator(),
),
),
// Other widgets here...
],
),
)

Flutter how to create circular border around icon and align an image top of the circular border

I am trying to use the below code to create a circular border around an image and align an icon on top of the circular border. What I am looking at is as the image below:
And my code is as below but it didn't work out perfectly:
Stack(
children: [
CircleAvatar(
radius: 60,
backgroundColor: Colors.white,
child: Container(
padding: EdgeInsets.all(2),
child: CircleAvatar(
radius: 70,
backgroundImage: AssetImage('assets/person_icon.png'),
backgroundColor: Colors.white,
//
)),
),
Positioned(
bottom: 100,
right: 50,
child: InkWell(
onTap: () {},
child: Container(
child: Padding(
padding: const EdgeInsets.all(2.0),
child: Icon(Icons.add_a_photo, color: colorBlue),
),
decoration: BoxDecoration(
border: Border.all(
width: 3,
color: Colors.white,
),
borderRadius: BorderRadius.all(
Radius.circular(
50,
),
),
color: Colors.white,
boxShadow: [
BoxShadow(
offset: Offset(2, 4),
color: Colors.black.withOpacity(
0.3,
),
blurRadius: 3,
),
]),
),
)),
],
),
As you can above I am trying to use stack to lay each widget on top of each other but couldn't achieve that. I don't if anyone can help out where I missed it or give me a good idea of how to come about this.
Thanks in advance.
Default clipBehavior on Stack is hardEdge.
Use clipBehavior: Clip.none on Stack.
And to have circle shape
use customBorder: CircleBorder(), on InkWell.
use shape: BoxShape.circle instead of circular radius on container.
For better alignment use
Positioned(
top: -12,//half of icon size
left: 0,
right: 0,
Also better providing size on Stack like here.
/// fixing top widget size
SizedBox.square(
dimension: squareSize,
child: Stack(
clipBehavior: Clip.none,
children: [
Positioned.fill(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
clipBehavior: Clip.hardEdge,
decoration: const ShapeDecoration(
shape: CircleBorder(),
),
child: Image.asset(
'assets/images/image01.png',
fit: BoxFit.cover,
),
),
),
),
///background circle, you also do it on image widget
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(width: 5, color: Colors.green),
),
),
Positioned(
top: -12, // half of icon size
left: 0,
right: 0,
child: InkWell(
onTap: () {},
customBorder: const CircleBorder(),
child: Container(
width: 24 + 12, //icon size+padding
height: 24 + 12,
alignment: Alignment.center,
decoration: const ShapeDecoration(
shape: CircleBorder(),
color: Colors.green,
),
child: Icon(
Icons.add_a_photo,
color: Colors.white,
),
),
),
),
],
),
)
Play with sizes and decoration
Just add to the Stack Widget the Property clipBehavior: Clip.none,.
The clipBehavior will befine how to handle the Clip of the Stack Widget. Standard is hardEdge and cuts your icon off.
So your finished working Code is
import 'package:flutter/material.dart';
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Stack(
clipBehavior: Clip.none,
children: [
CircleAvatar(
radius: 60,
backgroundColor: Colors.white,
child: Container(
padding: EdgeInsets.all(2),
child: CircleAvatar(
radius: 70,
backgroundImage: AssetImage('assets/person_icon.png'),
backgroundColor: Colors.white,
//
),
),
),
Positioned(
bottom: 100,
right: 50,
child: InkWell(
onTap: () {},
child: Container(
child: Padding(
padding: const EdgeInsets.all(2.0),
child: Icon(Icons.add_a_photo, color: Colors.blue),
),
decoration: BoxDecoration(
border: Border.all(
width: 3,
color: Colors.white,
),
borderRadius: BorderRadius.all(
Radius.circular(
50,
),
),
color: Colors.white,
boxShadow: [
BoxShadow(
offset: Offset(2, 4),
color: Colors.black.withOpacity(
0.3,
),
blurRadius: 3,
),
],
),
),
),
),
],
),
),
);
}
}
void main() {
runApp(
const MaterialApp(
home: MyApp(),
),
);
}
Try below code
Stack(
children: <Widget>[
Padding(
padding: EdgeInsets.only(top: 25),
child: Container(
padding: EdgeInsets.all(8),
height: 270,
width: 270,
decoration: BoxDecoration(
color: Colors.green,
shape: BoxShape.circle,
),
child: Container(
padding: EdgeInsets.all(8),
decoration: BoxDecoration(
color: Colors.white,
shape: BoxShape.circle,
),
child: ClipOval(
child: Container(
height: 250,
width: 250,
child: Image.network(
'https://miro.medium.com/max/1400/1*-6WdIcd88w3pfphHOYln3Q.png',
fit: BoxFit.cover,
),
),
),
),
),
),
Positioned(
top: 0,
left: .0,
right: .0,
child: Center(
child: CircleAvatar(
backgroundColor: Colors.green,
radius: 30.0,
child: Icon(
Icons.check,
color: Colors.white,
size: 40,
),
),
),
)
],
),
Result Screen->
user this below code to achieve
Center(
child: Stack(
children: [
Container(
height: 200,
child: CircleAvatar(
radius: 75,
backgroundColor: Colors.green,
child: CircleAvatar(
radius: 70,
backgroundColor: Colors.white,
child: Container(
padding: EdgeInsets.all(2),
child: const CircleAvatar(
radius: 60,
backgroundImage: NetworkImage("https://helostatus.com/wp-content/uploads/2021/09/pic-for-WhatsApp-HD.jpg"),
backgroundColor: Colors.white,
//
)),
),
),
),
Positioned(
left: 16,
right: 16,
top: 8,
child: InkWell(
onTap: () {},
child: const CircleAvatar(
backgroundColor: Colors.green,
radius: 16,
child: Icon(
Icons.check,
color: Colors.white,
),
)),
),
],
),
)[enter image description here][1]
Thanks all for the contribution but here is what works perfectly for what I'm looking at. I added clipBehavior and set Clip to noneclipBehavior: Clip.none, added ClipOval in a Container and set it margin and padding respectively to give the space between the green circular border and the profile image. I also, added another Container inside my ClipOval so as to add my image as a child to it. Find below my final code:
Center(
child: Stack(
clipBehavior: Clip.none,
children: [
CircleAvatar(
radius: 60,
backgroundColor: colorGreen,
child:Container(
padding: EdgeInsets.all(4),
margin: EdgeInsets.all(3),
decoration: BoxDecoration(
color: Colors.white,
shape: BoxShape.circle,
),
child: ClipOval(
child: Container(
height: 250,
width: 250,
child: Image.network(
'my image link',
fit: BoxFit.cover,
),
),
)
)),
Positioned(
bottom: 100,
right: 45,
child: InkWell(
onTap: () {},
child: Center(
child: CircleAvatar(
backgroundColor: colorGreen,
radius: 15.0,
child: Icon(
Icons.check,
color: Colors.white,
size: 25,
),
),
),
),
),
],
),
),

Flutter Stack is not Getting Full Height

I want to overlay container to 1st one container in Stack. But when doing, it works but when i give to height first one it just take this height and second container just stucks and didn't take full height.
I want this but "THIS IS MY TEXT" container should take full height but it won't?
But when i use fit : StackFit.expand. it does work what i want but first one got behind it.
here's my code
double topHeightPadding = MediaQuery.of(context).padding.top;
double heightForStack = (MediaQuery.of(context).size.height - 90);
return Scaffold(
body: Stack(
fit : StackFit.expand,
children: <Widget>[
Container(
height: topHeightPadding + 120,
decoration: const BoxDecoration(
color: Color(0xFF141D38),
),
child: const Center(
child: Text(
"SOMETEXT.COM",
style: TextStyle(color: Colors.white),
textScaleFactor: 1.4,
)),
),
Positioned(
top: topHeightPadding + 90,
left: 0.1,
right: 0.1,
bottom: 0,
child: Container(
width: MediaQuery.of(context).size.width,
height: heightForStack,
decoration: const BoxDecoration(
// color: Colors.red,
color: Color(0xFFFFFFFF),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(35),
topRight: Radius.circular(35)),
boxShadow: [
BoxShadow(
color: Color(0xE6808080),
spreadRadius: 5,
blurRadius: 5,
offset: Offset(0, 2),
),
],
),
child: const Center(
child: Text('THIS IS MY TEXT')
),
))
],
),
);
Any help would be Appreciated.
Answering Own Question : https://stackoverflow.com/help/self-answer
I just got how to do it by Adding one more container with height double.infinity.
Code:
double topHeightPadding = MediaQuery.of(context).padding.top;
double heightForStack = (MediaQuery.of(context).size.height - 90);
return Scaffold(
body: Stack(
// fit : StackFit.expand,
children: <Widget>[
Container(height: double.infinity,),
Container(
height: topHeightPadding + 120,
decoration: const BoxDecoration(
color: Color(0xFF141D38),
),
child: const Center(
child: Text(
"SOMETEXT.COM",
style: TextStyle(color: Colors.white),
textScaleFactor: 1.4,
)),
),
Positioned(
top: topHeightPadding + 90,
left: 0.1,
right: 0.1,
bottom: 0,
child: Container(
width: MediaQuery.of(context).size.width,
height: heightForStack,
decoration: const BoxDecoration(
// color: Colors.red,
color: Color(0xFFFFFFFF),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(35),
topRight: Radius.circular(35)),
boxShadow: [
BoxShadow(
color: Color(0xE6808080),
spreadRadius: 5,
blurRadius: 5,
offset: Offset(0, 2),
),
],
),
child: const Center(
child: Text('THIS IS MY TEXT')
),
))
],
),
);

flutter : data to go over the curve parts when I scroll

i post two images, first is looking good but when i am scrolling my data then my ui is getting messed up(second image)
I want it to go under the curve parts when I scroll.
HOW TO DO IT
This is my code
return Scaffold(
backgroundColor: appGreenColor,
appBar: new AppBar(
centerTitle: false,
backgroundColor: appGreenColor,
elevation: 0,
title: Padding(
padding: const EdgeInsets.only(left: 16.0),
child: Image.asset(
"lib/Assets/bellazIcon.png",
fit: BoxFit.fill,
height: 40,
width: 78,
),
),
actions: [
Padding(
padding: const EdgeInsets.only(right: 8.0),
child: IconButton(
icon: Image.asset(
"lib/Assets/notification1.png",
height: 22,
width: 22,
),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => NotificationList()));
}),
)
],
),
body: Container(
height: MediaQuery.of(context).size.height - 70,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30), topRight: Radius.circular(30))),
child: SingleChildScrollView(
child: Column(
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 3),
child: Column(
children: [
locationView(),
imageSlider(),
genderView(),
categories(),
isMan == true
? maleTopBranches.length == 0
? Container()
: topRatedSalons(maleTopBranches)
: topRatedSalons(femaleTopBranches),
],
),
),
offerImage(),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 2.0),
child: Column(
children: [
services(),
nearByAppointment(),
],
),
),
infoImage()
],
),
),
),
);
this image looks fine till i am not scrolling
but when i scrolling image my data comes onto that curve
This answer work for me
adding : clipBehavior: Clip.hardEdge
Container(
clipBehavior: Clip.hardEdge,
height: MediaQuery.of(context).size.height - 70,
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(topLeft: Radius.circular(30),
topRight: Radius.circular(30))),
child: ...,
),)
try to add : clipBehavior: Clip.hardEdge
Container(
clipBehavior: Clip.hardEdge,
height: MediaQuery.of(context).size.height - 70,
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(topLeft: Radius.circular(30),
topRight: Radius.circular(30))),
child: ...,
),)

How to cut through an Opacity Widget in flutter?

I want to remove opacity from the center of a container to make the picture below it to be visible.
What I want:
What I tried:
Code I Tried:
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
class AppFour extends StatefulWidget {
#override
_AppFourState createState() => _AppFourState();
}
class _AppFourState extends State<AppFour> {
String img = 'https://images.unsplash.com/photo-1513279922550-250c2129b13a?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1050&q=80';
#override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: <Widget>[
Container(
height: MediaQuery.of(context).size.height,
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage('$img'),
fit: BoxFit.cover,
),
),
),
Opacity(
opacity: 0.5,
child: Container(
color: Colors.white,
),
),
Center(
child: Container(
height: MediaQuery.of(context).size.height / 1.5,
width: MediaQuery.of(context).size.width / 1.5,
decoration: BoxDecoration(
color: Colors.transparent,
image: DecorationImage(
image: NetworkImage('$img'),
fit: BoxFit.fitHeight),
borderRadius: BorderRadius.circular(5.0),
border: Border.all(
color: Colors.white,
width: 2.0,
),
boxShadow: [
BoxShadow(
color: Colors.black,
offset: Offset(0.0, 0.0),
blurRadius: 10.0)
],
),
),
),
],
),
floatingActionButton: FloatingActionButton(
backgroundColor: Colors.grey[800],
child: Transform.rotate(
angle: 45,
child: Icon(FontAwesomeIcons.syncAlt),
),
onPressed: () {},
),
);
}
}
I've modified your code to have the effect of the image that you gave as an example:
Screenshot
Code
String img = 'https://images.unsplash.com/photo-1513279922550-250c2129b13a?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1050&q=80';
#override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: <Widget>[
Container(
height: MediaQuery.of(context).size.height,
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage('$img'),
fit: BoxFit.cover,
),
),
),
Opacity(
opacity: 0.5,
child: Container(
color: Colors.white,
),
),
Center(
child: Container(
decoration: BoxDecoration(
color: Colors.transparent,
borderRadius: BorderRadius.circular(5.0),
border: Border.all(
color: Colors.white,
width: 5.0,
),
boxShadow: [
BoxShadow(
color: Colors.black,
offset: Offset(0.0, 0.0),
blurRadius: 10.0
)
],
),
child: ClipRRect(
borderRadius: BorderRadius.circular(5.0),
child: Align(
alignment: Alignment.center,
widthFactor: 0.75,
heightFactor: 0.75,
child: Container(
decoration: BoxDecoration(
color: Colors.transparent,
image: DecorationImage(
image: NetworkImage('$img'),
fit: BoxFit.fitHeight
),
),
),
),
),
),
),
],
),
floatingActionButton: FloatingActionButton(
backgroundColor: Colors.grey[800],
child: Transform.rotate(
angle: 45,
child: Icon(FontAwesomeIcons.syncAlt),
),
onPressed: () {},
),
);
}