Flutter项目快速换图标
Flutter项目快速换图标
安装依赖
flutter pub add --dev flutter_launcher_icons初始化配置文件,将自动在项目根目录创建一个名为flutter_launcher_icons.yaml的文件,位于你的 flutter 项目的根目录。
dart run flutter_launcher_icons:generate修改项目根目录的flutter_launcher_icons.yaml,移除不需要的平台之类的,如果改过了这个文件就不用再去pubspec.yaml单独加一个配置项了,直接运行替换即可。
# flutter pub run flutter_launcher_icons
flutter_launcher_icons:
image_path: "assets/icon/icon.png"
android: "launcher_icon"
# image_path_android: "assets/icon/icon.png"
min_sdk_android: 21 # android min sdk min:16, default 21
# adaptive_icon_background: "assets/icon/background.png"
# adaptive_icon_foreground: "assets/icon/foreground.png"
# adaptive_icon_foreground_inset: 16
# adaptive_icon_monochrome: "assets/icon/monochrome.png"
ios: true
# image_path_ios: "assets/icon/icon.png"
remove_alpha_ios: true
# image_path_ios_dark_transparent: "assets/icon/icon_dark.png"
# image_path_ios_tinted_grayscale: "assets/icon/icon_tinted.png"
# desaturate_tinted_to_grayscale_ios: true
# background_color_ios: "#ffffff"
web:
generate: true
image_path: "path/to/image.png"
background_color: "#hexcode"
theme_color: "#hexcode"
windows:
generate: true
image_path: "path/to/image.png"
icon_size: 48 # min:48, max:256, default: 48
macos:
generate: true
image_path: "path/to/image.png"如果走了上一步,这一步可以跳过,修改项目根目录的pubspec.yaml,以下是一个示例。更多复杂的示例可以在示例项目中找到。 注意: flutter_launcher_icons与dev_dependencies是同级配置
dev_dependencies:
flutter_launcher_icons: "^0.14.4"
flutter_launcher_icons:
android: "launcher_icon"
ios: true
image_path: "assets/icon/icon.png"
min_sdk_android: 21 # android min sdk min:16, default 21
web:
generate: true
image_path: "path/to/image.png"
background_color: "#hexcode"
theme_color: "#hexcode"
windows:
generate: true
image_path: "path/to/image.png"
icon_size: 48 # min:48, max:256, default: 48
macos:
generate: true
image_path: "path/to/image.png"运行替换
dart run flutter_launcher_icons