Flutter 本地图片加载不出来

pubspec.yaml 中添加

项目根目录/assets/images/ 中是存在该图片的
但图片无论怎么刷新都加载不出来,根据文档反复对了很多次,实在找到不到代码在哪里出了问题。

重点来了…重新启动后,图片出来了……

页面布局
以下为关键代码:

  assets:
    - assets/images/

Layout.dart

import 'package:flutter/material.dart';

import 'section/footer.dart';
import 'section/title.dart';
import 'section/reviews.dart';

class Layout extends StatefulWidget {
  @override
  _LayoutState createState() => _LayoutState();
}

class _LayoutState extends State<Layout> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: [
       	// 图片无法加载,
          Image.asset(
              'assets/images/avatar.png',
            width: 200,
            height: 200,
            fit: BoxFit.cover
          ),
          Reviews(),
          titleSection,
          textSection,
          footerSection(context),
        ],
      )
    );
  }

  Widget headImage() {

  }

  Widget textSection = Container(
    padding: const EdgeInsets.all(32),
    child: Text(
      'Lake Oeschinen lies at the foot of the Blüemlisalp in the Bernese '
          'Alps. Situated 1,578 meters above sea level, it is one of the '
          'larger Alpine Lakes. A gondola ride from Kandersteg, followed by a '
          'half-hour walk through pastures and pine forest, leads you to the '
          'lake, which warms to 20 degrees Celsius in the summer. Activities '
          'enjoyed here include rowing, and riding the summer toboggan run.',
      softWrap: true,
    ),
  );
}
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值