diff --git a/lib/Screens/Statistics/statistics_report.dart b/lib/Screens/Statistics/statistics_report.dart index df9c23a..585d933 100644 --- a/lib/Screens/Statistics/statistics_report.dart +++ b/lib/Screens/Statistics/statistics_report.dart @@ -303,7 +303,7 @@ pw.Widget _chart(StatisticsReportData data) { data.series.map((point) => point.visits).reduce((a, b) => a > b ? a : b); final axisMax = _roundedAxisMax(peak); - return _card( + return _Unbreakable(_card( data, title: data.chartTitle, subtitle: data.chartSubtitle, @@ -352,11 +352,11 @@ pw.Widget _chart(StatisticsReportData data) { ], ], ), - ); + )); } pw.Widget _barGroup(StatisticsReportData data, ReportBarGroup group) { - return _card( + return _Unbreakable(_card( data, title: group.title, subtitle: group.subtitle, @@ -388,7 +388,7 @@ pw.Widget _barGroup(StatisticsReportData data, ReportBarGroup group) { ), ], ), - ); + )); } pw.Widget _table(StatisticsReportData data, ReportTable table) { @@ -460,6 +460,22 @@ pw.Widget _barTrack(double fraction, PdfColor color) { ); } +/// `Container` délègue `canSpan` à son enfant : une carte se coupait donc entre +/// deux pages, titre seul en bas de l'une et contenu en haut de l'autre. +/// `MultiPage` reporte en entier tout enfant non sécable. +class _Unbreakable extends pw.SingleChildWidget { + _Unbreakable(pw.Widget child) : super(child: child); + + @override + bool get canSpan => false; + + @override + void paint(pw.Context context) { + super.paint(context); + paintChild(context); + } +} + double _roundedAxisMax(int peak) { if (peak <= 4) return 4; var magnitude = 1.0;