icon library
🙋♂️ I'm an Icon Too!
+ 🗜️ extension IconUtils on Icon
🔽
An extended Icon
"too" for those that are not actually square,
because Flutter's native Icon "assumes that the rendered icon is squared",
plus 👥 shadows
support.
const IconToo(icon, {key, sizeX?, sizeY?, color?, shadows?, alignment?, semanticLabel?, textDirection?})
- Builds an
Icon
-akin widget set inside aSizedBox
ofsizeX
andsizeY
with givenicon
data. - Customize with optional 🎨
color
or 👥shadows
, aList<Shadow>
likeTextStyle
. - The
alignment
andtextDirection
are handled, but may be overridden if necessary. - Replete with proper
Semantics
and debugProperty
s.
Assumed to be wide, super
Icon.size
is assigned sizeX ?? sizeY
.
- This affects situations that look for an
Icon.size
, likeIconButton
- A solution for taller icons exists:
IconToo.tall
- Where the only difference is the order of assignment to
Icon.size
:sizeY ?? sizeX
- Where the only difference is the order of assignment to
🗜️ Icon Utilities
- 📋
copyWith
optional replacement values - 👆
operator >(VoidCallback onTap)
➡ IconButton - ➕
operator +(inflate)
➡size += inflation
- ➖
operator -(deflate)
➡size -= deflation
- ❌
operator *(dynamic operation)
- ❓
operation is Color
➡color = operation
- ❓
operation is num
➡size *= operation
- ❓
- 💥
operator %(dynamic modulation)
- ❓
modulation is List<Color>
➡color = modulation[Random()]
- ❓
modulation is List<num>
➡sizeX *= modulation[random]
&sizeY *= modulation[random]
- ❓
🗜️ IconToo Utilities
📋 copyWith
👆 "Chevron" operator >(VoidCallback onTap)
➡ IconButton
➕ "Add" inflation
- ❓
inflation is num
: adds tosizeX
&sizeY
the same - ❓
inflation is List<num>
(length==2): rampsX += inflation[0]
&Y += inflation[1]
➖ "Subtract" deflation
- ❓
deflation is num
: subtracts fromsizeX
&sizeY
the same - ❓
deflation is List<num>
(length==2): rampsX -= deflation[0]
&Y -= deflation[1]
❌ "Multiply" with operation
- ❓
operation is Color
: newColor
- ❓
operation is num
: multipliessizeX
&sizeY
the same - ❓
operation is List<num>
(length==2): rampsX *= operation[0]
&Y *=operation[1]
💥 "Modulate" with modulation
(randomizer)
- ❓
modulation is List<Color>
➡color: modulation[Random()]
- ❓
modulation is List<num>
➡sizeX *= modulation[Random()]
&sizeY *= modulation[Random()]
(sameRandom
)
🧦 "And" with padding
- ❓
padding is num
➡EdgeInsets.all(padding)
- ❓
padding is List<num>
(length==2) ➡EdgeInsets.symmetric(horizontal: padding[0], vertical: padding[1])
- ❓
padding is List<num>
(length==4) ➡EdgeInsets.fromLTRB(padding[0], padding[1],padding[2], padding[3])
❓ IconToo as IconButton:
final wideButton = IconButton(
icon: const IconToo(
CustomIcons.non_square_icon,
// IconToo passes `fontSize: min(trueSize.width, trueSize.height)`,
// the shortest side (here: height), to glyph-rendering TextStyle:
sizeX: 34.0 * 5.0, // Glyph is 5 times wider than tall
sizeY: 34.0,
),
// But the max(), or longest side, is needed to ensure an
// IconButton has a diameter that encompasses the entire IconToo:
iconSize: 34.0 * 5.0, // IconToo.asSize.longestSize
onPressed: () {},
);
Classes
- IconToo
- 🙋♂️ I'm an Icon Too!