Related
I want to display the number of each item which is inside the list to a Card, I found some example which they said you should do it with a for() loop, and i did just that but the number isn't incrementing at all can someone show me what I'm doing wrong?
My code:
child: ScrollablePositionedList.builder(
itemScrollController: itemController,
itemCount: selectedChallenge.contestantsList.length,
shrinkWrap: true,
itemBuilder: (context, index) {
final sortedList = selectedChallenge.contestantsList
..sort((itemOne, itemTwo) =>
itemTwo.points.compareTo(itemOne.points));
final data = sortedList[index];
// My for loop
for (var i = 0;
i < selectedChallenge.contestantsList.length;
i++,) {
return Card(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Row(
children: [
Padding(
padding: const EdgeInsets.all(10.0),
child: Text('${i}'),
),
SizedBox(
height: 35,
width: 35,
child: CachedNetworkImage(
imageUrl: data.avatar,
),
),
SizedBox(
width: 12,
),
Text(
data.firstName + ' ' + data.lastName,
),
],
),
Text(data.points.toString()),
],
),
);
}
},
),
What I got:
What I want:
]
Use the index of your builder and remove the for loop
ScrollablePositionedList.builder(
itemScrollController: itemController,
itemCount: selectedChallenge.contestantsList.length,
shrinkWrap: true,
itemBuilder: (context, index) {
final sortedList = selectedChallenge.contestantsList
..sort((itemOne, itemTwo) =>
itemTwo.points.compareTo(itemOne.points));
final data = sortedList[index];
return Card(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Row(
children: [
Padding(
padding: const EdgeInsets.all(10.0),
child: Text('${index + 1}'),
),
// rest of the code
Another suggestion is to sort the list first before building it.
// sort the list first in a method or something
final sortedList = selectedChallenge.contestantsList
..sort((itemOne, itemTwo) =>
itemTwo.points.compareTo(itemOne.points));
// build it
ScrollablePositionedList.builder(
itemScrollController: itemController,
itemCount: sortedList.length,
Try below code hope its help to you.
declare one int variable
int index = 1;
Your Widget.
Text(
(index + 1).toString(),
),
Whole Widget.
SingleChildScrollView(
child: Column(
children: <Widget>[
Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsetsDirectional.only(
top: 18, bottom: 18),
child: Text("Powered By:",
style: new TextStyle(fontSize: 18.0)),
)
],
),
ListView.builder(
padding: EdgeInsets.zero,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: 10,
itemBuilder: (BuildContext context, int index) {
return Card(
margin: EdgeInsets.zero,
elevation: 0.4,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(0),
),
child: Container(
child: ListTile(
leading: Expanded(
child: Text(
(index + 1).toString(),
),
),
title: Text(
"Coconut Oil",
style: TextStyle(
color: Colors.black87,
fontWeight: FontWeight.bold),
),
subtitle: Row(
children: <Widget>[
Icon(Icons.linear_scale,
color: Colors.greenAccent),
Text("Go Green!",
style: TextStyle(
color: Colors.black87))
],
),
)));
})
],
),
),
Your result screen like->
I have a doubt about how I suppose to implement a list of markers? Or other things? Like, separate this code into a different file to solve this problem. I'm using Flutter Map on my app.
Here's my code with only two markers:
Code
MarkerLayerOptions(
markers: [
Marker(
width: 96,
height: 96,
point: mainPoint,
builder: (ctx) => Container(
child: Column(
children: [
Text(
'IFCE Campus Acaraú',
textAlign: TextAlign.center,
style: TextStyle(color: Colors.pink.shade700),
),
IconButton(
icon: Icon(Icons.location_on),
color: Colors.pink.shade700,
onPressed: () {
showModalBottomSheet(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20.0),
),
context: context,
backgroundColor: Colors.transparent,
builder: (context) => BackdropFilter(
filter: ImageFilter.blur(sigmaX: 5, sigmaY: 5),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20),
topRight: Radius.circular(20)),
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: <Color>[
Color(0XFFFAEBE8),
Colors.green.shade100
])),
height: 480,
width: MediaQuery.of(context).size.width,
child: SingleChildScrollView(
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Container(
margin: EdgeInsets.only(
bottom: 1, top: 4),
height: 300,
width: 300,
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage(
'https://images.even3.com.br/wtw3LCAjTLmxbRQwr6KI2H-FIKw=/1300x536/smart/even3.blob.core.windows.net/banner/fachadavalendo.a060ab6b7f8d4bf2a52c.jpg'),
fit: BoxFit.cover,
),
borderRadius:
BorderRadius.circular(20),
),
),
SizedBox(
height: 10,
),
Text(
'IFCE Campus Acaraú \nlaboratório do Ecomangueando',
textAlign: TextAlign.center,
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.green,
fontSize: 15),
),
SizedBox(
height: 10,
),
Text(
'Alguma descrição sobre',
textAlign: TextAlign.center,
style: TextStyle(
fontWeight: FontWeight.normal,
color: Colors.green.shade300),
),
SizedBox(
height: 10,
),
Container(
margin: EdgeInsets.only(
bottom: 4, top: 4),
height: 300,
width: 300,
decoration: BoxDecoration(
color: Colors.black,
borderRadius:
BorderRadius.circular(20),
),
),
],
),
),
)
],
),
),
);
},
),
],
)),
),
Marker(
width: 96,
height: 96,
point: LatLng(-9.83284607465564, -35.90767696029337),
builder: (ctx) => Container(
child: Column(
children: [
Text(
'Reserva Ecológica \ndos Manguezais \nda Lagoa do Roteiro',
textAlign: TextAlign.center,
style: TextStyle(color: Colors.pink.shade700),
),
IconButton(
icon: Icon(Icons.location_on),
color: Colors.pink.shade700,
onPressed: () {
showModalBottomSheet(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20.0),
),
context: context,
backgroundColor: Colors.transparent,
builder: (context) => BackdropFilter(
filter: ImageFilter.blur(sigmaX: 5, sigmaY: 5),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20),
topRight: Radius.circular(20)),
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: <Color>[
Color(0XFFFAEBE8),
Colors.green.shade100
])),
height: 480,
width: MediaQuery.of(context).size.width,
child: SingleChildScrollView(
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Container(
margin: EdgeInsets.only(
bottom: 1, top: 4),
height: 300,
width: 300,
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage(
'https://images.even3.com.br/wtw3LCAjTLmxbRQwr6KI2H-FIKw=/1300x536/smart/even3.blob.core.windows.net/banner/fachadavalendo.a060ab6b7f8d4bf2a52c.jpg'),
fit: BoxFit.cover,
),
borderRadius:
BorderRadius.circular(20),
),
),
SizedBox(
height: 10,
),
Text(
'IFCE Campus Acaraú \nlaboratório do Ecomangueando',
textAlign: TextAlign.center,
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.green,
fontSize: 15),
),
SizedBox(
height: 10,
),
Text(
'Alguma descrição sobre',
textAlign: TextAlign.center,
style: TextStyle(
fontWeight: FontWeight.normal,
color: Colors.green.shade300),
),
SizedBox(
height: 10,
),
Container(
margin: EdgeInsets.only(
bottom: 4, top: 4),
height: 300,
width: 300,
decoration: BoxDecoration(
color: Colors.black,
borderRadius:
BorderRadius.circular(20),
),
),
],
),
),
)
],
),
),
);
},
),
],
),
),
),
],
),
See the problem? I have to make almost 20 markers. And only 2 of them is this big. Besides in some point even myself will be confused. What the solution you guys recommend? Thanks in advance who answer me.
It has some good features that I was looking for, and works with my code
I'm trying to make ToDo app, and I have problem with slidable widget. I'm putting Slidable inside the ListTile element, and it appears to overlay the parent. Actually, if I specify height of the parent list, it doesn't happen, but I can't specify the height of parent list, because it needs to be set automatically as new element is added to the list, this is why I use shrinkWrap property.
EDIT: I found package that does exactly what I need. It has some iOS-like slide features, and even some animations.
https://pub.dev/packages/flutter_swipe_action_cell
Widget build(BuildContext context) {
return Column(
children: [
Container(
margin: EdgeInsets.only(bottom: 20),
child: Container(
child: ListView.builder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: this.widget.listNotes.length,
itemBuilder: (context, index) {
var content = this.widget.listNotes[index];
return Column(
children: [
Align(
alignment: Alignment.centerLeft,
child: ListTile(
title: Container(
child: Slidable(
controller: slidableController,
actionPane: SlidableStrechActionPane(),
actionExtentRatio: 0.4,
secondaryActions: <Widget>[
SlideAction(
color: Colors.red,
child: Text(
'Delete',
style: TextStyle(
fontSize: 15, color: Colors.white),
maxLines: 1,
),
onTap: () => deleteNote(index),
),
],
child: Row(
children: [
Container(
child: Transform.scale(
scale: 1.7,
child: Radio(
toggleable: true,
value: '${index}' + 'ok',
groupValue: groupVal,
onChanged: (value) {
setState(() {
groupVal = value;
});
},
activeColor: Color(0xffFFBD11),
),
),
),
InkWell(
onTap: () {
print('object');
},
child: Container(
width: 230,
padding:
EdgeInsets.fromLTRB(0, 10, 12, 12),
margin: EdgeInsets.only(left: 5),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: Color(0xFFBABABA),
width: 0.5))),
child: Text(
content.note,
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w300,
fontSize: 18),
),
),
),
],
),
),
),
),
),
],
);
}),
),
),
Hi #XRSIL your code is wrong, because the slidable widget must be the widget that contains the ListTile, like this example:
ListView.builder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: this.widget.listNotes.length,
itemBuilder: (context, index) {
return Slidable(
actionPane: SlidableDrawerActionPane(),
child: Container(
child: ListTile(title: Text('Title'),
),
));
}
)
family of programmers. I'm new to programming, I'm having a hard time transferring data from a screen to a list, where the user can review the messages sent. Sorry for this one with a silly question like that, but I already tried it in the library, videos and etc. But I did not find the solution, please, could someone help me with this? Thanks! (I've been stuck on this issue for days).
My code:
import 'dart:io';
import 'package:flutter/services.dart';
import 'package:animated_text_kit/animated_text_kit.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:animated_button/animated_button.dart';
import 'package:giffy_dialog/giffy_dialog.dart';
import 'package:mailer/mailer.dart';
import 'package:mailer/smtp_server/gmail.dart';
import 'package:ouvidoria_mvl/main.dart';
// ignore: must_be_immutable
class PaginadeBoasVindasAN extends StatelessWidget {
String _localAn;
String _problemaAn;
File _imagemAn;
File _imagemGaleriaAn;
PaginadeBoasVindasAN(
this._localAn,
this._problemaAn,
this._imagemAn,
this._imagemGaleriaAn,
);
final _formKey = GlobalKey<FormState>();
// Aqui vamos criar o e-mail - smtp
enviarMensagem() async {
String username = '#gmail.com';
String password = '4#';
final smtpServer = gmail(username, password);
// Use the SmtpServer class to configure an SMTP server:
// final smtpServer = SmtpServer('smtp.domain.com');
// See the named arguments of SmtpServer for further configuration
// options.
// Create our message.
final message = Message()
..from = Address('', '')
..recipients.add('#gmail.com')
..ccRecipients.addAll(['destCc1#gmail.com', 'destCc1#gmail.com'])
..bccRecipients.add(Address('destCc1#gmail.com'))
..subject = '$_localAn :: ${DateTime.now()}'
..text = 'LOCAL DA OCORRÊNCIA: $_localAn,n\ OCORRÊNCIA: $_problemaAn';
if ((_imagemAn != null) && (_imagemAn != ""))
message.attachments.add(FileAttachment(_imagemAn,));
if ((_imagemGaleriaAn!= null) && (_imagemGaleriaAn!= ""))
message.attachments.add(FileAttachment(_imagemGaleriaAn,));
try {
final sendReport = await send(message, smtpServer);
print('Mensagem enviada: ' + sendReport.toString());
} on MailerException catch (e) {
print('Mensagem não enviada.');
for (var p in e.problems) {
print('Problema: ${p.code}: ${p.msg}');
}
}
var connection = PersistentConnection(smtpServer);
await connection.send(message);
await connection.close();
}
// HERE THE APP CONFIGURATION IS ENDED
// The Function below blocks the screen rotation, thus allowing the app to stay in vertical mode
void blockgiro() {
SystemChrome.setPreferredOrientations(
[DeviceOrientation.portraitDown, DeviceOrientation.portraitUp]);
}
#override
Widget build(BuildContext context) {
blockgiro();
return Stack(children: <Widget>[
Scaffold(
backgroundColor: Colors.white,
body: SingleChildScrollView(
padding: EdgeInsets.only(bottom: 20),
child: Container(
margin: EdgeInsets.all(10),
color: Colors.transparent,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
margin: EdgeInsets.only(
left: 1,
bottom: 10,
top: 10,
),
padding: EdgeInsets.all(10),
height: 200,
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
blurRadius: 0,
color: Colors.white,
offset: Offset(0, 0))
],
borderRadius: BorderRadius.circular(13),
color: Colors.white),
child:
Image.asset("Assets/image/enviando-loading.gif")),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
padding: EdgeInsets.only(
bottom: 30, right: 1, left: 1, top: 20),
),
Container(
margin: EdgeInsets.only(
left: 1,
bottom: 10,
top: 5,
),
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
blurRadius: 2,
color: Colors.black54,
offset: Offset(1, 1))
],
borderRadius: BorderRadius.circular(13),
color: Colors.white),
child: Align(
alignment: Alignment.topLeft,
child: SizedBox(
width: 250.0,
child: TypewriterAnimatedTextKit(
pause: Duration(minutes: 10),
speed: Duration(milliseconds: 100),
onTap: () {
print("Tap Event");
},
text: ['The location is this: $_localAn'],
textStyle: TextStyle(
color: Colors.black,
fontSize: 20.0,
fontFamily: "Agne"),
textAlign: TextAlign.start,
),
),
),
),
Container(
margin: EdgeInsets.only(
left: 1,
bottom: 10,
top: 10,
),
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
blurRadius: 4,
color: Colors.black54,
offset: Offset(2, 2))
],
borderRadius: BorderRadius.circular(13),
color: Colors.white),
child: Align(
alignment: Alignment.topLeft,
child: SizedBox(
width: 1000.0,
child: TypewriterAnimatedTextKit(
pause: Duration(minutes: 10),
onTap: () {
print("Tap Event");
},
text: [
'Its occurrence: $_problemaAn',
],
textStyle: TextStyle(
color: Colors.black,
fontSize: 20.0,
fontFamily: "Agne"),
textAlign: TextAlign.justify,
curve: Curves.linear),
),
)),
Container(
margin: EdgeInsets.all(10),
padding: EdgeInsets.all(10),
child: _imagemAn != null
? Image.file(
_imagemAn,
fit: BoxFit.scaleDown,
)
: Center(
child: Text(
'',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w400),
),
),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
blurRadius: 1,
color: Colors.transparent,
offset: Offset(1, 1))
],
borderRadius: BorderRadius.circular(30),
color: Colors.transparent),
),Container(
margin: EdgeInsets.all(10),
padding: EdgeInsets.all(10),
child: _imagemGaleriaAn != null
? Image.file(
_imagemGaleriaAn,
fit: BoxFit.scaleDown,
)
: Center(
child: Text(
'Capture a photo',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w400),
),
),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
blurRadius: 1,
color: Colors.transparent,
offset: Offset(1, 1))
],
borderRadius: BorderRadius.circular(30),
color: Colors.transparent),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TypewriterAnimatedTextKit(
pause: Duration(minutes: 10),
onTap: () {
print("Select below");
},
text: [
'Need to edit your message?',
],
textStyle: TextStyle(
fontWeight: FontWeight.w600,
color: Colors.lightBlueAccent,
fontSize: 20.0,
fontFamily: "Agne"),
textAlign: TextAlign.center,
curve: Curves.linear),
],
),
//INICIO DOS BOTOES SIM E NAO
Container(
padding: EdgeInsets.only(bottom: 50),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
margin: EdgeInsets.only(
bottom: 2, top: 2, right: 55),
alignment: Alignment.centerLeft,
child: AnimatedButton(
shape: BoxShape.rectangle,
child: Text(
'Edit',
style: TextStyle(
fontSize: 15,
color: Colors.white,
fontWeight: FontWeight.w500,
),
),
onPressed: () {
Navigator.pop(context);
},
width: 70,
height: 40,
color: Theme.of(context).primaryColor,
shadowDegree: ShadowDegree.dark,
enabled: true,
),
),
//ACIMA SIM, ABAIXO NÃO
Container(
margin: EdgeInsets.only(
bottom: 2, top: 2, left: 55),
alignment: Alignment.centerRight,
child: AnimatedButton(
child: const Text(
'Send',
style: TextStyle(
fontSize: 19,
color: Colors.white,
fontWeight: FontWeight.w500,
),
),
onPressed: () {
enviarMensagem();
showDialog(
context: context,
builder: (_) => AssetGiffyDialog(
image: Image.asset(
'Assets/image/Correta.gif'),
title: Text(
'Success',
style: TextStyle(
fontSize: 22.0,
fontWeight:
FontWeight.w600),
),
description: Text(
'Hi, we received your message',
style: TextStyle(),
),
entryAnimation:
EntryAnimation.BOTTOM_RIGHT,
onlyCancelButton: false,
onOkButtonPressed: () async {
final result =
await Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
splashScreen()));
},
onlyOkButton: true,
));
},
width: 70,
height: 40,
color: Theme.of(context).primaryColor,
shadowDegree: ShadowDegree.dark,
enabled: true,
),
)
],
),
],
),
Container(
padding: EdgeInsets.only(bottom: 50),
),
]))),
)
]);
}
}
I created 2 classes in dart, to use in flutter, the first is used to a list and a profile page for a trainer, the second class is for the training.
if I want to show the instructor's training list in his profilepage what can I do?
for example the train "Ciccio" has only a Traing and i want see only that traing.
class IstruttoreClasse{
int idIstruttore;
String nome;
List allenamento;
IstruttoreClasse({
this.idIstruttore,this.nome, this.allenamento});
}
List<IstruttoreClasse> istruttori =[
IstruttoreClasse(
idIstruttore: 1,
nome: "Ciccio", ),
IstruttoreClasse(
idIstruttore: 2,
nome: "Valeria",
),
];
class Traing extends IstruttoreClasse{
String nomeTraing;
int idTraing ,numEsercizi, calorie, minuti, numSet ;
Traing({this.calorie,this.idTraing,this.minuti,this.nomeTraing,this.numEsercizi, this.numSet, int idIstruttore, String nome});
}
List<Traing> allenamentoList =[
Traing(
idIstruttore: 1,
nome: "Ciccio",
idTraing: 1,
calorie: 200,
minuti: 45,
numEsercizi: 12,
numSet: 2,
nomeTraing: "Totalbody"
),
Traing(
idIstruttore: 2,
nome: "Valeria",
idTraing: 2,
calorie: 200,
minuti: 45,
numEsercizi: 12,
numSet: 2,
nomeTraing: "Zumba"
),
];
this is the profile page code
import 'package:flutter/material.dart';
import 'package:tesiapp/src/models/classeIstruttore.dart';
import 'package:tesiapp/theme/costanti.dart';
class ProfiloTrainer extends StatelessWidget {
final IstruttoreClasse istruttoreClasse;
const ProfiloTrainer({Key key, this.istruttoreClasse}) : super(key: key);
#override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return Scaffold(
backgroundColor: Colors.grey,
body: SafeArea(
child: Stack(
children: <Widget>[
Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [Colors.grey[300], Colors.grey[700]],
),
),
),
Positioned(
top: 0,
left: 0,
right: 0,
child: Column(
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
height: size.height * 0.06,
width: size.width * 1,
color: Colors.transparent,
child: Row(
children: [
InkWell(
onTap: () {
Navigator.pop(context);
},
child: Container(
child: Icon(Icons.arrow_back),
),
),
],
),
),
),
Padding(
padding:
const EdgeInsets.only(right: 8.0, left: 8.0, top: 45.0),
child: Container(
height: size.height * 0.3,
width: size.width * 1,
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30),
topRight: Radius.circular(30),
bottomLeft: Radius.circular(30),
bottomRight: Radius.circular(30),
),
color: Colors.transparent,
),
// color: Color.fromRGBO(255, 255, 255, 0.4)),
child: SingleChildScrollView(
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(istruttoreClasse.nome,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 30)),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text("Guarino",
style: TextStyle(fontSize: 30)),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"lore ipsum bio del trainer chi sono io e cosa faccio dove lavoro"),
)
],
),
),
),
],
),
),
),
),
Padding(
padding:
const EdgeInsets.only(top: 10.0, left: 8.0, right: 8.0),
child: Container(
height: size.height * 0.45,
width: size.width * 1,
decoration: BoxDecoration(
color: Colors.transparent,
// color: Color.fromRGBO(255, 255, 255, 0.4),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(25),
topRight: Radius.circular(25),
bottomLeft: Radius.circular(25),
bottomRight: Radius.circular(25),
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Text("Allenemanti",
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 20)),
),
Expanded(
child: ListView.builder(
itemCount: allenamentoList.length,
itemBuilder: (context, index) =>
CasellaAllenamenti(size: size),
),
),
],
),
),
)
],
),
),
],
),
),
);
}
}
class CasellaAllenamenti extends StatelessWidget {
const CasellaAllenamenti({
Key key,
#required this.size,
}) : super(key: key);
final Size size;
#override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Container(
decoration: BoxDecoration(
color: Colors.transparent,
),
width: size.width * 0.65,
height: size.height * 0.20,
child: Stack(
children: [
Container(
decoration: BoxDecoration(
boxShadow: [kDefaultShadow],
color: Colors.blue,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(25),
topRight: Radius.circular(25),
bottomLeft: Radius.circular(25),
bottomRight: Radius.circular(25),
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
alignment: Alignment.bottomLeft,
child: Text(
"Totalbody",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 18),
),
),
),
],
),
),
Container(
height: size.height * 0.05,
width: size.width * 0.65,
decoration: BoxDecoration(
color: Colors.transparent,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Text(
"Tempo: m.45",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16),
),
Text(
"calorie: 350",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16),
)
],
),
),
],
),
);
}
}
Try this
// ...
ListView.builder(
itemCount: allenamentoList.length,
itebrmBuilder: (context, index) {
return ListTile(
title: Text(allenamentoList[index].nome),
);
},
),
// ...
Edit
If you want to access specific item of your List, provide it's index like this
Text(allenamentoList[0].nome),