How to add text under images like shown in example below [Flutter] - flutter

I would like to add the text "Appointments" like shown in the example below. I've tried using the Text widget under Image.asset but I don't think I'm using it right. I'm still new to Flutter so any help would be much appreciated.
Expected Output
This is the code I have so far:
Container(
height: 250,
width: 320,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
boxShadow: kElevationToShadow[1],
color: Color.fromARGB(255, 255, 255, 255),
),
child: Align(
alignment: Alignment(0, -0.5),
child: Image.asset("assets/appointment.png", height: 150, width: 150),
),
),

Use below code :
Container(
height: 250,
width: 320,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
boxShadow: kElevationToShadow[1],
color: Color.fromARGB(255, 255, 255, 255),
),
child: Column(
children: [
Align(
alignment: Alignment(0, -0.5),
child: Image.asset("assets/appointment.png", height: 150, width: 150),
),
SizedBox(height: 20,),
Text('Appointments',style: TextStyle(color: Colors.black,fontSize: 18),),
],
),
),

Used card and column widget for this type of UI.
Card(
elevation: 10,
shape: RoundedRectangleBorder(borderRadius:BorderRadius.circular(10)),
child: Column(
children: [
// Your Image Widget
// Your Text Widget
],
),
),

Related

Is there something like mainaxisaligment for a stack?

Is there a way to align the blue chart bars to the bottom instead of the top?
Here's the code, the blue bar is the FractionallySizedBox:
#override
Widget build(BuildContext context) {
return Column(
children: [
Container(
height: 20,
child: FittedBox(
child: Text('\$${getShortForm(spendingAmount)}'),
),
),
SizedBox(
height: 4,
),
Container(
height: 64,
width: 10,
child: Stack(
children: [
Container(
decoration: BoxDecoration(
border: Border.all(color: Colors.grey, width: 1),
color: Color.fromRGBO(220, 220, 220, 1),
borderRadius: BorderRadius.circular(10),
),
),
FractionallySizedBox(
heightFactor: spendingPctOfTotal,
child: Container(
decoration: BoxDecoration(
color: Theme.of(context).primaryColor,
borderRadius: BorderRadius.circular(10),
),
),
),
],
),
),
SizedBox(
height: 4,
),
Text(label)
],
);
}
}
I tried working with the Stack's alignment attribute but that didn't seem to work. It seems I can only work with the order in which the children are stacked, not position. I tried wrapping it with a column but that broke the entire thing.
Mostly we need to wrap stack children with positioned widget like Aling/Positioned. For your case
child: Stack(
alignment: Alignment.bottomCenter,//default is topStart
children: [
Or
Align(
alignment: Alignment.bottomCenter,
child: FractionallySizedBox(
heightFactor: .3,
child: Container(
alignment: Alignment.bottomCenter,
decoration: BoxDecoration(
color: Theme.of(context).primaryColor,
borderRadius: BorderRadius.circular(10),
),
),
),
),

How can I make the outer circles

I am trying to make the display feature for my app, but I am having a hard time making these outer circles, any input is appreciated
There is a way to draw using coordinates.
You can set the ratio using MediaQuery.of(context).size.
return Scaffold(
body: SafeArea(
child: Stack(
children: <Widget>[
Positioned(
top: 200,
left: 80,
child: Container(
width: 200,
height: 200,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(128.0),
border: Border.all(color: Colors.blue),
),
),
),
Positioned(
top: 225,
left: 105,
child: Container(
width: 150,
height: 150,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(128.0),
border: Border.all(color: Colors.blue),
),
),
),
],
),
),
);
Use this:
Container(
color: Colors.white,
child: Center(
child: Container(
width: 200,
height: 200,
decoration: BoxDecoration(
gradient: const LinearGradient(
colors: [Colors.white,Colors.white, Colors.red, Colors.red, Colors.white,Colors.white],
transform: GradientRotation(pi / 2),
),
borderRadius: BorderRadius.circular(128.0),
),
child: Center(
child: Container(
width: 198,
height: 198,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(120.0),
),
),
),
),
),
),
It leads to this output:
use stack widget and put 2 circle containers with different size as children in stack widget

