PavelS0 / docx_template_dart

A Docx template engine
Apache License 2.0
40 stars 20 forks source link

Create row on table dynamically #5

Closed sxywalkr closed 3 years ago

sxywalkr commented 3 years ago

Many thanks for your great plugins.

i've facing issue when create content within table which is created dynamically

need your suggesstion what i'm missing?

here is my error

I/flutter ( 2617): NoSuchMethodError: The method 'add' was called on null.
I/flutter ( 2617): Receiver: null
I/flutter ( 2617): Tried calling: add(Instance of 'RowContent')

here is my code

List<RowContent> aRow;
      for (int i = 0; i < data3.length; i++) {
        aRow.add(
          RowContent()
            ..add(TextContent("xxNo", i + 1))
            ..add(TextContent("xxJenis", data3[i]['xJenis']))
            ..add(TextContent("xxMerk", "---")),
        );
      }

      c
        ..add(TableContent("table", aRow));
PavelS0 commented 3 years ago

You are using an uninitialized variable List<RowContent> aRow change to final aRow = <RowContent>[]