From 2da236ddf3096f84c3438588d5bf2d8ec78810bf Mon Sep 17 00:00:00 2001 From: lmy <2534290808@qq.com> Date: Tue, 17 Sep 2019 17:46:24 +0800 Subject: [PATCH] update example --- example/lib/ant_design_page.dart | 102 +++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 example/lib/ant_design_page.dart diff --git a/example/lib/ant_design_page.dart b/example/lib/ant_design_page.dart new file mode 100644 index 0000000..6f5514b --- /dev/null +++ b/example/lib/ant_design_page.dart @@ -0,0 +1,102 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_icons/flutter_icons.dart'; + +class AntDesignPage extends StatefulWidget { + @override + _AntDesignPageState createState() => _AntDesignPageState(); +} + +class _AntDesignPageState extends State { + String keyword = ""; + List _keys; + + getIconData(String iconSetName, String iconName) { + switch (iconSetName) { + case "AntDesign": + return AntDesign.getIconData(iconName); + case "Entypo": + return Entypo.getIconData(iconName); + case "EvilIcons": + return EvilIcons.getIconData(iconName); + case "Feather": + return Feather.getIconData(iconName); + case "FontAwesome": + return FontAwesome.getIconData(iconName); + case "Foundation": + return Foundation.getIconData(iconName); + case "Ionicons": + return Ionicons.getIconData(iconName); + case "MaterialCommunityIcons": + return MaterialCommunityIcons.getIconData(iconName); + case "MaterialIcons": + return MaterialIcons.getIconData(iconName); + case "Octicons": + return Octicons.getIconData(iconName); + case "SimpleLineIcons": + return SimpleLineIcons.getIconData(iconName); + case "Zocial": + return Zocial.getIconData(iconName); + } + } + + @override + Widget build(BuildContext context) { + Map args = ModalRoute.of(context).settings.arguments; + Map maps = args["glyphMaps"]; + String iconSetName = args["iconSetName"]; + _keys??=maps.keys.toList(); + return Scaffold( + body: Padding( + padding: const EdgeInsets.all(20.0), + child: Column( + children: [ + TextField( + onChanged: (value){ + keyword = value; + }, + decoration: InputDecoration( + hintText: "输入图标名称进行搜索", + suffix: IconButton( + onPressed: (){ + if(keyword!="") { + var _kkeys = maps.keys.toList(); + _kkeys.retainWhere((str)=>str.contains(keyword)); + setState(() { + _keys = _kkeys; + }); + } + }, + icon: Icon(Icons.search), + ), + ), + ), + Expanded( + child: ListView.separated( + itemBuilder: (_,index){ + return Padding( + padding: const EdgeInsets.symmetric(vertical: 8), + child: Row( + children: [ + Icon( + getIconData(iconSetName, _keys.elementAt(index)), + size: 16, + ), + SizedBox(width: 10), + Text(_keys.elementAt(index)) + ], + ), + ); + }, + separatorBuilder: (_,index)=>Container( + height: 1, + color: Colors.black.withOpacity(0.3), + ), + itemCount: _keys.length, + ), + ), + ], + ), + ), + ); + } +}