How do I add my Text in the following code in flutter:
Text( '${_productosModel[index].name}', textAlign: TextAlign.center, style: TextStyle(fontSize: 20.0), ),
return InkWell(
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) => ImageScreen(
url: '${_productosModel[index].image}' '?alt=media',
),
),
),
child: Expanded(
child: CachedNetworkImage(
imageUrl: '${_productosModel[index].image}' '?alt=media',
fit: BoxFit.cover,
placeholder: (_, __) {
return Center(
child: CupertinoActivityIndicator(
radius: 15,
),
);
//code TEXT
},
),
),
),
CodePudding user response:
LIke this --- as the
heathscliff says,
return InkWell(
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) => ImageScreen(
url: '${_productosModel[index].image}' '?alt=media',
),
),
),
child: Column(children: [
Expanded(
child: CachedNetworkImage(
imageUrl: '${_productosModel[index].image}' '?alt=media',
fit: BoxFit.cover,
placeholder: (_, __) {
return Center(
child: CupertinoActivityIndicator(
radius: 15,
),
);
//code TEXT
},
),
Text('data test'),
]),
),
),
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>
CodePudding user response:
You need to wrap your Expanded
with Column
.
But I recommand you to use Container
instead Expanded
Set the height and width of your Container
return InkWell(
onTap: () {},
child: Column(
children: [
Container(
width: double.infinity //if you want to use the maximum width
height: 250, // you can customize this
margin: EdgeInsets.symmetric(vertical: 5),
child: CachedNetworkImage(
imageUrl:
'${_productosModel[index].image}' '?alt=media',
fit: BoxFit.cover,
placeholder: (_, __) {
return Center(
child: CupertinoActivityIndicator(
radius: 15,
),
);
},
),
),
Text("Image text")
],
),
);