addWidgets method

Future<bool> addWidgets(
  1. List<CPDFWidget> widgets
)

Adds widgets to the document.

example:

List<CPDFWidget> widgets = [CPDFTextWidget(
    title: CPDFWidgetUtil.createFieldName(CPDFFormType.textField),
    page: 0,
    rect: const CPDFRectF(left: 40, top: 799, right: 320, bottom: 701),
    borderColor: Colors.lightGreen,
    fillColor: Colors.white,
    borderWidth: 2,
    text: 'This text field is created using the Flutter API.',
    familyName: 'Times',
    styleName: 'Bold')];

bool result = await document.addWidgets(widgets);

Implementation

Future<bool> addWidgets(List<CPDFWidget> widgets) async {
  List<Map<String, dynamic>> widgetsData =
      widgets.map((e) => e.toJson()).toList();
  return await _channel.invokeMethod('add_widgets', {'widgets': widgetsData});
}