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
Why does this SingleChildScrollView overflow instead of scroll when the screen height is resized too small? I've used this design because the bottom widget needs to be pushed to the bottom.
return NavigationListener(builder: (context, child) {
return SingleChildScrollView(
child: SizedBox(
height: MediaQuery.of(context).size.height,
width: maxSideMenuWidth,
child: Column(
children: [
Container(
height: 155, color: Colors.purple, child: const MenuHeader()),
Container(
color: Colors.red,
height: 327,
child: MainMenu(
primaryDestinations: primaryDestinations,
secondaryDestinations: secondaryDestinations,
onNavigate: onNavigate,
isSelected: isSelected,
)),
Spacer(),
Container(
color: Colors.green,
height: 135,
child: LoginContextWidget(user, userDetails, logOut)),
],
),
));
});
Try This code
return NavigationListener(builder: (context, child) {
return SizedBox(
height: MediaQuery.of(context).size.height,
width: maxSideMenuWidth,
child: SingleChildScrollView(
child: Column(
children: [
Container(
height: 155, color: Colors.purple, child: const MenuHeader()),
Container(
color: Colors.red,
height: 327,
child: MainMenu(
primaryDestinations: primaryDestinations,
secondaryDestinations: secondaryDestinations,
onNavigate: onNavigate,
isSelected: isSelected,
)),
Spacer(),
Container(
color: Colors.green,
height: 135,
child: LoginContextWidget(user, userDetails, logOut)),
],
),
),
);
});
wrap singlechildscrollview in expanded
return NavigationListener(builder: (context, child) {
return Expanded(
child:SingleChildScrollView(
child: SizedBox(
height: MediaQuery.of(context).size.height,
width: maxSideMenuWidth,
child: Column(
children: [
Container(
height: 155, color: Colors.purple, child: const MenuHeader()),
Container(
color: Colors.red,
height: 327,
child: MainMenu(
primaryDestinations: primaryDestinations,
secondaryDestinations: secondaryDestinations,
onNavigate: onNavigate,
isSelected: isSelected,
)),
Spacer(),
Container(
color: Colors.green,
height: 135,
child: LoginContextWidget(user, userDetails, logOut)),
],
),
));
};
});
Widget build(BuildContext context) {
return Swipable(
child: Column(
children: [
Container(
height: MediaQuery.of(context).size.height * 0.57,
child: Card(
elevation: 2,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(14),
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: ClipRRect(
borderRadius: BorderRadius.circular(14),
child: Image.network(
widget.urls,
fit: BoxFit.cover,
),
),
),
),
),
Center(
child: Expanded(
child: Text(
widget.usernames,
maxLines: 1,
)),
)
],
),
//onSwipeLeft: () => _returnString(index),
);
}
}
This is my code and i've been adjusting and readjusting for over 3hrs.. I just need the text to show on the image that can be swiped. Please help me. Thanks
image:
Hello I think what you are needing is to use a Stack Widget instead of a Column widget. When using Stacks you can use a Positioned widget to indicate exactly where you want your child widgets to be displayed inside of the stack as well.
Widget build(BuildContext context) {
return Swipable(
child: Stack(
alignment: Alignment.center,
children: [
Container(
height: MediaQuery.of(context).size.height * 0.57,
child: Card(
elevation: 2,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(14),
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: ClipRRect(
borderRadius: BorderRadius.circular(14),
child: Image.network(
widget.urls,
fit: BoxFit.cover,
),
),
),
),
),
Positioned(
top: 16,
right: 16,
child: Center(
child: Expanded(
child: Text(
widget.usernames,
maxLines: 1,
)),
),
)
],
),
//onSwipeLeft: () => _returnString(index),
);
}
}
Happy Coding!
You can use this way
Widget build(BuildContext context) {
return Column(
children: [
Container(
decoration: BoxDecoration(
image: DecorationImage(
widget.urls,
fit: BoxFit.cover,
),
),
height: MediaQuery.of(context).size.height * 0.57,
width: MediaQuery.of(context).size.height,
child: Align(
alignment: Alignment.bottomCenter,
child: Text(
widget.usernames,
style: TextStyle(color: Colors.orange),
),
),
),
],
);
//onSwipeLeft: () => _returnString(index),
}
may i ask how to force the top part of the screen not disappear when i scroll the listview down ?
as you can see here in this Photo
When i Scroll the ListView Down, then the top part, that contains the Player Widgets will disappear
so how can i please to force the Top Widgets to keep showing up when i scrolling down the Listview
Scaffold(
body: Container(
child: ListView(
shrinkWrap: true,
children: <Widget>[
Center(
child: Container(
width: 200.0,
height: 150.0,
child: Stack(
children: <Widget>[
Container(
decoration: BoxDecoration(
color:Color(0xff193451).withOpacity(.5),
shape: BoxShape.circle),
child: Padding(
padding: const EdgeInsets.all(.0),
child: _buildRadialSeekBar(),
),
),
Center(
child: Container(
width: 150.0,
height: 150.0,
child: Padding(
padding: const EdgeInsets.all(5.0),
child: ClipOval(
clipper: MClipper(),
child: Image.asset(
"assets/justine.jpg",
fit: BoxFit.cover,
),
),
),
),
)
],
),
),
),
Container(
// color: Colors.blue,
width: 350.0,
height: 100.0,
child: Stack(
children: <Widget>[
Center(
child: Container(
height: 65.0,
width: 290.0,
decoration: BoxDecoration(
border: Border.all(
color: Color(0xff193451), width: 3.0),
borderRadius: BorderRadius.circular(40.0)),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 25.0),
child: Row(
children: <Widget>[
Icon(Icons.fast_rewind,
size: 55.0, color: Color(0xff193451)),
Expanded(
child: Container(),
),
Icon(Icons.fast_forward,
size: 55.0, color: Color(0xff193451))
],
),
),
),
),
Align(
alignment: Alignment.center,
child: Container(
width: 92.0,
height: 92.0,
decoration: BoxDecoration(
color: Color(0xff193451), shape: BoxShape.circle),
child: IconButton(
icon: Icon(
Icons.play_arrow,
size: 45.0,
color: Colors.white,
),
onPressed: () {},
),
),
)
],
),
),
ListView(
shrinkWrap: true,
physics: ClampingScrollPhysics(),
children: [
if(LocalUrl == "http://local") Container(child: ParseLocall(),),
if(LocalUrl == "http://music") Container(child: ParseMusicc(),),
if(LocalUrl == "http://talk") Container(child: ParseTalkk(),),
if(LocalUrl == "http://sports") Container(child: ParseSportss(),),
if(LocalUrl == "http://id=r0") Container(child: ParseByLocationn(),),
if(LocalUrl == "http://lang") Container(child: ParseLanguagess(),),
if(LocalUrl == "http://podcast") Container(child: ParseProdcastss(),),
],
),
],
),
));
Thanks in Advance
You can separate Justin part from your ListView and wrap them with a Column. Code needs some fixing still, but will be like that:
body: Container(
// Here is the Column!
child: Column(
children: [
// And here is the top part!
Center(
child: Container(
width: 200.0,
height: 150.0,
child: Stack(
children: <Widget>[
Container(
decoration: BoxDecoration(
color:Color(0xff193451).withOpacity(.5),
shape: BoxShape.circle),
child: Padding(
padding: const EdgeInsets.all(.0),
child: _buildRadialSeekBar(),
),
),
Center(
child: Container(
width: 150.0,
height: 150.0,
child: Padding(
padding: const EdgeInsets.all(5.0),
child: ClipOval(
clipper: MClipper(),
child: Image.asset(
"assets/justine.jpg",
fit: BoxFit.cover,
),
),
),
),
)
],
),
),
),
ListView(
shrinkWrap: true,
children: <Widget>[
Container(
// color: Colors.blue,
width: 350.0,
height: 100.0,
child: Stack(
children: <Widget>[
Center(
child: Container(
height: 65.0,
width: 290.0,
decoration: BoxDecoration(
border: Border.all(
color: Color(0xff193451), width: 3.0),
borderRadius: BorderRadius.circular(40.0)),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 25.0),
child: Row(
children: <Widget>[
Icon(Icons.fast_rewind,
size: 55.0, color: Color(0xff193451)),
Expanded(
child: Container(),
),
Icon(Icons.fast_forward,
size: 55.0, color: Color(0xff193451))
],
),
),
),
),
Align(
alignment: Alignment.center,
child: Container(
width: 92.0,
height: 92.0,
decoration: BoxDecoration(
color: Color(0xff193451), shape: BoxShape.circle),
child: IconButton(
icon: Icon(
Icons.play_arrow,
size: 45.0,
color: Colors.white,
),
onPressed: () {},
),
),
)
],
),
),
ListView(
shrinkWrap: true,
physics: ClampingScrollPhysics(),
children: [
if(LocalUrl == "http://local") Container(child: ParseLocall(),),
if(LocalUrl == "http://music") Container(child: ParseMusicc(),),
if(LocalUrl == "http://talk") Container(child: ParseTalkk(),),
if(LocalUrl == "http://sports") Container(child: ParseSportss(),),
if(LocalUrl == "http://id=r0") Container(child: ParseByLocationn(),),
if(LocalUrl == "http://lang") Container(child: ParseLanguagess(),),
if(LocalUrl == "http://podcast") Container(child: ParseProdcastss(),),
],
),
],
),
],
),
));
I want to add a list of Container inside a Column widget.
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
fixedContainer(context),
),
Widget fixedContainer(BuildContext context) {
return ListView(
children: <Widget>[
FutureBuilder<List<AddCash>>(
future: future,
builder: (context, snapshot) {
if (snapshot.hasData) {
return Column(
children:
snapshot.data.map((todo) => nameColumn(todo)).toList());
} else {
return SizedBox();
}
},
),
],
);
}
Widget nameColumn(AddCash addCash) {
return Container(
alignment: Alignment.center,
width: 120.0,
height: 60.0,
color: Colors.white,
margin: EdgeInsets.all(4.0),
child: Text(
'name: ${addCash.name}',
),
);
}
It's getting an error saying Vertical viewport was given unbounded height. Do I need to set the height? I didn't set the height because I need to add the Container dynamically.
Entire Code
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import '../data/repository_service_addcash.dart';
import '../models/addcash.dart';
class CalendarPage extends StatefulWidget {
#override
_CalendarPageState createState() => _CalendarPageState();
}
class _CalendarPageState extends State<CalendarPage> {
Future<List<AddCash>> future;
int id;
#override
initState() {
super.initState();
future = RepositoryServiceAddCash.getAllAddCash();
}
#override
Widget build(BuildContext context) {
return Scaffold(
body: SingleChildScrollView(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
//THE FIRST COLUMN NEEDS TO BY DYNAMICALLY PRODUCDED
// nameColumnContainer(context),
Container(
alignment: Alignment.center,
width: 120.0,
height: 60.0,
color: Colors.white,
margin: EdgeInsets.all(4.0),
child: Text(
"ONE",
),
),
Container(
alignment: Alignment.center,
width: 120.0,
height: 60.0,
color: Colors.white,
margin: EdgeInsets.all(4.0),
child: Text(
"TWO",
),
),
Container(
alignment: Alignment.center,
width: 120.0,
height: 60.0,
color: Colors.white,
margin: EdgeInsets.all(4.0),
child: Text(
"THREE",
),
),
],
),
Flexible(
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
child: Row(
// children: getDaysInWeek(),
children: <Widget>[
Container(
alignment: Alignment.center,
width: 120.0,
height: 60.0,
color: Colors.white,
margin: EdgeInsets.all(4.0),
child: Text(
"A",
),
),
Container(
alignment: Alignment.center,
width: 120.0,
height: 60.0,
color: Colors.white,
margin: EdgeInsets.all(4.0),
child: Text(
"B",
),
),
Container(
alignment: Alignment.center,
width: 120.0,
height: 60.0,
color: Colors.white,
margin: EdgeInsets.all(4.0),
child: Text(
"C",
),
),
Container(
alignment: Alignment.center,
width: 120.0,
height: 60.0,
color: Colors.white,
margin: EdgeInsets.all(4.0),
child: Text(
"D",
),
),
],
),
),
Container(
child: Row(
children: <Widget>[
Container(
alignment: Alignment.center,
width: 120.0,
height: 60.0,
color: Colors.white,
margin: EdgeInsets.all(4.0),
child: Text(
"H",
),
),
Container(
alignment: Alignment.center,
width: 120.0,
height: 60.0,
color: Colors.white,
margin: EdgeInsets.all(4.0),
child: Text(
"F",
),
),
Container(
alignment: Alignment.center,
width: 120.0,
height: 60.0,
color: Colors.white,
margin: EdgeInsets.all(4.0),
child: Text(
"3000",
),
),
Container(
alignment: Alignment.center,
width: 120.0,
height: 60.0,
color: Colors.white,
margin: EdgeInsets.all(4.0),
child: Text(
"4000",
),
),
],
),
),
Container(
alignment: Alignment.center,
width: 120.0,
height: 60.0,
color: Colors.white,
margin: EdgeInsets.all(4.0),
child: Text(
"two",
),
),
],
),
),
)
],
),
),
);
}
Widget nameColumnContainer(BuildContext context) {
return ListView(
shrinkWrap: true,
children: <Widget>[
FutureBuilder<List<AddCash>>(
future: future,
builder: (context, snapshot) {
if (snapshot.hasData) {
return Column(
children:
snapshot.data.map((todo) => nameColumn(todo)).toList());
} else {
return SizedBox();
}
},
),
],
);
}
Widget nameColumn(AddCash addCash) {
return Container(
alignment: Alignment.center,
width: 120.0,
height: 60.0,
color: Colors.white,
margin: EdgeInsets.all(4.0),
child: Text(
'name: ${addCash.name}',
),
);
}
}
You could set shrinkWrap: true to the ListView.
shrinkWrap property
If the scroll view does not shrink wrap, then the scroll view will
expand to the maximum allowed size in the scrollDirection. If the
scroll view has unbounded constraints in the scrollDirection, then
shrinkWrap must be true.