IconToo constructor

const IconToo(
  1. IconData? icon, {
  2. Key? key,
  3. @Deprecated(_DEPRECATED) Size? trueSize,
  4. double? sizeX,
  5. double? sizeY,
  6. Color? color,
  7. List<Shadow>? shadows,
  8. AlignmentGeometry? alignment,
  9. String? semanticLabel,
  10. 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.

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

Replete with proper Semantics and debug Propertys.


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,
      );