I am trying to achieve this layout and content using Flutter:
https://i.imgur.com/oqiZqHb.png
If I try to offset by -20 using a Positioned widget to have the sticky scroller feature of the flutter_swiper package hide on part of the screen and have the side headers on top of that to cover it I get:
I/flutter ( 6060): Another exception was thrown: A RenderFlex overflowed by Infinity pixels on the bottom.
Removing the Positioned Widget gets the part of the layout working, I might need an additional card in this example but I am struggling to get the slider to offset and have the correct swipable item proportions 141x118 on the Stack with 12 padding right and the third one slightly showing on the right but the widget starting point clips the first one as well.
https://i.imgur.com/AfjqIag.jpg
This is my code for the horizontal slider widget:
import 'package:flutter/cupertino.dart';
import '../../../theme/styles.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'dart:math';
class HorizontalIndicator extends StatefulWidget {
const HorizontalIndicator({
Key key,
}) : super(key: key);
#override
_HorizontalIndicatorState createState() => _HorizontalIndicatorState();
}
class _HorizontalIndicatorState extends State<HorizontalIndicator> {
#override
Widget build(BuildContext context) {
var rnd = new Random();
var next = rnd.nextInt(10) * 1;
double screenWidth = MediaQuery.of(context).size.width;
return Container(
height: 120,
padding: EdgeInsets.only(top: 0),
width: screenWidth,
child: Stack(
overflow: Overflow.visible,
fit: StackFit.expand,
children: <Widget>[
Container(
child: new Swiper(
itemBuilder: (BuildContext context, int index) {
return Container(
margin: EdgeInsets.symmetric(vertical: 6),
decoration: new BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(26)),
boxShadow: [
BoxShadow(
color: ThemeColor.shadowColor,
blurRadius:
3.0,
spreadRadius:
0,
)
],
),
child: Padding(
padding: const EdgeInsets.only(right: 12),
child: ClipRRect(
borderRadius: BorderRadius.circular(26),
child: Image.network(
"https://picsum.photos/150/120?" +
"$index" +
"$next",
fit: BoxFit.cover,
),
),
),
);
},
itemCount: 10,
viewportFraction: 0.43,
scale: 1,
itemWidth: 150,
itemHeight: 120,
layout: SwiperLayout.DEFAULT)),
]),
);
}
}
This is how I am positioning it:
...
Stack(
alignment: AlignmentDirectional.topStart,
fit: StackFit.loose,
overflow: Overflow.visible,
children: [
ListView(children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 85, left: 50),
child: Column(
children: <Widget>[
HorizontalIndicator(),
HorizontalIndicator(),
HorizontalIndicator(),
HorizontalIndicator(),
],
),
),
]),
//ProgressBarLarge2(),
],
),
...
I finally got this layout to work.
Here is how I positioned the items:
Stack(
alignment: AlignmentDirectional.topStart,
fit: StackFit.loose,
children: [
ListView(physics: ClampingScrollPhysics(), children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 80, left: 0),
child: Column(
children: <Widget>[
HorizontalIndicator(),
HorizontalIndicator(),
HorizontalIndicator(),
],
),
),
]),
ProgressBarLarge(
context, ThemeColor.primaryColor, 0.5, 48, 11, "Done", "Pending"),
],
),
This is how the horizontal widget was structured (sorry for the long code!).
I just used Stack and Positioned.fill widget with a -100 right value and tweaked the viewportFraction values:
Container(
height: 124,
padding: EdgeInsets.only(top: 0),
child: Stack(alignment: Alignment.centerLeft, children: <Widget>[
Positioned.fill(
left: 47,
right: -100,
child: Container(
child: new Swiper(
itemBuilder: (BuildContext context, move) {
return Container(
padding: EdgeInsets.symmetric(vertical: 0),
decoration: new BoxDecoration(
borderRadius:
BorderRadius.all(Radius.circular(26)),
boxShadow: [
BoxShadow(
color: ThemeColor.shadowColor.withOpacity(0),
offset: Offset(0, 2),
blurRadius:
87.0, // has the effect of softening the shadow
spreadRadius:
0, // has the effect of extending the shadow
)
],
),
child: Padding(
padding: const EdgeInsets.all(0),
child: Container(
margin: EdgeInsets.all(5),
child: MaterialButton(
elevation: 0,
highlightElevation: 2,
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(26.0)),
padding: EdgeInsets.fromLTRB(0, 0.0, 0, 0.0),
color: Colors.grey.shade800,
onPressed: () {
Navigator.push(
context,
CupertinoPageRoute(
builder: (context) => SeatsPage()),
);
},
child: Container(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
mainAxisAlignment:
MainAxisAlignment.center,
children: <Widget>[
Padding(
padding: const EdgeInsets.all(0),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
left: 24,
top: 12,
right: 24),
child: FittedBox(
fit: BoxFit.scaleDown,
child: Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: <Widget>[
Padding(
padding:
const EdgeInsets
.only(
top: 0,
right: 0),
child: Opacity(
opacity: 0.90,
child: Text(
"84",
style: ThemeText
.cardHeaderNumber,
textAlign:
TextAlign.left,
),
),
),
// Icon(
// Icons.more_vert,
// color: Colors.grey.withAlpha(0), // More
// ),
],
),
),
),
Padding(
padding:
const EdgeInsets.fromLTRB(
24, 2, 16, 2),
child: Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: <Widget>[
Opacity(
opacity: 0.50,
child: Text(
"Available",
style: ThemeText
.cardText,
),
),
Icon(
Icons
.fiber_smart_record,
color: ThemeColor
.primaryColor,
),
],
))
],
),
),
],
),
),
),
),
));
},
itemCount: 4,
viewportFraction: viewportFraction,
scale: 1,
itemWidth: 140,
itemHeight: 120,
layout: SwiperLayout.DEFAULT)),
),
]),
),
Related
A design like I want:
This is the current design:
Hello. How to change the position of the button and make the button design like the picture I show. I have tried to make it myself but still failed to get the design as in the picture I showed. I am new to flutter. Please guide me and hope someone is willing to help me.
This is my current code:
Container(
padding: const EdgeInsets.symmetric(horizontal: 150),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
SizedBox(height: 35),
Container(
margin: EdgeInsets.fromLTRB(10, 0, 10, 10),
padding: EdgeInsets.all(15),
decoration: BoxDecoration(
border: Border.all(
color: Colors.transparent,
width: 1.0,
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expanded(
flex: 1,
child: Center(
child: FutureBuilder(
future:
_getSignedURL(widget.patientProfile.avatar),
builder: (BuildContext context,
AsyncSnapshot snapshot) {
if (snapshot.data == null) {
return Container(
color: Colors.white,
child: Container(
width: 200,
height: 200,
decoration: BoxDecoration(
color:
Color.fromRGBO(255, 255, 255, 0.3),
border: Border.all(
color: Colors.black12,
width: 1.0,
),
borderRadius: BorderRadius.all(
Radius.circular(200.0)),
),
),
);
} else {
return CircleAvatar(
radius: 100,
backgroundImage:
NetworkImage(snapshot.data),
);
}
},
),
),
),
],
),
),
Container(
margin: EdgeInsets.fromLTRB(10, 0, 10, 10),
padding: EdgeInsets.all(15),
decoration: BoxDecoration(
border: Border.all(
color: Colors.transparent,
width: 1.0,
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Expanded(
child: Padding(
padding: EdgeInsets.only(top: 10),
child: Align(
alignment: Alignment.centerRight,
child: ButtonTheme(
minWidth: 100.0,
height: 38.0,
buttonColor: mainColor,
// ignore: deprecated_member_use
child: RaisedButton(
padding: EdgeInsets.fromLTRB(30, 0, 30, 0),
textColor: Colors.white,
color: mainColor,
child: Text('Save'),
onPressed: () => _updatePatientProfile(),
),
),
)),
),
],
),
),
],
),
),
Play with Stack widget, there are others way of doing this.
class B extends StatefulWidget {
B({Key? key}) : super(key: key);
#override
State<B> createState() => _BState();
}
class _BState extends State<B> {
Color mainColor = Colors.blue;
#override
Widget build(BuildContext context) {
return Scaffold(
body: LayoutBuilder(
builder: (context, constraints) => Column(
children: [
Column(
children: [
Container(
color: Colors.cyanAccent,
height: 200 + 70 + 60, // based on circle+ text space
child: Stack(
clipBehavior: Clip.none,
children: <Widget>[
// divider
Align(
alignment: Alignment(0, -.35),
child: Container(
width: constraints.maxWidth,
height: 8,
color: mainColor,
)),
Positioned(
top: 40,
left: 100,
child: Column(
children: [
CircleAvatar(
radius: 100,
),
SizedBox(
height: 70,
),
Text(
"Dumasd Text A",
textAlign: TextAlign.center,
),
],
),
),
Align(
alignment: Alignment(.7, .25),
child: saveProfile(),
)
],
),
),
],
),
],
),
),
);
}
ButtonTheme saveProfile() {
return ButtonTheme(
minWidth: 100.0,
height: 38.0,
buttonColor: mainColor,
// ignore: deprecated_member_use
child: RaisedButton(
padding: EdgeInsets.fromLTRB(30, 0, 30, 0),
textColor: Colors.white,
color: mainColor,
child: Text('Save'),
onPressed: () {}),
);
}
}
Play with Positioned and Alignment
I'm trying to display a list of contestants that are participating in a challenge and sort them by their score but other then that I'm trying to put some actual distance between them in the list where one can actually tell how far behind he actually is from the other contestant whether he is in front or behind of him with their accumulated score(you will find an example of what I'm trying to do down below), so far what I've done is displaying the list of the contestants with a listview.builder and returned a TimelineTile() (timeline_tile) and the result is shown below, what I'm stuck right now is how to start/do the dynamic distance between each contestant depending on their score?
Any help is appreciated :D
My ListView.builder:
body: Center(
child: ListView.builder(
shrinkWrap: true,
itemCount: _contestants.length,
itemBuilder: (context, index) {
var data = _contestants[index];
bool isTeamOne = data.team == 'teamOne';
bool isTeamTwo = data.team == 'teamTwo';
return SizedBox(
height: 100,
width: 50,
child: TimelineTile(
alignment: TimelineAlign.center,
endChild: isTeamOne
? Align(
alignment: Alignment.centerLeft, child: _userCard(data))
: const Text(''),
startChild: isTeamTwo
? Align(
alignment: Alignment.centerRight,
child: _userCard(
data,
))
: const Text(''),
beforeLineStyle: const LineStyle(
color: Colors.brown,
thickness: 5,
),
afterLineStyle: const LineStyle(
color: Colors.black,
thickness: 5,
),
indicatorStyle: IndicatorStyle(
padding: const EdgeInsets.symmetric(horizontal: 0),
color: isTeamOne ? Colors.red : Colors.green,
indicatorXY: 0.5,
drawGap: true,
),
),
);
},
),
),
Widget _userCard(ChallengeModel data) {
return Card(
elevation: 5,
color: Colors.teal,
child: Text(data.name),
);
}
My list of data:
final List<ChallengeModel> _contestants = [
ChallengeModel(
id: 1,
name: 'Team1',
createdAt: 'createdAt',
numeric: 4,
team: 'teamOne',
indicatorXY: 0.7,
),
ChallengeModel(
id: 2,
name: 'Team2',
createdAt: 'createdAt',
numeric: 3,
team: 'teamTwo',
indicatorXY: 0.5,
),
ChallengeModel(
id: 3,
name: 'Team1',
createdAt: 'createdAt',
numeric: 2,
team: 'teamOne',
indicatorXY: 0.3,
),
ChallengeModel(
id: 4,
name: 'Team2',
createdAt: 'createdAt',
numeric: 3,
team: 'teamTwo',
indicatorXY: 0.6,
),
];
What I want to achieve:
What I got so far:
Update
I tried another approach to put actual distance between the players/contestants on a challenge, what I did was by putting everything in a stack and draw a line with a Container() and removed the TimeLineTile() widget and added some containers as cards and dots to see where he is in the line, the way I move them up and down is by basically pushing the player/contestant from the bottom to the top, but this is leading to some other issues mainly the accuracy of the miles a player/contestant has and the actual moving of the container proportionally in the drawn line(which is the line of how much miles should a player/contestant accomplish)
My code so far with the Stack() solution:
body: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 0.0),
child: Stack(
alignment: AlignmentDirectional.bottomCenter,
children: [
Padding(
padding: const EdgeInsets.only(top: 28.0),
child: Container(
height: 500,
width: 20,
color: Colors.red,
),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 0.0),
child: ListView.builder(
shrinkWrap: true,
itemCount: _contestants.length,
itemBuilder: (context, index) {
var data = _contestants[index];
bool isTeamOne = data.team == 'teamOne';
bool isTeamTwo = data.team == 'teamTwo';
return Align(heightFactor: 0.01, child: _userCard(data));
},
),
),
],
),
),
);
Widget _userCard(ChallengeModel data) {
var isTeamOne = data.team == 'teamOne';
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 167.0),
child: Container(
margin: EdgeInsets.only(bottom: data.numeric),
alignment: Alignment.bottomCenter,
child: Row(
mainAxisAlignment:
isTeamOne ? MainAxisAlignment.end : MainAxisAlignment.start,
children: [
isTeamOne
? const Icon(Icons.ac_unit_rounded)
: Padding(
padding: const EdgeInsets.only(right: 20.0),
child: Card(
elevation: 5,
color: Colors.teal,
child: Text(data.name),
),
),
isTeamOne
? Padding(
padding: const EdgeInsets.only(left: 20.0),
child: Card(
elevation: 5,
color: Colors.teal,
child: Text(data.name),
),
)
: Icon(Icons.ac_unit_rounded),
],
),
),
);
}
I think wrapping your TimelineTile into SizedBox then assigning a height will be good option. Try below code :
Column(
children: [
SizedBox(
height: 200,
child: TimelineTile(
alignment: TimelineAlign.center,
startChild: Container(
height: 50,
child: Card(
color: Colors.lightBlueAccent,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(50)),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("59"),Text("Title"),
Icon(Icons.ac_unit)
],
),
),
),
),
),
),
SizedBox(
height: 150,
child: TimelineTile(
alignment: TimelineAlign.center,
endChild: Container(
height: 50,
child: Card(
color: Colors.lightBlueAccent,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(50)),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("59"),Text("Title"),
Icon(Icons.ac_unit)
],
),
),
),
),
),
),
SizedBox(
height: 80,
child: TimelineTile(
alignment: TimelineAlign.center,
endChild: Container(
height: 50,
child: Card(
color: Colors.lightBlueAccent,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(50)),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("59"),Text("Title"),
Icon(Icons.ac_unit)
],
),
),
),
),
),
),
SizedBox(
height: 100,
child: TimelineTile(lineXY: 0.0,
alignment: TimelineAlign.center,
endChild: SizedBox(
height: 50,
child: Card(
color: Colors.lightBlueAccent,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(50)),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("59"),Text("Title"),
Icon(Icons.ac_unit)
],
),
),
),
),
),
),
],
)
What i need?
I have two Positioned Widget inside of the Stack Widget. Once i click the TextButton i'd like to transform one positioned widget right to left and display another invisible widget on the screen.
Also once i click the another TextButton it should be like in the initial view.
I have tried what have described in this video but couldn't work.
https://www.youtube.com/watch?v=FCyoHclCqc8
Details in the below code
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
class HomeScreen extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
FormLogin(),
],
));
}
}
class FormLogin extends StatefulWidget {
const FormLogin({
Key key,
}) : super(key: key);
#override
_FormLoginState createState() => _FormLoginState();
}
class _FormLoginState extends State<FormLogin>
with SingleTickerProviderStateMixin {
static AnimationController controller;
#override
Widget build(BuildContext context) {
return Flexible(
flex: 2,
child: Stack(
children: <Widget>[
Container(height: MediaQuery.of(context).size.height),
Container(
height: MediaQuery.of(context).size.height / 2.5,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [Color(0xFFbe8696), Color(0xFFbe8996)],
),
),
),
// Logo Section -> I don't want to transform this section i want to keep it on screen.
Positioned(
top: MediaQuery.of(context).size.height / 6,
left: MediaQuery.of(context).size.width / 3.8,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Image.network(
"https://upload.wikimedia.org/wikipedia/commons/thumb/1/17/Google-flutter-logo.png/799px-Google-flutter-logo.png",
scale: 4,
),
],
),
),
// Login Screen - I would like to transfer this Positioned Widget through
// X axis to left and make it invisible, When I click the below TextButton.
Positioned(
top: 200,
child: Container(
height: MediaQuery.of(context).size.height / 2,
width: MediaQuery.of(context).size.width,
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
margin: EdgeInsets.all(20.0),
elevation: 0.7,
child: Padding(
padding: const EdgeInsets.only(
left: 16, right: 16, top: 8, bottom: 4),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Center(
child: Wrap(
runAlignment: WrapAlignment.center,
crossAxisAlignment: WrapCrossAlignment.center,
children: [
TextButton(
// When I click that button.
onPressed: () {},
child: Text(
"Signup",
style: GoogleFonts.montserrat(
fontWeight: FontWeight.w400,
fontSize: 14.0,
color: Colors.black,
),
),
)
],
),
),
],
)),
))),
// Register Screen - Once user click the above button,
// at the same time this widget should be visible.
Positioned(
top: 250,
// This widget invisible now. Make "left: 0" to display widget.
left: 0,
height: MediaQuery.of(context).size.height / 2,
child: Container(
width: MediaQuery.of(context).size.width,
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
margin: EdgeInsets.all(20.0),
elevation: 0.7,
child: Padding(
padding: const EdgeInsets.only(
left: 16, right: 16, top: 8, bottom: 4),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Center(
child: Wrap(
runAlignment: WrapAlignment.center,
crossAxisAlignment: WrapCrossAlignment.center,
children: [
TextButton(
//**I would like to return initial position once i click that button.**
onPressed: () {},
child: Text(
"Return Back",
style: GoogleFonts.montserrat(
fontWeight: FontWeight.w400,
fontSize: 14.0,
color: Colors.black,
),
),
)
],
),
),
],
)),
)))
],
),
);
}
}
I have a question whether it is feasible what I am planning. When I scroll down my page, the red-framed container shouldn't disappear but instead stay in the place of the red frame. I have no idea how to do it right now. Here is the relevant part of the code.
thank you in advance for any idea.
R.Eleven
Screenshot normal
Screenshot where the container should be
it should look like that
Here the Code
body: SingleChildScrollView(
child: Container(
// Main Container
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/bg.jpg"),
fit: BoxFit.cover,
),
),
child: Column(
children: <Widget>[
Container(
// Bild Container
height: 300,
child: Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Container(
decoration: BoxDecoration(
boxShadow: [
//background color of box
BoxShadow(
color: Color.fromRGBO(
33,
33,
33,
1,
),
blurRadius: 4, // soften the shadow
spreadRadius: 2, //extend the shadow
offset: Offset(
0.0, // Move to right 10 horizontally
0.0, // Move to bottom 10 Vertically
),
)
],
image: DecorationImage(
fit: BoxFit.cover,
image:
CachedNetworkImageProvider(data['imgUrl'])),
color: Color.fromRGBO(255, 255, 255, 100),
),
),
),
), // Bild
Container(
height: 60,
width: MediaQuery.of(context).size.width,
// Titel Container
child: Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Container(
decoration: BoxDecoration(
boxShadow: [
//background color of box
BoxShadow(
color: Color.fromRGBO(
33,
33,
33,
1,
),
blurRadius: 4, // soften the shadow
spreadRadius: 2, //extend the shadow
offset: Offset(
0.0, // Move to right 10 horizontally
0.0, // Move to bottom 10 Vertically
),
)
],
color: Color.fromRGBO(255, 255, 255, 1),
),
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Text(data['title'],
style: Theme.of(context).textTheme.headline),
)),
),
), // Titel
Container(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Expanded(
// Left
flex: 4,
child: Padding(
padding: const EdgeInsets.only(top: 10.0),
child: Container(
decoration: BoxDecoration(
boxShadow: [
//background color of box
BoxShadow(
color: Color.fromRGBO(
33,
33,
33,
1,
),
blurRadius: 4, // soften the shadow
spreadRadius: 2, //extend the shadow
offset: Offset(
0.0, // Move to right 10 horizontally
0.0, // Move to bottom 10 Vertically
),
)
],
color: Color.fromRGBO(255, 255, 255, 1),
),
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Row(
children: <Widget>[
Text("Portionen: ",
style: Theme.of(context)
.textTheme
.body1),
Text(data['portions'],
style: Theme.of(context)
.textTheme
.body1),
],
),
Text("Zutaten",
style: Theme.of(context)
.textTheme
.title),
Text(data['ingredients'],
style: Theme.of(context)
.textTheme
.body1),
],
),
),
),
),
),
Expanded(
// Right
flex: 6,
child: Padding(
padding:
const EdgeInsets.only(top: 10.0, left: 10),
child: Container(
decoration: BoxDecoration(
boxShadow: [
//background color of box
BoxShadow(
color: Color.fromRGBO(
33,
33,
33,
1,
),
blurRadius: 4, // soften the shadow
spreadRadius: 2, //extend the shadow
offset: Offset(
0.0, // Move to right 10 horizontally
0.0, // Move to bottom 10 Vertically
),
)
],
color: Color.fromRGBO(255, 255, 255, 1),
),
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text("Zubereitung",
style: Theme.of(context)
.textTheme
.body1),
ItemsList(myid: widget.value),
],
),
),
),
),
),
],
),
),
],
),
),
),
I think what you are looking for is Sticky Side Header, try this flutter_sticky_header sample:
import 'package:flutter/material.dart';
import 'package:flutter_sticky_header/flutter_sticky_header.dart';
import '../common.dart';
class SideHeaderExample extends StatelessWidget {
const SideHeaderExample({
Key key,
}) : super(key: key);
#override
Widget build(BuildContext context) {
return AppScaffold(
title: 'Side Header Example',
slivers: [
_StickyHeaderGrid(index: 0),
_StickyHeaderGrid(index: 1),
_StickyHeaderGrid(index: 2),
_StickyHeaderGrid(index: 3),
],
);
}
}
class _StickyHeaderGrid extends StatelessWidget {
const _StickyHeaderGrid({
Key key,
this.index,
}) : super(key: key);
final int index;
#override
Widget build(BuildContext context) {
return SliverStickyHeader(
overlapsContent: true,
header: _SideHeader(index: index),
sliver: SliverPadding(
padding: const EdgeInsets.only(left: 60),
sliver: SliverGrid(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3, crossAxisSpacing: 4.0, mainAxisSpacing: 4.0),
delegate: SliverChildBuilderDelegate(
(context, i) => GridTile(
child: Card(
child: Container(
color: Colors.green,
),
),
footer: Container(
color: Colors.white.withOpacity(0.5),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'Grid tile #$i',
style: const TextStyle(color: Colors.black),
),
),
),
),
childCount: 9,
),
),
),
);
}
}
class _SideHeader extends StatelessWidget {
const _SideHeader({
Key key,
this.index,
}) : super(key: key);
final int index;
#override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0),
child: Align(
alignment: Alignment.centerLeft,
child: SizedBox(
height: 44.0,
width: 44.0,
child: CircleAvatar(
backgroundColor: Colors.orangeAccent,
foregroundColor: Colors.white,
child: Text('$index'),
),
),
),
);
}
}
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.