reparentTypes property

Map reparentTypes
getter/setter pair

Widget types to reparent, mapped to a method that handles that type. This is used to make it easy to work with widgets that require specific parents. For example, the Positioned widget, which needs its immediate parent to be a Stack.

Handles Flexible, Positioned, and Expanded by default, but you can add additional handlers as appropriate. Example, this would add support for a hypothetical "AlignPositioned" widget, that has an alignment property.

Animate.reparentTypes[AlignPositioned] = (parent, child) {
  AlignPositioned o = parent as AlignPositioned;
  return AlignPositioned(alignment: o.alignment, child: child);
}

Implementation

static Map reparentTypes = <Type, ReparentChildBuilder>{
  Flexible: (parent, child) {
    Flexible o = parent as Flexible;
    return Flexible(key: o.key, flex: o.flex, fit: o.fit, child: child);
  },
  Positioned: (parent, child) {
    Positioned o = parent as Positioned;
    return Positioned(
      key: o.key,
      left: o.left,
      top: o.top,
      right: o.right,
      bottom: o.bottom,
      width: o.width,
      height: o.height,
      child: child,
    );
  },
  Expanded: (parent, child) {
    Expanded o = parent as Expanded;
    return Expanded(key: o.key, flex: o.flex, child: child);
  }
};