dart_pdf icon indicating copy to clipboard operation
dart_pdf copied to clipboard

headerAlignments are not applied to the header cells

Open dkbast opened this issue 3 years ago • 0 comments

Describe the bug headerAlignments are not applied to the header cells

To Reproduce Code snippet to reproduce the behavior:

class CustomPdfTable extends pw.StatelessWidget {
  /// The table's columns.
  final List<String> headers;

  /// The table's rows.
  final List<List<String>> rows;

  CustomPdfTable({required this.headers, required this.rows});

  @override
  pw.Widget build(pw.Context context) {
  return pw.Table.fromTextArray(
      data: [headers, ...rows],
      headerStyle: pw.Theme.of(context).defaultTextStyle.copyWith(fontWeight: pw.FontWeight.bold),
      headerDecoration: const pw.BoxDecoration(
        color: PdfColor.fromInt(0xFFEEEEEE),
        border: pw.Border(
          bottom: pw.BorderSide(
            color: PdfColor.fromInt(0xFF000000),
            width: 2,
          ),
        ),
      ),
      headerCellDecoration: const pw.BoxDecoration(
        border: pw.Border(),
      ),
      border: null,
      headerAlignments: {
        0: pw.Alignment.centerLeft,
        1: pw.Alignment.centerLeft,
        2: pw.Alignment.centerRight,
      },
      cellAlignments: {
        0: pw.Alignment.centerLeft,
        1: pw.Alignment.centerLeft,
        2: pw.Alignment.centerRight,
      },
      columnWidths: {
        0: const pw.IntrinsicColumnWidth(flex: 3),
        1: const pw.IntrinsicColumnWidth(flex: 1),
        2: const pw.FixedColumnWidth(100),
      },
    );
  }
}


Expected behavior The right most header should be aligned with the "end" of the table, as are the data fields

Screenshots

Flutter Doctor [✓] Flutter (Channel stable, 3.0.5, on macOS 12.3.1 21E258 darwin-arm, locale en-DE) • Flutter version 3.0.5 at /opt/homebrew/Caskroom/flutter/2.5.3/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision f1875d570e (8 weeks ago), 2022-07-13 11:24:16 -0700 • Engine revision e85ea0e79c • Dart version 2.17.6 • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0-rc1) • Android SDK at /Users/damianbast/Library/Android/sdk • Platform android-33, build-tools 32.0.0-rc1 • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763) • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.1) • Xcode at /Applications/Xcode.app/Contents/Developer • CocoaPods version 1.11.3

[✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.1) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)

[✓] Connected device (2 available) • macOS (desktop) • macos • darwin-arm64 • macOS 12.3.1 21E258 darwin-arm • Chrome (web) • chrome • web-javascript • Google Chrome 105.0.5195.102

[✓] HTTP Host Availability • All required HTTP hosts are available

• No issues found!

Desktop (please complete the following information):

  • [ x] Mac

dkbast avatar Sep 08 '22 06:09 dkbast