How to achieve Listview design on flutter - flutter

I want to create a listview item design something like
Click here
and which I have tried so far is Click here
Here is my code
ListTile(
leading: ConstrainedBox(
constraints: BoxConstraints(
minWidth: 44,
minHeight: 44,
maxWidth: 64,
maxHeight: 64,
),
child: Image.network(catData[index]['icon'].toString(),
width: 150,
height: 150,
fit: BoxFit.cover,
headers: headersMap,
)
),
title: Padding(
padding: EdgeInsets.only(left: 10,bottom: 5, right: 10, top: 10),
child: Text(
getCategoryName(catData, index),
style: TextStyle(
fontWeight: FontWeight.w500,
fontSize: 20,
fontFamily: 'Mada-Medium',
letterSpacing: 0.25,
),
maxLines: 3,
overflow: TextOverflow.ellipsis,
),
),
subtitle: Padding(
padding: EdgeInsets.only(left: 10,bottom: 5, right: 10),
child: Text(
getText(catData[index]['catId'], subCatData),
style: TextStyle(
color: parseColor('##A2A2A2'),
letterSpacing: 0.25,
fontSize: 14,
fontFamily: 'Mada',
fontWeight: FontWeight.w500),
maxLines: 2,
overflow: TextOverflow.ellipsis,
)
),
)
The image portion is not setting properly on listTile title. Please help to create this design

Try this
class ListItem extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Container(
margin: const EdgeInsets.all(10.0),
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(color: Colors.grey),
borderRadius: BorderRadius.all(Radius.circular(20.0))),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
ClipRRect(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20.0), bottomLeft: Radius.circular(20.0)),
child: Image.asset(
'assets/images/nilesh.jpg',
fit: BoxFit.cover,
height: 120,
width: 100,
),
),
SizedBox(width: 20),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
// mainAxisAlignment: MainAxisAlignment.spaceAround,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
SizedBox(height: 20),
Text(
'Dummy Text',
style: TextStyle(color: Colors.black, fontWeight: FontWeight.bold),
),
SizedBox(height: 30),
Text(
'Dummy Text',
style: TextStyle(color: Colors.grey, fontWeight: FontWeight.normal),
),
],
))
],
),
);
}
}
OUTPUT

Related

How to set a image inside a container but also expand outside the container in flutter

