Widget

Sizebox + Container
Divider的height实际为最外层高度,thickness才是真正的内容高,indent和endIndent为当margin实现

  1. @override
  2. Widget build(BuildContext context) {
  3. final DividerThemeData dividerTheme = DividerTheme.of(context);
  4. final double height = this.height ?? dividerTheme.space ?? 16.0;
  5. final double thickness = this.thickness ?? dividerTheme.thickness ?? 0.0;
  6. final double indent = this.indent ?? dividerTheme.indent ?? 0.0;
  7. final double endIndent = this.endIndent ?? dividerTheme.endIndent ?? 0.0;
  8. return SizedBox(
  9. height: height,
  10. child: Center(
  11. child: Container(
  12. height: thickness,
  13. margin: EdgeInsetsDirectional.only(start: indent, end: endIndent),
  14. decoration: BoxDecoration(
  15. border: Border(
  16. bottom: createBorderSide(context, color: color, width: thickness),
  17. ),
  18. ),
  19. ),
  20. ),
  21. );
  22. }

style

用的直接是Divider皮肤

  1. final DividerThemeData dividerTheme = DividerTheme.of(context);