update Example

master
lmy 5 years ago
parent 426dc9b8f8
commit acd990e81e

@ -1,104 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_icons/flutter_icons.dart';
class AntDesignPage extends StatefulWidget {
@override
_AntDesignPageState createState() => _AntDesignPageState();
}
class _AntDesignPageState extends State<AntDesignPage> {
String keyword = "";
List<String> _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);
case "WeatherIcons":
return WeatherIcons.getIconData(iconName);
}
}
@override
Widget build(BuildContext context) {
Map<String, dynamic> args = ModalRoute.of(context).settings.arguments;
Map<String, int> maps = args["glyphMaps"];
String iconSetName = args["iconSetName"];
_keys??=maps.keys.toList();
return Scaffold(
body: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
children: <Widget>[
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: <Widget>[
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,
),
),
],
),
),
);
}
}

@ -40,53 +40,6 @@ class MyHomePage extends StatefulWidget {
}
class _MyHomePageState extends State<MyHomePage> {
buildChildren() {
Map<String, dynamic> map = {
"AntDesign": AntDesign.glyphMaps,
"Entypo": Entypo.glyphMaps,
"EvilIcons": EvilIcons.glyphMaps,
"Feather": Feather.glyphMaps,
"FontAwesome":FontAwesome.glyphMaps,
"Foundation": Foundation.glyphMaps,
"Ionicons": Ionicons.glyphMaps,
"MaterialCommunityIcons": MaterialCommunityIcons.glyphMaps,
"MaterialIcons": MaterialIcons.glyphMaps,
"Octicons": Octicons.glyphMaps,
"SimpleLineIcons": SimpleLineIcons.glyphMaps,
"Zocial":Zocial.glyphMaps,
"WeatherIcons": WeatherIcons.glyphMaps
};
List<Widget> widgets = [];
for (int i = 0; i < map.keys.length; i++) {
widgets.add(GestureDetector(
onTap: (){
Navigator.of(context).pushNamed("icon_page",arguments: {
"glyphMaps":map[map.keys.elementAt(i)],
"iconSetName":map.keys.elementAt(i)
});
},
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(map.keys.elementAt(i)),
Spacer(),
Text(map[map.keys.elementAt(i)].length.toString()),
Icon(Icons.arrow_forward_ios)
],
),
),
));
if (i != map.keys.length - 1) {
widgets.add(Container(
height: 1,
color: Colors.black.withOpacity(0.3),
));
}
}
return widgets;
}
@override
Widget build(BuildContext context) {
@ -106,7 +59,9 @@ class _MyHomePageState extends State<MyHomePage> {
padding: const EdgeInsets.all(20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: buildChildren(),
children: [
Icon(AntDesign.login)
],
),
),
);

@ -13,6 +13,5 @@ export 'src/simple_line_icons.dart';
export 'src/zocial.dart';
export 'src/foundation.dart';
export 'src/font_awesome_5.dart';
export 'src/flutter_icon_data.dart' show IconWeight;
export 'src/icon_toggle.dart';
export 'src/weather_icons.dart';

@ -1,7 +1,5 @@
import 'package:flutter/material.dart';
enum IconWeight { Regular, Solid, Brand }
class FlutterIconData extends IconData {
const FlutterIconData(int codePoint, String fontFamily)
: super(codePoint, fontFamily: fontFamily, fontPackage: "flutter_icons");

Loading…
Cancel
Save