I tried to code this all the way I can, but It's still can't move .
I tried to wrap this all in stack and I put the picture as second child, even if i adjust the container width, the image can't get out of the card, and the card padding is stuck there, I can't change anything, how do i fix that
here is the example design
here is my code
children: [
SizedBox(height: 37),
const Text("Hey Mishal,",
style: TextStyle(
fontSize: 26,
color: Color(0xFF0D1333),
fontWeight: FontWeight.bold,
)),
const Text("Find a course you want to learn",
style: TextStyle(
fontSize: 20,
color: Color(0xFF61688B),
height: 2,
)),
Container(
height: 150,
width: 357,
alignment: Alignment.topLeft,
margin: const EdgeInsets.symmetric(vertical: 30),
decoration: BoxDecoration(
color: kDeepBlueTheme,
borderRadius: BorderRadius.circular(15)),
child: Stack(
children: [
Card(
color: Colors.blueAccent,
child: Padding(
padding: const EdgeInsets.only(left: 15, top: 23),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// SizedBox(height: 30, width: 100,),
const Text('50% off',
style: TextStyle(
color: Colors.white,
fontSize: 27,
fontWeight: FontWeight.bold)),
const SizedBox(
height: 5,
),
const Text('For Any Courses',
style: TextStyle(
letterSpacing: 2,
color: Colors.white,
fontSize: 17,
fontWeight: FontWeight.w300)),
const SizedBox(
height: 6,
),
ElevatedButton(
//on pressed
onPressed: () async {},
//text to shoe in to the button
child: const Text('Join Now!',
style: TextStyle(color: kMainTheme)),
//style section code here
style: ButtonStyle(
elevation:
MaterialStateProperty.all<double>(0),
shape: MaterialStateProperty.all<
RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
)),
backgroundColor:
MaterialStateProperty.all<Color>(
Colors.black),
),
),
]),
),
),
Positioned(
bottom: 1,
left: 100,
child: Image.asset(
'assets/person_home.png',
height: 230,
),
)
],
),
),
],
and here is my result ,
how can I achieve that ?
Wrap your Stack with a SizedBox and give it a height greater than the height of Card, use media query heights to make it responsive.
SizedBox(
height: 220,
child: Stack(
alignment: Alignment.bottomCenter,
children: [
Container(
height: 200,
width: double.infinity,
padding: const EdgeInsets.all(8.0),
child: Card(
color: Colors.blueAccent,
child: Padding(
padding: const EdgeInsets.all(12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text('50% off',
style: TextStyle(
color: Colors.white,
fontSize: 25,
fontWeight: FontWeight.bold)),
const SizedBox(
height: 5,
),
const Text('For Any Courses',
style: TextStyle(
letterSpacing: 2,
color: Colors.white,
fontSize: 15,
fontWeight: FontWeight.w300)),
const SizedBox(
height: 6,
),
ElevatedButton(
//on pressed
onPressed: () async {},
//text to shoe in to the button
child: const Text('Join Now!',
style: TextStyle(color: Colors.white)),
//style section code here
style: ButtonStyle(
elevation: MaterialStateProperty.all<double>(0),
shape:
MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
)),
backgroundColor:
MaterialStateProperty.all<Color>(Colors.black),
),
),
]),
),
),
),
Positioned(
right: 0,
top: 0,
child: Image.network(
'https://i.ibb.co/7Kr3Vc2/Screenshot-2022-02-23-at-6-11-05-PM-removebg-preview.png',
fit: BoxFit.cover,
height: 210,
),
)
],
),
),
Try This Result Will be like in pic..
Stack(
children: [
Align(
alignment: Alignment.bottomCenter,
child: Container(
height: 400,
alignment: Alignment.bottomCenter,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: Colors.blueGrey,
),
),
),
Row(
children: [
const Padding(
padding:EdgeInsets.only(left: 20,right: 5),
child: Text('hello'),
),
Spacer(),
SizedBox(
height: 700,
child: Image.asset('assets/images/place_holder_avatar.png',fit: BoxFit.cover,),
),
],
),
],
)

flutter Problem : How to make upgrade section in bottom left in card

