[英]Image in container doesn't want to show in my screen Flutter Dart
The image doesn't show on my screen.图像未显示在我的屏幕上。 Also can someone tell me what's the deal with the flatbutton, the rectangle doesn't show up either.也有人可以告诉我 flatbutton 是怎么回事,矩形也没有出现。
This is what it should look like:它应该是这样的:
This is my screen这是我的屏幕
My code:我的代码:
import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(
home: Scaffold(
backgroundColor: Colors.pink,
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center, children: [
new Container(
width: 100,
height: 100,
decoration: new BoxDecoration(
shape: BoxShape.circle,
image: new DecorationImage(
image: new AssetImage("Image/Animegirl.jpg"),
fit: BoxFit.fill,
),
),
),
Text(
"Alice Payne",
style: TextStyle(fontSize: 50, color: Colors.white),
),
Text(
"MOBILE DEVELOPER",
style: TextStyle(fontSize: 40, color: Colors.white),
),
FlatButton.icon(
shape: new RoundedRectangleBorder(borderRadius: new BorderRadius.circular(30.0)),
color: Colors.white,
label: Text("+212612174968",
style:TextStyle(
color: Colors.grey,
),
),
icon: Icon(Icons.phone,
size: 25,
color: Colors.white,
),
onPressed: (null)
),
FlatButton.icon(
shape: new RoundedRectangleBorder(borderRadius: new BorderRadius.circular(30.0)),
color: Colors.white,
label: Text("hda.karima@gmail.com",
style:TextStyle(
color:Colors.grey,
),
),
icon: Icon(Icons.email,
size: 25,
color: Colors.white,
),
onPressed: (null)
),
]),
),),
),
);
}
还包括assets
image: AssetImage("assets/Image/Animegirl.jpg"),
Replace onPressed: (null)
with将onPressed: (null)
替换为
onPressed: () {
}
The style you seeing is of a disabled button as you are not providing onTap method.您看到的样式是禁用按钮,因为您没有提供 onTap 方法。
Also add asset folder in pubsub.yaml as per your folder structure (If Image folder is inside a assets folder) do it as per your folder structure.还要根据您的文件夹结构在 pubsub.yaml 中添加资产文件夹(如果图像文件夹在资产文件夹内),请按照您的文件夹结构进行操作。
assets:
- assets/Image/
- assets/
then use image: new AssetImage("assets/Image/Animegirl.jpg")
然后使用image: new AssetImage("assets/Image/Animegirl.jpg")
Your code should be something like你的代码应该是这样的
import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(
home: Scaffold(
backgroundColor: Colors.pink,
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center, children: [
new Container(
width: 100,
height: 100,
decoration: new BoxDecoration(
shape: BoxShape.circle,
image: new DecorationImage(
image: new AssetImage("Image/Animegirl.jpg"),
fit: BoxFit.fill,
),
),
),
Text(
"Alice Payne",
style: TextStyle(fontSize: 50, color: Colors.white),
),
Text(
"MOBILE DEVELOPER",
style: TextStyle(fontSize: 40, color: Colors.white),
),
FlatButton.icon(
shape: new RoundedRectangleBorder(borderRadius: new BorderRadius.circular(30.0)),
color: Colors.white,
label: Text("+212612174968",
style:TextStyle(
color: Colors.grey,
),
),
icon: Icon(Icons.phone,
size: 25,
color: Colors.white,
),
onPressed: () {
}
),
FlatButton.icon(
shape: new RoundedRectangleBorder(borderRadius: new BorderRadius.circular(30.0)),
color: Colors.white,
label: Text("hda.karima@gmail.com",
style:TextStyle(
color:Colors.grey,
),
),
icon: Icon(Icons.email,
size: 25,
color: Colors.white,
),
onPressed: () {
}
),
]),
),),
),
);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.