Flutter 容器中的图像不';我不想在屏幕上显示飞镖
图像没有显示在我的屏幕上。还有谁能告诉我扁平按钮是怎么回事,矩形也不显示 它应该是这样的: 这是我的屏幕 我的代码:Flutter 容器中的图像不';我不想在屏幕上显示飞镖,flutter,dart,Flutter,Dart,图像没有显示在我的屏幕上。还有谁能告诉我扁平按钮是怎么回事,矩形也不显示 它应该是这样的: 这是我的屏幕 我的代码: import 'package:flutter/material.dart'; void main() { runApp( MaterialApp( home: Scaffold( backgroundColor: Colors.pink, body: Center(
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)
),
]),
),),
),
);
}
还包括
资产
image: AssetImage("assets/Image/Animegirl.jpg"),
将按下时的替换为:(空)
onPressed: () {
}
您看到的样式是禁用的按钮,因为您没有提供onTap方法
还可以根据文件夹结构在pubsub.yaml中添加资产文件夹(如果图像文件夹位于资产文件夹中),并根据文件夹结构进行添加
assets:
- assets/Image/
- assets/
然后使用image:newassetimage(“assets/image/Animegirl.jpg”)
您的代码应该类似于
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: () {
}
),
]),
),),
),
);
}
您是否在pubspec.yaml中添加了“Image/Animegirl.jpg”?