I want to make upgrade section in bottom left but I am not understatig how to do it.
I want to make upgrade section in bottom left but I am not understatig how to do it.
I want to make upgrade section in bottom left but I am not understatig how to do it.
this is my code.
import 'package:cwc/constants/constants.dart';
import 'package:flutter/material.dart';
class UpgradeMemberPackages extends StatefulWidget {
const UpgradeMemberPackages({Key? key}) : super(key: key);
#override
_UpgradeMemberPackagesState createState() => _UpgradeMemberPackagesState();
}
class _UpgradeMemberPackagesState extends State<UpgradeMemberPackages> {
#override
Widget build(BuildContext context) {
return Scaffold(
body: SingleChildScrollView(
child: Column(
children: [
Container(
width: double.infinity,
height: 160,
decoration: const BoxDecoration(
color: Color(0xffCCEAEF),
image: DecorationImage(
image: AssetImage('assets/ump.png'),
fit: BoxFit.cover,
),
),
),
Container(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12.0),
child: Column(
children: [
SizedBox(
height: 13,
),
Text(
"Your Membership Package",
style: TextStyle(
fontSize: tSize18,
fontWeight: FontWeight.w500),
),
Container(
padding: EdgeInsets.only(right: 15, left: 15),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
image: DecorationImage(
image: AssetImage("assets/green_card.png"),
fit: BoxFit.fill,
),
),
height: 147,
width: MediaQuery.of(context).size.width,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Starter Package",
style: TextStyle(
fontSize: tSize18,
fontWeight: FontWeight.w500),
),
SizedBox(
height: 6,
),
Text(
"Package for new members",
style: TextStyle(
fontSize: tSize14,
),
),
SizedBox(
height: 16,
),
Text(
"Free",
style: TextStyle(
fontSize: tSize27,
fontWeight: FontWeight.w500),
),
SizedBox(
height: 3,
),
Text(
"Valid Til: NONE",
style: TextStyle(
fontSize: tSize14,
),
),
],
),
),
Padding(
padding: EdgeInsets.only(bottom: 8),
child: Image.asset(
'assets/onaa.png',
height: 114,
width: 114,
),
),
],
)),
SizedBox(
height: 13,
),Text(
"Other Packages",
style: TextStyle(
fontSize: tSize18,
fontWeight: FontWeight.w500),
), SizedBox(
height: 13,
),
Container(
padding: EdgeInsets.only(right: 15, left: 15),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
image: DecorationImage(
image: AssetImage("assets/orange_card.png"),
fit: BoxFit.fill,
),
),
height: 147,
width: MediaQuery.of(context).size.width,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Explorer Package",
style: TextStyle(
fontSize: tSize18,
fontWeight: FontWeight.w500),
),
SizedBox(
height: 6,
),
Text(
"Best package for price",
style: TextStyle(
fontSize: tSize14,
),
),
SizedBox(
height: 16,
),
Text(
"\$99 USD",
style: TextStyle(
fontSize: tSize27,
fontWeight: FontWeight.w500),
),
],
),
),
Padding(
padding: EdgeInsets.only(bottom: 8),
child: Image.asset(
'assets/onbb.png',
height: 114,
width: 114,
),
),
],
)),
SizedBox(
height: 10,
),
Container(
padding: EdgeInsets.only(right: 15, left: 15),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
image: DecorationImage(
image: AssetImage("assets/purple_card.png"),
fit: BoxFit.fill,
),
),
height: 147,
width: MediaQuery.of(context).size.width,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Champion Package",
style: TextStyle(
fontSize: tSize18,
fontWeight: FontWeight.w500),
),
SizedBox(
height: 6,
),
Text(
"VIP Package",
style: TextStyle(
fontSize: tSize14,
),
),
SizedBox(
height: 16,
),
Text(
"\$199 USD",
style: TextStyle(
fontSize: tSize27,
fontWeight: FontWeight.w500),
),
],
),
),
Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Image.asset(
'assets/oncc.png',
height: 114,
width: 114,
),
),
],
))
],
),
),
),
],
),
),
);
}
}
In Actuall I want to make like this.
But It becoming like this. I want upgrade section which is in bottom left.
Try below code hope its help to you. You used Stack widget for that
Refer Stack here
Refer Positioned here
Stack(
children: [
Container(
padding: EdgeInsets.only(right: 15, left: 15),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
image: DecorationImage(
image: NetworkImage(
"https://miro.medium.com/max/1400/1*-6WdIcd88w3pfphHOYln3Q.png"),
fit: BoxFit.fill,
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: Column(
children: [
Text(
"Explorer Package",
style: TextStyle(
color: Colors.white,
fontSize: 18,
fontWeight: FontWeight.w500),
),
SizedBox(
height: 6,
),
Text(
"Best package for price",
style: TextStyle(
fontSize: 14,
),
),
SizedBox(
height: 16,
),
Text(
"\$99 USD",
style: TextStyle(
color: Colors.white,
fontSize: 27,
fontWeight: FontWeight.w500),
),
],
),
),
Padding(
padding: EdgeInsets.only(bottom: 8),
child: Image.network(
'https://miro.medium.com/max/1400/1*-6WdIcd88w3pfphHOYln3Q.png',
height: 114,
width: 114,
),
),
],
),
),
Positioned(
bottom: 0,
child: Container(
decoration: BoxDecoration(
color: Colors.green,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(8),
topRight: Radius.circular(20),
),
),
width: 200,
height: 38,
child: Center(
child: Text(
'Upgrade Now',
style: TextStyle(
color: Colors.white,
fontSize: 20,
),
),
),
),
),
],
),
Your result screen->
By using Stack widget, I implemented what you want to.
Because there is no image resource, screenshot is not same as you uploaded.
Wrap Row Widget with Stack widget in Container
Moved padding property because of 'upgrade now' widget location
Added 'upgrade now' widget
Container(
decoration: BoxDecoration(
color: Colors.orange,
borderRadius: BorderRadius.circular(10),
image: DecorationImage(
image: AssetImage("assets/orange_card.png"),
fit: BoxFit.fill,
),
),
height: 147,
width: MediaQuery.of(context).size.width,
child: Stack(
children: [
Padding(
padding: EdgeInsets.only(right: 15, left: 15),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
"Explorer Package",
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500),
),
SizedBox(
height: 6,
),
Text(
"Best package for price",
style: TextStyle(
fontSize: 10,
),
),
SizedBox(
height: 16,
),
Text(
"\$99 USD",
style: TextStyle(
fontSize: 23,
fontWeight: FontWeight.w500),
),
],
),
),
Padding(
padding: EdgeInsets.only(bottom: 8),
child: Image.asset(
'assets/onbb.png',
height: 114,
width: 114,
),
),
],
),
),
Align(
alignment: Alignment.bottomLeft,
child: Container(
decoration: BoxDecoration(
color: Colors.green,
borderRadius: BorderRadius.only(
topRight: Radius.circular(10),
bottomLeft: Radius.circular(10),
),
),
height: 25,
width: 150,
child: Center(
child: Text(
'Upgrade Now',
style: TextStyle(
color: Colors.white,
fontSize: 9,
),
),
),
),
),
],
),
),

