material design icons flutter
the material design icons icon pack available as set of flutter icons.
based on material design icons 3.6.95.
installation
in the dependencies:
section of your pubspec.yaml
, add the following line:
material_design_icons_flutter: 3.2.3695
usage
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
class mywidget extends statelesswidget {
widget build(buildcontext context) {
return new iconbutton(
// use the mdiicons class for the icondata
icon: new icon(mdiicons.sword),
onpressed: () { print('using the sword'); }
);
}
}
or, if you want to access the icon by a string name, you can use fromstring
method to create one.
this is not recomended because to make fromstring
work we need a map for all icon names. using this method will not get the benifits of tree-shaking.
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
class mywidget extends statelesswidget {
widget build(buildcontext context) {
return new iconbutton(
// use the string name to access icons.
icon: new icon(mdiicons.fromstring('sword')),
onpressed: () { print('using the sword'); }
);
}
}
name conversion
some icons’ name is reversed keyword in dart (and most other languages), so the names have been changed.
null
->nullicon
switch
->switchicon
sync
->syncicon
factory
->factoryicon
Comments are closed.