繁体   English   中英

容器中的图像不想显示在我的屏幕中 Flutter Dart

[英]Image in container doesn't want to show in my screen Flutter Dart

图像未显示在我的屏幕上。 也有人可以告诉我 flatbutton 是怎么回事,矩形也没有出现。

它应该是这样的:应该是什么样子

这是我的屏幕我的屏幕

我的代码:

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"),

onPressed: (null)替换为

onPressed: () {

    }

您看到的样式是禁用按钮,因为您没有提供 onTap 方法。

还要根据您的文件夹结构在 pubsub.yaml 中添加资产文件夹(如果图像文件夹在资产文件夹内),请按照您的文件夹结构进行操作。

  assets:
    - assets/Image/
    - assets/

然后使用image: new AssetImage("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: () {

                               }
        ),
        ]),
  ),),


  ),

  );
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM