flutter 最簡單的應(yīng)用程序圖標(biāo)制作方法

image

原文

https://medium.com/@bharadwaj.palakurthy/the-easiest-way-to-make-app-icons-in-flutter-9fe1bc9dd646

參考

正文

image

讓我們承認(rèn)這一點(diǎn)ーー管理應(yīng)用程序圖標(biāo)是一項(xiàng)重復(fù)的任務(wù)。他們必須生成的多分辨率和手動放置在幾個文件夾,這是一個世俗的任務(wù)采取。你可能需要做一些小的改變或者修改,現(xiàn)在你必須重復(fù)整個替換圖標(biāo)的過程。

不僅如此,根據(jù)我們選擇的平臺或操作系統(tǒng)的版本,還應(yīng)用了不同的規(guī)則。所以把這些都記在心里,這個過程最好是自動化,而不是手動完成。我們將在這里使用這個名為“ flutter_launcher_icons”的 flutter 包來自動生成所有需要的分辨率。

Flutter Launcher Icons:

一個命令行工具,簡化了更新應(yīng)用程序啟動圖標(biāo)的任務(wù)。完全靈活,允許你選擇你想要更新啟動器圖標(biāo)的平臺,如果你想要的話,選擇保留你的舊啟動器圖標(biāo),以防你想在未來的某個時候返回。

先決條件

在任何情況下,當(dāng)從圖形編輯器導(dǎo)出時,應(yīng)該是:

  • Format: 32-bit 格式: 32 位PNG 巴布亞新幾內(nèi)亞
  • Icon size 圖標(biāo)大小must be up to 1024x1024 pixels 必須達(dá)到 1024x1024 像素
  • 確保在 40 像素處可見(這是最小的圖標(biāo))(Apple Requirement) (蘋果需求)
  • 最大尺寸1024KB (Android Requirement) 1024KB (Android 版本要求)
  • 圖標(biāo)必須用no transparency 沒有透明度
  • 形狀必須是正方形no rounded corners 沒有圓角
  • 需要一個自適應(yīng)的 android 圖標(biāo)background 背景and 及foreground 前景to be separated 分開
image

安卓產(chǎn)品圖標(biāo)關(guān)鍵字

The intended look might be different from the guidelines provided by the platforms. So we’ll be creating 3 different flavors for android, iOS, adaptive icons.

預(yù)期的外觀可能與平臺提供的指導(dǎo)方針不同。因此,我們將為 android、 iOS 和自適應(yīng)圖標(biāo)創(chuàng)建三種不同的風(fēng)格。

image

預(yù)期外觀

image

Android and iOS (no transparency) 安卓和 iOS (沒有透明度)

image

Adaptive Icons for Android 8.0 and above 8.0 及以上版本的自適應(yīng)圖標(biāo)

實(shí)施方案:

我們將使用一個名為 flutter_launcher_icons 的包

現(xiàn)在我們需要分別在你的代碼中實(shí)現(xiàn)它:

  • 第一步: 添加依賴項(xiàng)。

將 dependency 添加到位于 Flutter 項(xiàng)目根目錄中的 pubspec.yaml 文件:

dev_dependencies:
  flutter_launcher_icons: any

  • 第二步: 配置屬性
flutter_icons:
  ios: true
  android: true
  image_path_ios: "assets/launcher/icon.png"
  image_path_android: "assets/launcher/icon.png"
  adaptive_icon_background: "assets/launcher/background.png"
  adaptive_icon_foreground: "assets/launcher/foreground.png"
image

圖像在你的 assets/launcher/

  • 第三步: 運(yùn)行包

設(shè)置完配置后,剩下要做的就是運(yùn)行包。

flutter pub get
flutter pub run flutter_launcher_icons:main
  • 第四步: 跑步

如果一切順利,資產(chǎn)已經(jīng)產(chǎn)生。現(xiàn)在,您已經(jīng)準(zhǔn)備好構(gòu)建應(yīng)用程序并運(yùn)行它了。恭喜你

屬性:

目前,它只能用于為 android/ios 分配圖標(biāo)

  • image_path 圖像路徑: : 圖標(biāo)圖像文件的位置,你想用它作為應(yīng)用程序啟動圖標(biāo)
  • image_path_android 圖片/path/android: : 特定于 Android 平臺的圖標(biāo)圖像文件的位置
  • image_path_ios 圖片/path/ios: : 特定于 iOS 平臺的圖標(biāo)圖像文件位置

接下來的兩個屬性只在生成 Android 啟動器圖標(biāo)時使用

  • adaptive_icon_background 背景: You can pass in a solid color (E.g. “#ffffff”) or image asset (E.g. “assets/images/christmas-background.png”) which will be used to fill out the background of the adaptive icon.
  • adaptive_icon_foreground 自適應(yīng)圖標(biāo)前景: The image asset which will be used for the icon foreground of the adaptive icon : 將用于自適應(yīng)圖標(biāo)的前景圖標(biāo)的圖像資產(chǎn)

Thank you!

謝謝


? 貓哥

往期

開源

GetX Quick Start

https://github.com/ducafecat/getx_quick_start

新聞客戶端

https://github.com/ducafecat/flutter_learn_news

strapi 手冊譯文

https://getstrapi.cn

微信討論群 ducafecat

系列集合

譯文

https://ducafecat.tech/categories/%E8%AF%91%E6%96%87/

開源項(xiàng)目

https://ducafecat.tech/categories/%E5%BC%80%E6%BA%90/

Dart 編程語言基礎(chǔ)

https://space.bilibili.com/404904528/channel/detail?cid=111585

Flutter 零基礎(chǔ)入門

https://space.bilibili.com/404904528/channel/detail?cid=123470

Flutter 實(shí)戰(zhàn)從零開始 新聞客戶端

https://space.bilibili.com/404904528/channel/detail?cid=106755

Flutter 組件開發(fā)

https://space.bilibili.com/404904528/channel/detail?cid=144262

Flutter Bloc

https://space.bilibili.com/404904528/channel/detail?cid=177519

Flutter Getx4

https://space.bilibili.com/404904528/channel/detail?cid=177514

Docker Yapi

https://space.bilibili.com/404904528/channel/detail?cid=130578

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容