isChecked property

bool get isChecked

Gets or sets a value indicating whether this PdfCheckBoxField is checked.

The default value is false.

Implementation

bool get isChecked {
  if (_helper.isLoadedField) {
    if (items != null && items!.count > 0) {
      final IPdfPrimitive? state = PdfCrossTable.dereference(
          PdfFieldItemHelper.getHelper(items![_helper.defaultIndex])
              .dictionary![PdfDictionaryProperties.usageApplication]);
      if (state == null) {
        final IPdfPrimitive? name = PdfFieldHelper.getValue(
            _helper.dictionary!,
            _helper.crossTable,
            PdfDictionaryProperties.v,
            false);
        if (name != null && name is PdfName) {
          _checked = name.name ==
              _helper.getItemValue(
                  PdfFieldItemHelper.getHelper(items![_helper.defaultIndex])
                      .dictionary!,
                  _helper.crossTable);
        }
      } else if (state is PdfName) {
        _checked = state.name != PdfDictionaryProperties.off;
      }
      return _checked;
    }
    if (_helper.dictionary!.containsKey(PdfDictionaryProperties.v)) {
      final PdfName chk =
          _helper.dictionary![PdfDictionaryProperties.v]! as PdfName;
      _checked = chk.name != 'Off';
    }
  }
  return _checked;
}
set isChecked (bool value)

Implementation

set isChecked(bool value) {
  if (_helper.isLoadedField) {
    if (_helper.dictionary!.containsKey(PdfDictionaryProperties.v)) {
      final PdfName chk =
          _helper.dictionary![PdfDictionaryProperties.v]! as PdfName;
      if (chk.name!.isNotEmpty) {
        _checked = chk.name != 'Off';
      } else {
        _helper.dictionary!.remove(PdfDictionaryProperties.v);
      }
    }
    PdfFormHelper.getHelper(form!).setAppearanceDictionary = true;
    if (PdfFormHelper.getHelper(super.form!).needAppearances == false) {
      _helper.changed = true;
    }
  }
  if (_checked != value) {
    _checked = value;
    String? val;
    if (_helper.isLoadedField) {
      val = _helper._enableCheckBox(value);
      val = _helper._enableItems(value, val);
    }
    if (_checked) {
      _helper.dictionary!.setName(PdfName(PdfDictionaryProperties.v),
          val ?? PdfDictionaryProperties.yes);
      _helper.dictionary!.setProperty(
          PdfDictionaryProperties.usageApplication,
          PdfName(val ?? PdfDictionaryProperties.yes));
    } else {
      _helper.dictionary!.remove(PdfDictionaryProperties.v);
      if (_helper.dictionary!
          .containsKey(PdfDictionaryProperties.usageApplication)) {
        _helper.dictionary!.setName(
            PdfName(PdfDictionaryProperties.usageApplication),
            PdfDictionaryProperties.off);
      }
    }
  }
}