【问题标题】:asset image not appearing in flutter资产图像没有出现在颤动中
【发布时间】:2023-01-11 15:13:04
【问题描述】:

我正在使用 dhiwise 将我的 figma 原型转换为 flutter,但标题没有出现并且以某种方式位于屏幕上方。我试着把它移到别处,但它只是把它放在标题外面。

current look what it is supposed to look like

return SafeArea(
 child: Scaffold(
 backgroundColor: ColorConstant.whiteA700,
 body: Container(
 height: size.height,
 width: size.width,
 child: Stack(
 children: [
 Align(
 alignment: Alignment.center,
 child: SingleChildScrollView(
 child: Container(
 height: size.height,
 width: size.width,
 child: Stack(
 alignment: Alignment.topRight,
 children: [
 Align(
 alignment: Alignment.center,
 child: Container(
 height: size.height,
 width: size.width,
 decoration: BoxDecoration(
 color: ColorConstant.whiteA700,
 ),
 child: Stack(
 alignment: Alignment.bottomCenter,
 children: [
 Align(
 alignment: Alignment.topCenter,
 child: Container(
 width: size.width,
 padding: getPadding(
 left: 11,
 top: 7,
 right: 11,
 bottom: 7,
 ),
 decoration: BoxDecoration(
 color: ColorConstant.blue200,
 ),
 child: Column(
 mainAxisSize: MainAxisSize.min,
 crossAxisAlignment:
 CrossAxisAlignment.start,
 mainAxisAlignment:
 MainAxisAlignment.start,
 children: [
 CustomIconButton(
 height: 53,
 width: 53,
 margin: getMargin(
 bottom: 276,
 ),
 child: CustomImageView(
 svgPath: ImageConstant.imgUser,

【问题讨论】:

  • 尝试 flutter clean,然后重新安装应用程序
  • 您是否将该图像指定为 pubspec.yaml 中的资产?示例:flutter: assets: - assets/my_icon.png - assets/background.png

标签: flutter dart assets


【解决方案1】:

1-flutter clean

2-flutter pub get

如果这些说明不适用,我建议您查看下面的链接 enter link description here

【讨论】:

    【解决方案2】:

    我希望您将该图像指定为 pubspec.yaml 中的资产。

    我是说...

    Flutter 使用位于项目根目录的 pubspec.yaml 文件来识别应用程序所需的资产。

    flutter:
      assets:
        - assets/my_icon.png
        - assets/background.png
    

    要包含目录下的所有资产,请在末尾指定带有 / 字符的目录名称:

    flutter:
      assets:
        - directory/
        - directory/subdirectory/
    

    【讨论】:

      猜你喜欢
      • 2018-04-10
      • 2021-11-24
      • 2021-07-10
      • 1970-01-01
      • 1970-01-01
      • 2022-11-30
      • 2020-02-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多