Reputation: 301
I'm new to flutter and implementing this container. I want to add a trophy and text "NFT" like the image shown. I tried using column rows, but doesn't work. how can I do this appreciate your help on this. ............................... ........................... .............. ................. .................... ...............
return Center(
child: Material(
type: MaterialType.transparency,
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
// color: backgroundBlue,
gradient: myGradient,
),
padding: const EdgeInsets.only(top: 15, bottom: 15,left: 15),
width: Size.width - 40,
height: Size.height * 0.5,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
"Challenge",
style: TextStyle(
color: buttonPurpule,
fontSize: 25,
// fontWeight: FontWeight.bold
),
),
SizedBox(
height: 20,
),
Row(
children: [
Text(
"Steps",
style: TextStyle(
color: buttonPurpule,
fontSize: 20,
),
),
],
),
Row(
children: [
Text(
"10,000 Steps",
style: TextStyle(
color: buttonPurpule,
fontSize: 20,
),
),
],
),
SizedBox(
height: 20,
),
Row(
children: [
Text(
"Clories",
style: TextStyle(
color: buttonPurpule,
fontSize: 20,
),
),
],
),
Row(
children: [
Text(
"650 cal",
style: TextStyle(
color: buttonPurpule,
fontSize: 20,
),
),
],
),
SizedBox(
height: 20,
),
Row(
children: [
Text(
"Exercise",
style: TextStyle(
color: buttonPurpule,
fontSize: 20,
),
),
],
),
Row(
children: [
Text(
"15 Min 550cal , 5000Steps",
style: TextStyle(
color: buttonPurpule,
fontSize: 20,
),
),
],
),
SizedBox(
height: 20,
),
Expanded(
flex: 1,
child: GestureDetector(
child: //Icon(Icons.arrow_forward, color: textWhite),
ButtonM("Unlock", Size, Size.width * 0.75,
Icons.arrow_forward, false, buttonblue),
onTap: () {
_Unlockchallenge();
},
),
),
],
),
),
),
);
Upvotes: 0
Views: 75
Reputation: 676
You can use Stack for positioning text on a image.
Wrap Text inside Positioned to get the desired position.
Use clipBehaviour: Clip.none to ensure your stack elements are not clipped if they overflow outside parent widget size.
Code:
Widget build(BuildContext context) {
// final mainChildKey = GlobalKey();
double width = MediaQuery.of(context).size.width;
double height = MediaQuery.of(context).size.height;
return Scaffold(
appBar: AppBar(),
body: Center(
child: Material(
type: MaterialType.transparency,
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.white,
// gradient: Gradient(colors: [Colors.amber, Colors.orange],),
),
padding: const EdgeInsets.only(top: 15, bottom: 15, left: 15),
width: width - 40,
height: height * 0.5,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
const Text(
"Challenge",
style: TextStyle(
color: Colors.purple,
fontSize: 25,
// fontWeight: FontWeight.bold
),
),
const SizedBox(
height: 20,
),
Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: const [
Text(
"Steps",
style: TextStyle(
color: Colors.purple,
fontSize: 20,
),
),
],
),
Row(
children: const [
Text(
"10,000 Steps",
style: TextStyle(
color: Colors.purple,
fontSize: 20,
),
),
],
),
const SizedBox(
height: 20,
),
Row(
children: const [
Text(
"Clories",
style: TextStyle(
color: Colors.purple,
fontSize: 20,
),
),
],
),
Row(
children: const [
Text(
"650 cal",
style: TextStyle(
color: Colors.purple,
fontSize: 20,
),
),
],
),
],
),
// Icon(Icons.cup)
SizedBox(
width: 30,
),
Stack(
clipBehavior: Clip.none,
children: [
Image.network(
"https://media.istockphoto.com/photos/gold-cup-winner-on-white-background-isolated-3d-illustration-picture-id868334728?s=612x612",
height: 100,
width: 100,
),
// Icon(Icons.challenge)
Positioned(
bottom: 0,
right: -5,
child: Text("NFT", style: TextStyle(fontSize: 40, fontWeight: FontWeight.bold, color: Colors.blue[900]),))
],
)
],
),
const SizedBox(
height: 20,
),
Row(
children: const [
Text(
"Exercise",
style: TextStyle(
color: Colors.purple,
fontSize: 20,
),
),
],
),
Row(
children: const [
Text(
"15 Min 550cal , 5000Steps",
style: TextStyle(
color: Colors.purple,
fontSize: 20,
),
),
],
),
const SizedBox(
height: 20,
),
Expanded(
flex: 1,
child: GestureDetector(
child: //Icon(Icons.arrow_forward, color: textWhite),
// ButtonM("Unlock", Size, width * 0.75,
// Icons.arrow_forward, false, buttonblue),
const Text("data"),
onTap: () {
// _Unlockchallenge();
showDialog(
context: context,
builder: (context) {
return const Dialog(
child: Text("Button pressed"),
);
});
},
),
),
],
),
),
),
));
}
Upvotes: 1