IconToo constructor
const
IconToo(
- IconData? icon, {
- Key? key,
- @Deprecated(_DEPRECATED) Size? trueSize,
- double? sizeX,
- double? sizeY,
- Color? color,
- List<
Shadow> ? shadows, - AlignmentGeometry? alignment,
- String? semanticLabel,
- TextDirection? textDirection,
🙋♂️ I'm an Icon Too!
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, trueSize?, sizeX?, sizeY?, color?, shadows?, alignment?, semanticLabel?, textDirection?})
Builds an Icon-akin widget set inside a SizedBox of
sizeX
and sizeY
with given icon data.
Customize with 🎨 color, which defaults to IconTheme.of,
or optional 👥 shadows, a List<Shadow>
like TextStyle.shadows.
The AlignmentGeometry and textDirection are handled, but may be overridden if necessary.
- See alignment for more information.
Assumed to be wide, super
Icon.size is assigned _sizeX
??
_sizeY
.
- This affects situations that look for an Icon.size
- A solution for taller icons exists: IconToo.tall
- Where the only difference is the order of assignment,
Icon.size:
_sizeY
??
_sizeX
- Where the only difference is the order of assignment,
Icon.size:
Replete with proper Semantics
and debug Property
s.
❓ 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: () {},
);
NOTE: All the boxes are checked as far as the parameters for which a standard Icon looks and the accessibility & debug features they offer.
SEE ALSO: Icon, for a description on what an "
Icon
" is and some requirements to deploy that Widget or an 🙋♂️ IconToo.
Implementation
const IconToo(
this.icon, {
Key? key,
@Deprecated(_DEPRECATED) Size? trueSize,
double? sizeX,
double? sizeY,
this.color,
this.shadows,
this.alignment,
this.semanticLabel,
this.textDirection,
}) : assert((sizeX ?? 0) >= 0 && (sizeY ?? 0) >= 0,
'[IconToo] > Provide non-negative dimensions.'),
_sizeX = sizeX,
_sizeY = sizeY,
_trueSize = trueSize,
super(
icon,
key: key,
size: sizeX ?? sizeY, // Assumed to be wider ╠░░░░░░░░╣
color: color,
semanticLabel: semanticLabel,
textDirection: textDirection,
);