Flutter Material Icons(for the web)在释放模式下不工作

5f0d552i  于 2023-04-22  发布在  Flutter
关注(0)|答案(2)|浏览(177)

在为我的一个网站尝试flutter-web时,我发现Material Icons在调试模式下渲染,但在发布模式下不工作(被盒子取代)。navBarMobile.dart的代码在这里。

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:eva_icons_flutter/eva_icons_flutter.dart';
import 'package:portfolio/globals/myColors.dart';
import 'package:portfolio/globals/myDimens.dart';
import 'package:portfolio/globals/mySpaces.dart';
import 'package:portfolio/globals/myString.dart';

class NavBarMobile extends StatefulWidget {
  _NavBarMobileState createState() => _NavBarMobileState();
}

class _NavBarMobileState extends State<NavBarMobile> {
  @override
  Widget build(BuildContext context) {
    return Container(
      height: MyDimens.double_125,
      color: MyColors.white,
      child: Padding(
        padding: const EdgeInsets.symmetric(horizontal: MyDimens.double_20),
        child: Row(
          children: [
            Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Row(
                  children: [
                    Container(
                      width: MyDimens.double_16,
                      height: MyDimens.double_16,
                      color: MyColors.accentColor,
                    ),
                    MySpaces.hSmallestGapInBetween,
                    Text(
                      MyStrings.myName,
                      style: TextStyle(
                          color: MyColors.black,
                          fontFamily: 'poppins',
                          fontSize: MyDimens.double_20),
                    ),
                  ],
                ),
                MySpaces.vSmallestGapInBetween,
                Text(
                  MyStrings.myWork.toUpperCase(),
                  style: TextStyle(
                      letterSpacing: 0.5,
                      color: MyColors.black,
                      fontFamily: 'avenir-light',
                      fontSize: MyDimens.double_15),
                ),
              ],
            ),
            Spacer(),
            Icon(Icons.menu, color: MyColors.accentColor, size: MyDimens.double_40,),
          ],
        ),
      ),
    );
  }
}

这里是我的屏幕截图从我的笔记本电脑在
1.释放方式(使用flutter run --release
x1c 0d1x 2.调试模式(使用flutter run

其他详细信息:

浏览器- Chrome
操作系统- Ubuntu 20.04

unguejic

unguejic1#

既然我找到了一条出路,我想与面临同样问题的其他人分享。就我而言,我通过以下方式解决了这个问题:
1.下载web/assets/fonts目录中的MaterialIcons-Regular.tff字体。
1.在文件web/assets/FontManifest.json中添加[{"fonts":[{"asset":"fonts/MaterialIcons-Regular.ttf"}],"family":"MaterialIcons"}]

bn31dyow

bn31dyow2#

如果你的资产/图标在调试模式下工作,而在发布模式下没有显示,请考虑这个简单的方法:
1.在debug模式下运行web应用程序。
1.运行时,打开build文件夹并查找flutter_assets文件夹:

build/flutter_assets

1.从flutter_assets复制fonts文件夹和FontManifest.json
1.将它们粘贴到您的Web文件夹web/assets和TADAAA!

  1. flutter clean〉删除构建文件夹〉flutter pub getflutter run --release

相关问题