Can not read properties of null, ListView.Builder

I have this problem in flutter, I want to fetch API with listview builder but they show this error after 2 seconds i got my data
//listviewBuilder
return Container(
height: 380,
child: ListView.builder(
padding: EdgeInsets.symmetric(vertical: 8.0),
scrollDirection: Axis.horizontal,
itemCount: listtest.length,
itemBuilder: (context, index) {
return index == listtest[index]
? SizedBox(width: 10)
: Card(
margin: EdgeInsets.only(right: 8.0),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(10.0))),
child: Container(
height: 400,
width: 370,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10.0),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
GestureDetector(
onTap: () {
Navigator.pushNamed(context, 'HouseDetails');
},
child: Container(
height: 260,
decoration: BoxDecoration(
image: DecorationImage(
fit: BoxFit.fill,
image: AssetImage(images[index])),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10.0),
topRight: Radius.circular(10.0),
)),
),
),
Container(
padding: EdgeInsets.all(8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
listtest[index]['name'].toString(),
style: kh4,
),
SizedBox(
height: 2,
),
Text(
addresses[index],
style:
TextStyle(color: Colors.grey, fontSize: 10),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
SizedBox(
height: 2,
),
IntrinsicHeight(
child: Row(
children: [
Text(
'3 ',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 12),
),
Text(
'bds ',
style: TextStyle(fontSize: 12),
),
VerticalDivider(
width: 1,
color: Colors.grey,
),
Text(
' 5 ',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 12),
),
Text(
'baths ',
style: TextStyle(fontSize: 12),
),
VerticalDivider(
width: 1,
color: Colors.grey,
),
Text(
' 1750 ',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 12),
),
Text(
'sqft',
style: TextStyle(fontSize: 12),
),
],
),
),
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
SizedBox(
height: 7,
),
Text(
'Starting Price',
style: TextStyle(
fontSize: 12,
),
),
Text(
prices[index],
style: TextStyle(
color: primaryColor,
fontWeight: FontWeight.bold,
fontSize: 11),
)
],
),
Spacer(),
HeartContainer(index)
],
)
],
),
)
],
),
),
);
}),
);
It seems to me listtest can be null. You should make sure you take that into account.
Try replacing listtest.length with listtest?.length ?? 0
and
listtest[index] with listtest?.elementAt(index)

Exception type Future(void) in not subtype of Future<AnimationController>

