Need to automate your code conversion? Use the CLI
Do you want an automated way to convert C# classes to Dart? The new C# to Dart Command-Line Interface (CLI) tool does just that. Here's how you use it:
csharp2dart [arguments]: This is how you run the tool. Replace [arguments] with
any of the below options.
Global options list:
-h, -help: Display help information.-s: Specify the location of the source folder with your C# files.-o: Specify the location of the output folder where you want Dart files to be stored.-addJsonSerializable: Add the @JsonSerializable() annotation to your Dart code.-addToJson: Add @toJson() method to your Dart code for JSON serialization.-addFromJson: Add @fromJson() method to your Dart code for decoding the JSON you received.-allFieldsNullable: If you want all fields in your Dart code to be nullable, use this option.-requiredConstructorParameters: Use this option to make all constructor parameters required.-simpleEnums: Generate simple enums.
For instance, if you want to convert your files from 'C:\MyCsharpFiles' folder and want Dart files to be stored in 'C:\MyDartFiles' folder, you can use the CLI tool as such:
CSharp2Dart.exe -s C:\MyCsharpFiles -o C:\MyDartFiles -addJsonSerializable -addToJson -addFromJson Download CLI