[英]Custom made flutter Icon
I am developing a flutter application, for which I need to put my own logo as a Bottom Navigation Bar Icon.我正在开发一个颤振应用程序,为此我需要将自己的徽标作为底部导航栏图标。 I have my own .svg file as well as an image file(png, jpeg, etc) of my logo, but I don't know how to use it as Icon in the bottom nav bar(BNB) with other material Icon.
我有自己的 .svg 文件以及徽标的图像文件(png、jpeg 等),但我不知道如何将其用作底部导航栏(BNB)中的图标和其他材质图标。 For now, I have 4 icons in BNB and want to place the App Logo icon in center of BNB.
目前,我在 BNB 中有 4 个图标,并希望将 App Logo 图标放置在 BNB 的中心。 Note: I am building the app for android as well as ios platform.
注意:我正在为 android 和 ios 平台构建应用程序。 enter image description here
在此处输入图片说明
Take a look at this package: https://pub.dev/packages/flutter_svg看看这个包: https : //pub.dev/packages/flutter_svg
Or use https://www.fluttericon.com/ to make your own "native" icons.或者使用https://www.fluttericon.com/制作自己的“原生”图标。
using package flutter_svg , put the widget inside yout items
list in BottomNavigationBar
使用包flutter_svg ,将小部件放在
BottomNavigationBar
items
列表中
BottomNavigationBarItem(
icon: SvgPicture.asset('assets/images/logo.svg',
height: 40.0,
width: 40.0,
color: Colors.black,),
title: Text('Some Title'))
You can use icon_font_generator to convert from SVG icon to icon font family.您可以使用icon_font_generator将 SVG 图标转换为图标字体系列。
$ flutter pub global activate icon_font_generator
$ export PATH="$PATH":"$HOME/Tools/flutter/.pub-cache/bin"
$ icon_font_generator --from=icons --class-name=Iconly --out-font=lib/src/icon_font/iconly.ttf --out-flutter=lib/src/widgets/icons.dart
This will generate following files:这将生成以下文件:
lib/src/icon_font/iconly.ttf
lib/src/widgets/icons.dart
Final pubspec.yaml
file:最终的
pubspec.yaml
文件:
dev_dependencies:
icon_font_generator: ^1.0.0
flutter:
fonts:
- family: Iconly
fonts:
- asset: lib/src/icon_font/iconly.ttf
Usage:用法:
var icon = const Icon(Iconly.outline2User);
NOTE: there might be wrong rendering for complex SVG file.注意:复杂的 SVG 文件可能存在错误的渲染。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.