open method

Future<void> open()

Implementation

Future<void> open() async {
  await header.writeHeader(channel);
  charset = charset ??= Charset();
  timeZone = timeZone ??= TimeZones.getDefault();
  formatter = FieldFormatter(charset, timeZone, !reportFieldSizeErrors);

  // As the 'shapelib' osgeo project does, we use specific values for
  // null cells. We can set up these values for each column once, in
  // the constructor, to save time and memory.
  nullValues = List.filled(
      header.getNumFields(), <int>[]); //  List(header.getNumFields());
  for (int i = 0; i < nullValues.length; i++) {
    String nullChar;
    var fieldType = String.fromCharCode(header.getFieldType(i));
    switch (fieldType) {
      case 'C':
      case 'c':
      case 'M':
      case 'G':
        nullChar = NULL_CHAR;
        break;
      case 'L':
      case 'l':
        nullChar = '?';
        break;
      case 'N':
      case 'n':
      case 'F':
      case 'f':
        nullChar = '*';
        break;
      case 'D':
      case 'd':
        nullChar = '0';
        break;
      case '@':
        // becomes day 0 time 0.
        nullChar = NULL_CHAR;
        break;
      default:
        // catches at least 'D', and 'd'
        nullChar = '0';
        break;
    }
    nullValues[i] =
        List.filled(header.getFieldLength(i), nullChar.codeUnitAt(0));
  }
}