Select multiple choice flutter

What is this and how can I build this in flutter? I don't know how to create it and I can't design these buttons.
This is the design which I want to create
I'm guessing you do not know how to create those buttons, this is a scuffed code but it should give you an idea of how to create it.
Container(
width: 220.0,
height: 65.0,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Colors.white, Color.fromARGB(255, 177, 177, 177)]),
borderRadius: BorderRadius.circular(35),
),
alignment: Alignment.center, // where to position the child
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 2, sigmaY: 2),
child: Container(
width: 200.0,
height: 50.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(25),
color: Color.fromARGB(255, 226, 219, 219)),
child: Row(
children: [
Expanded(
flex: 2,
child: Container(
margin: EdgeInsets.symmetric(
vertical: 7, horizontal: 10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
color: Color.fromARGB(255, 78, 151, 185)),
)),
Expanded(
flex: 5,
child: Container(
padding: EdgeInsets.symmetric(vertical: 7),
alignment: Alignment.centerLeft,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(child: Text("title")),
Expanded(child: Text("subtitle"))
],
),
),
)
],
),
),
),
),
should result in something like this
adjust colors/dimensions/radius and text accordingly. You can turn it into a button with a gestureDetector Wrap it with a statefulWidget and assign a pressed parameter to it to control how it behaves when clicked and what to change. Please be mindful of the dimensions when creating it, use media sized query to not over flow

Flutter container inside a container using a widget

I want to add two boxes, one inside another. Here's my code and its not working for two boxes. how should I correct this. doc UI in this doc you can see the UI I implement so far and the UI I want to be implement.
Widget DetailBox() => Padding(
padding: const EdgeInsets.only(left: 25, right: 25),
child:Column(
children: [
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30.0),
color: Colors.white,
),
// alignment: Alignment.bottomCenter,
height: 400,
width: 300,
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30.0),
color: Colors.lightBlue,
),
// alignment: Alignment.bottomCenter,
height: 100,
width: 300,
),
),
],
),
);
May it help you
Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(25),
),
elevation: 5,
shadowColor: Colors.blue.shade200,
child: Column(
children: [
Expanded(
flex: 1,
child: Container(
decoration: BoxDecoration(
color: Colors.lightBlueAccent,
borderRadius: BorderRadius.only(topLeft:Radius.circular(25),topRight:Radius.circular(25))
),
),
),
Expanded(
flex: 3,
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(bottomRight:Radius.circular(25),bottomLeft:Radius.circular(25))
),
),
)
],
),
),
According to the design of the app, put the image in the bule box.

3D Sphere Effect in Flutter

I want to create a view like below.
I tried adding a RadialGradient but it doesn't exact like this image.
Container(
height: 50,
width: 50,
decoration: const BoxDecoration(
color: Color(0xff2DD485),
shape: BoxShape.circle,
gradient: RadialGradient(colors: [Color(0xff42CF8C), Color(0xff1DAE69)], center: Alignment(0, -0.7), stops: [0, 1]),
),
child: const Icon(Icons.done_rounded, color: Colors.white),
)
a bit ugly, but do the trick:
child: ClipRRect(
borderRadius: const BorderRadius.all(Radius.circular(25)),
child: Container(
height: 50,
width: 50,
color: const Color(0xff2DD485),
child: Stack(
alignment: AlignmentDirectional.center,
children: [
Positioned(
bottom: 22,
child: Container(
height: 50,
width: 50,
decoration: const BoxDecoration(
color: Color(0xff56dc9d),
shape: BoxShape.circle,
),
),
),
const Icon(Icons.done_rounded, color: Colors.white),
],
),
),
)