given this dart / flutter code
import 'package:flutter/material.dart';
import 'package:bitsdojo_window/bitsdojo_window.dart';
import 'package:fluent_ui/fluent_ui.dart' as fluent;
import 'dart:io';
import 'package:path/path.dart' as p;
import 'package:serial_port_win32/serial_port_win32.dart';
import 'dart:typed_data'; // Import dart:typed_data

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  List<String> langOptions = [];
  String? selectedLanguage;
  var ports = <String>[];
  late SerialPort port;

  @override
  void initState() {
    super.initState();
    fetchLangOptions(); // Ensure this is called after its declaration
  }

  Future<void> fetchLangOptions() async {
    final directory = Directory('assets/lang');

    try {
      final files = directory.listSync();
      List<String> options = [];
      for (var file in files) {
        if (file is File) {
          String fileName = p.basenameWithoutExtension(file.path);
          if (fileName.length >= 2) {
            options.add(fileName.substring(0, 2));
          }
        }
      }
      setState(() {
        langOptions = options;
      });
      await setInitialSelectedLanguage();
    } catch (e) {
      print('Error reading directory: $e');
    }
  }

  Future<void> setInitialSelectedLanguage() async {
    final file = File('assets/preferences.txt');

    try {
      if (await file.exists()) {
        String firstLine = (await file.readAsLines()).first.trim();
        String lastTwoChars = firstLine.length >= 2
            ? firstLine.substring(firstLine.length - 2)
            : firstLine;

        if (langOptions.contains(lastTwoChars)) {
          setState(() {
            selectedLanguage = lastTwoChars;
          });
        }
      }
    } catch (e) {
      print('Error reading preferences file: $e');
    }
  }

  Future<void> updatePreferencesFile(String value) async {
    final file = File('assets/preferences.txt');

    try {
      if (await file.exists()) {
        await file.writeAsString(value, mode: FileMode.write);
      }
    } catch (e) {
      print('Error writing to preferences file: $e');
    }
  }

  void initializeSerialPorts() async {
    final ports = SerialPort.getAvailablePorts();
    print(ports); // result like [COM3, COM4]

    port = SerialPort("COM3", openNow: true, ByteSize: 8, BaudRate: 56000);
    String buffer = "wei.mdf\r\n";
    await port.writeBytesFromString(buffer,
        includeZeroTerminator: false,
        stringConverter: StringConverter.nativeUtf8);
    final response = await port.readBytesUntil(
        Uint8List.fromList("\n".codeUnits)); // '\n' is the delimiter
    final asciiResponse =
        String.fromCharCodes(response); // Convert bytes to ASCII string
    print(asciiResponse); // Print the ASCII string
    //port.close();
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        WindowTitleBarBox(
          child: Row(
            children: [
              Expanded(child: MoveWindow()),
              const WindowButtons(),
            ],
          ),
        ),
        Container(
          height: 40,
          color: fluent.Colors.black,
          child: Row(
            children: [
              const Expanded(
                child: Center(
                  child: Text(
                    "Text Holder",
                    style: TextStyle(
                      color: fluent.Colors.white,
                      fontSize: 16,
                      fontWeight: FontWeight.bold,
                    ),
                  ),
                ),
              ),
              Padding(
                padding: const EdgeInsets.only(right: 16.0),
                child: SizedBox(
                  width: 65,
                  height: 35,
                  child: fluent.ComboBox<String>(
                    placeholder: const Text('..'),
                    style: const TextStyle(fontSize: 14),
                    value: selectedLanguage,
                    onChanged: (String? newValue) {
                      if (newValue != null) {
                        setState(() {
                          selectedLanguage = newValue;
                        });
                        updatePreferencesFile(newValue);
                      }
                    },
                    items: langOptions.map((String value) {
                      return fluent.ComboBoxItem<String>(
                        value: value,
                        child: Text(value),
                      );
                    }).toList(),
                  ),
                ),
              ),
            ],
          ),
        ),
        const SizedBox(height: 10),
        Container(
          alignment: Alignment.centerLeft,
          padding: const EdgeInsets.only(left: 130.0, bottom: 10.0),
          child: fluent.Button(
            onPressed: () {
              print('Initialize button pressed.');
              initializeSerialPorts();
            },
            child: const Text('Initialize'),
          ),
        ),
        Expanded(
          child: Row(
            children: [
              Container(
                width: 280,
                color: Colors.blueGrey[50],
                child: Column(
                  children: [
                    const Center(
                      child: Text(
                        "HYDRAULIC JACK",
                        style: TextStyle(
                          fontSize: 17,
                          fontWeight: FontWeight.bold,
                        ),
                      ),
                    ),
                    const Padding(
                      padding: EdgeInsets.all(8.0),
                      child: Row(
                        children: [
                          Expanded(
                            child: Text("Model No:"),
                          ),
                          Expanded(
                            child: SizedBox(
                              height: 22,
                              child: TextField(
                                decoration: InputDecoration(
                                  enabledBorder: OutlineInputBorder(
                                    borderSide: BorderSide(
                                      color: Colors.black, // Black border
                                      width: 1.0,
                                    ),
                                  ),
                                  focusedBorder: OutlineInputBorder(
                                    borderSide: BorderSide(
                                      color: Colors.black, // Black border
                                      width: 1.0,
                                    ),
                                  ),
                                ),
                                key: Key('FldHydraulicJackModelNo'),
                              ),
                            ),
                          ),
                        ],
                      ),
                    ),
                    const Padding(
                      padding: EdgeInsets.all(8.0),
                      child: Row(
                        children: [
                          Expanded(
                            child: Text("Serial No:"),
                          ),
                          Expanded(
                            child: SizedBox(
                              height: 22,
                              child: TextField(
                                decoration: InputDecoration(
                                  enabledBorder: OutlineInputBorder(
                                    borderSide: BorderSide(
                                      color: Colors.black, // Black border
                                      width: 1.0,
                                    ),
                                  ),
                                  focusedBorder: OutlineInputBorder(
                                    borderSide: BorderSide(
                                      color: Colors.black, // Black border
                                      width: 1.0,
                                    ),
                                  ),
                                ),
                                key: Key('FldHydraulicJackSerialNo'),
                              ),
                            ),
                          ),
                        ],
                      ),
                    ),
                    const Padding(
                      padding: EdgeInsets.all(8.0),
                      child: Row(
                        children: [
                          Expanded(
                            child: Text("Manufacturer:"),
                          ),
                          Expanded(
                            child: SizedBox(
                              height: 22,
                              child: TextField(
                                decoration: InputDecoration(
                                  enabledBorder: OutlineInputBorder(
                                    borderSide: BorderSide(
                                      color: Colors.black, // Black border
                                      width: 1.0,
                                    ),
                                  ),
                                  focusedBorder: OutlineInputBorder(
                                    borderSide: BorderSide(
                                      color: Colors.black, // Black border
                                      width: 1.0,
                                    ),
                                  ),
                                ),
                                key: Key('FldHydraulicJackManufacturer'),
                              ),
                            ),
                          ),
                        ],
                      ),
                    ),
                  ],
                ),
              ),
              Expanded(
                child: Container(
                  color: Colors.white,
                  child: const Center(
                    child: Text("Right Column"),
                  ),
                ),
              ),
            ],
          ),
        ),
      ],
    );
  }
}

final buttonColors = WindowButtonColors(
  iconNormal: const fluent.Color(0xFF805306),
  mouseOver: const fluent.Color(0xFFF6A00C),
  mouseDown: const fluent.Color(0xFF805306),
  iconMouseOver: const fluent.Color(0xFF805306),
  iconMouseDown: const fluent.Color(0xFFFFD500),
);

final closeButtonColors = WindowButtonColors(
  mouseOver: const fluent.Color(0xFFD32F2F),
  mouseDown: const fluent.Color(0xFFB71C1C),
  iconNormal: const fluent.Color(0xFF805306),
  iconMouseOver: fluent.Colors.white,
);

class WindowButtons extends StatelessWidget {
  const WindowButtons({super.key});

  @override
  Widget build(BuildContext context) {
    return Row(
      children: [
        MinimizeWindowButton(colors: buttonColors),
        CloseWindowButton(colors: closeButtonColors),
      ],
    );
  }
}
please correct so that when text is entered into the fields the text input cursor is in the correct position