the code below performs the creation of a layout in flutter, to create the layout I must first make sure that the set function is executed to make it use future builder but when I run the code I have the following error.
It tells me that the following error is present, future is not a subtype of future ,
theoretically both derive from object so there shouldn't be inheritance problems on dart, what is this due to?
Error:
type Future(void) in not subtype of Future
Flutter Code:
import ...
double latitudine=0;
Future<void> setValori() async {
latitudine=await Gps.getLatitudine();
print("Latitudine: "+latitudine.toString());
print("\n \n Sono dentro set valori \n \n");
}
class MediterranesnDietView extends StatelessWidget {
final AnimationController animationController;
final Animation animation;
const MediterranesnDietView(
{Key key, this.animationController, this.animation})
: super(key: key);
#override
Widget build(BuildContext context) {
return FutureBuilder<AnimatedBuilder>(
future: setValori(),
builder: (BuildContext context, AsyncSnapshot<AnimatedBuilder> snapshot) {
return AnimatedBuilder(
animation: animationController,
builder: (BuildContext context, Widget child) {
return FadeTransition(
opacity: animation,
child: new Transform(
transform: new Matrix4.translationValues(
0.0, 30 * (1.0 - animation.value), 0.0),
child: Padding(
padding: const EdgeInsets.only(
left: 24, right: 24, top: 16, bottom: 18),
child: Container(
decoration: BoxDecoration(
color: FintnessAppTheme.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8.0),
bottomLeft: Radius.circular(8.0),
bottomRight: Radius.circular(8.0),
topRight: Radius.circular(68.0)),
boxShadow: <BoxShadow>[
BoxShadow(
color: FintnessAppTheme.grey.withOpacity(0.2),
offset: Offset(1.1, 1.1),
blurRadius: 10.0),
],
),
child: Column(
children: <Widget>[
Padding(
padding:
const EdgeInsets.only(top: 16, left: 16, right: 16),
child: Row(
children: <Widget>[
Expanded(
child: Padding(
padding: const EdgeInsets.only(
left: 8, right: 8, top: 4),
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Container(
height: 48,
width: 2,
decoration: BoxDecoration(
color: HexColor('#87A0E5')
.withOpacity(0.5),
borderRadius: BorderRadius.all(
Radius.circular(4.0)),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
left: 4, bottom: 2),
child: Text(
'Latitudine',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily:
FintnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 16,
letterSpacing: -0.1,
color: FintnessAppTheme.grey
.withOpacity(0.5),
),
),
),
Row(
mainAxisAlignment:
MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.end,
children: <Widget>[
SizedBox(
width: 28,
height: 28,
child: Image.asset(
"assets/Home/eaten.png"),
),
Padding(
padding:
const EdgeInsets.only(
left: 4, bottom: 3),
child: Text(
'${(latitudine * animation.value).toInt()}',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily:
FintnessAppTheme
.fontName,
fontWeight:
FontWeight.w600,
fontSize: 16,
color: FintnessAppTheme
.darkerText,
),
),
),
Padding(
padding:
const EdgeInsets.only(
left: 4, bottom: 3),
child: Text(
'',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily:
FintnessAppTheme
.fontName,
fontWeight:
FontWeight.w600,
fontSize: 12,
letterSpacing: -0.2,
color: FintnessAppTheme
.grey
.withOpacity(0.5),
),
),
),
],
)
],
),
)
],
),
SizedBox(
height: 8,
),
Row(
children: <Widget>[
Container(
height: 48,
width: 2,
decoration: BoxDecoration(
color: HexColor('#F56E98')
.withOpacity(0.5),
borderRadius: BorderRadius.all(
Radius.circular(4.0)),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
left: 4, bottom: 2),
child: Text(
'Longitudine',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily:
FintnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 16,
letterSpacing: -0.1,
color: FintnessAppTheme.grey
.withOpacity(0.5),
),
),
),
Row(
mainAxisAlignment:
MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.end,
children: <Widget>[
SizedBox(
width: 28,
height: 28,
child: Image.asset(
"assets/Home/burned.png"),
),
Padding(
padding:
const EdgeInsets.only(
left: 4, bottom: 3),
child: Text(
'${(102 * animation.value).toInt()}',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily:
FintnessAppTheme
.fontName,
fontWeight:
FontWeight.w600,
fontSize: 16,
color: FintnessAppTheme
.darkerText,
),
),
),
Padding(
padding:
const EdgeInsets.only(
left: 8, bottom: 3),
child: Text(
'Kcal',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily:
FintnessAppTheme
.fontName,
fontWeight:
FontWeight.w600,
fontSize: 12,
letterSpacing: -0.2,
color: FintnessAppTheme
.grey
.withOpacity(0.5),
),
),
),
],
)
],
),
)
],
)
],
),
),
),
Padding(
padding: const EdgeInsets.only(right: 16),
child: Center(
child: Stack(
overflow: Overflow.visible,
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
width: 100,
height: 100,
decoration: BoxDecoration(
color: FintnessAppTheme.white,
borderRadius: BorderRadius.all(
Radius.circular(100.0),
),
border: new Border.all(
width: 4,
color: FintnessAppTheme
.nearlyDarkBlue
.withOpacity(0.2)),
),
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
Text(
'${(1503 * animation.value).toInt()}',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily:
FintnessAppTheme.fontName,
fontWeight: FontWeight.normal,
fontSize: 24,
letterSpacing: 0.0,
color: FintnessAppTheme
.nearlyDarkBlue,
),
),
Text(
'Kcal left',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily:
FintnessAppTheme.fontName,
fontWeight: FontWeight.bold,
fontSize: 12,
letterSpacing: 0.0,
color: FintnessAppTheme.grey
.withOpacity(0.5),
),
),
],
),
),
),
Padding(
padding: const EdgeInsets.all(4.0),
child: CustomPaint(
painter: CurvePainter(
colors: [
FintnessAppTheme.nearlyDarkBlue,
HexColor("#8A98E8"),
HexColor("#8A98E8")
],
angle: 140 +
(360 - 140) *
(1.0 - animation.value)),
child: SizedBox(
width: 108,
height: 108,
),
),
)
],
),
),
)
],
),
),
Padding(
padding: const EdgeInsets.only(
left: 24, right: 24, top: 8, bottom: 8),
child: Container(
height: 2,
decoration: BoxDecoration(
color: FintnessAppTheme.background,
borderRadius: BorderRadius.all(Radius.circular(4.0)),
),
),
),
Padding(
padding: const EdgeInsets.only(
left: 24, right: 24, top: 8, bottom: 16),
child: Row(
children: <Widget>[
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'Carbs',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FintnessAppTheme.fontName,
fontWeight: FontWeight.w500,
fontSize: 16,
letterSpacing: -0.2,
color: FintnessAppTheme.darkText,
),
),
Padding(
padding: const EdgeInsets.only(top: 4),
child: Container(
height: 4,
width: 70,
decoration: BoxDecoration(
color:
HexColor('#87A0E5').withOpacity(0.2),
borderRadius: BorderRadius.all(
Radius.circular(4.0)),
),
child: Row(
children: <Widget>[
Container(
width: ((70 / 1.2) * animation.value),
height: 4,
decoration: BoxDecoration(
gradient: LinearGradient(colors: [
HexColor('#87A0E5'),
HexColor('#87A0E5')
.withOpacity(0.5),
]),
borderRadius: BorderRadius.all(
Radius.circular(4.0)),
),
)
],
),
),
),
Padding(
padding: const EdgeInsets.only(top: 6),
child: Text(
'12g left',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FintnessAppTheme.fontName,
fontWeight: FontWeight.w600,
fontSize: 12,
color: FintnessAppTheme.grey
.withOpacity(0.5),
),
),
),
],
),
),
...
),
),
),
);
},
);
});
}
}
The error indicates, that the Future you are giving the FutureBuilder does not match the Builders generic type.
You defined FutureBuilder<AnimatedBuilder> with the generic parameter AnimatedBuilder and it expects a Future<AnimatedBuilder>. The function setValori() is returning a Future<void>.
If you change your FutureBuilder<AnimatedBuilder> to FutureBuilder<void> and change AsyncSnapshot<AnimatedBuilder> to AsyncSnapshot<void>, you resolved the issues.
As your method setValori() returns a Future of type void you need to change the following line:
return FutureBuilder<AnimatedBuilder>
this should be
return FutureBuilder<void>

How to achieve this in flutter?

I want this result:
I am unable to get the background text to look how I want.
I have tried overflow.clip and other overflows. I am getting overflow error if I try to do that.
My current code produces this:
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
decoration: BoxDecoration(
color: Color(0xFF86C232),
shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(15.0)),
height: 130,
width: 250,
//color: Color(0xFF86c232),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text('Students',
style: TextStyle(fontSize: 28)),
Text('256',
style: TextStyle(
fontSize: 28,
fontWeight: FontWeight.bold)),
Text(
'256',
style: TextStyle(
fontSize: 154, fontWeight: FontWeight.bold),
overflow: TextOverflow.clip,
softWrap: false,
maxLines: 1,
)
],
),
),
),
I'd rather use CustomPainter, but as a quick solution this works:
Container(
height: 200,
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.red,
),
child: Stack(
overflow: Overflow.clip,
fit: StackFit.expand,
alignment: Alignment.center,
children: <Widget>[
Positioned(
child: Text(
'test',
style: TextStyle(fontSize: 120, color: Colors.black.withOpacity(0.2)),
),
bottom: -60,
),
Center(
child: Text('test', style: TextStyle(fontSize: 40))
),
],
),
)