I just want to put an Image
and an Text
in this AlertDialog
, but the Imagename images/jonglieren.jpg
is red underlined. The shown "Error: The getter 'images' isn't defined for the class 'MyHomePage'" doesn't help too. Here's the function
:
void inform() {
showDialog<AlertDialog>(
context: context,
builder: (BuildContext context) {
return AlertDialog(
actions: <Widget>[
Column(
children: <Widget>[
Text('Jonglieren'), Image.asset(images/jonglieren.jpg)
],
)
],
);
});
}
Your image path should be a string(it should be in a quotation)
from images/jonglieren.jpg to 'images/jonglieren.jpg'
void inform() {
showDialog<AlertDialog>(
context: context,
builder: (BuildContext context) {
return AlertDialog(
actions: <Widget>[
Column(
children: <Widget>[
Text('Jonglieren'), Image.asset('images/jonglieren.jpg')
],
)
],
);
});
}
The Image.asset
constructor takes a String name
as its parameter. So to solve this issue just give your asset path as a String.
void inform() {
showDialog<AlertDialog>(
context: context,
builder: (BuildContext context) {
return AlertDialog(
actions: <Widget>[
Column(
children: <Widget>[
Text('Jonglieren'), Image.asset('images/jonglieren.jpg')
],
)
],
);
});
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.