import 'package:json_annotation/json_annotation.dart'; part 'car.g.dart'; @JsonSerializable(fieldRename: FieldRename.snake) class Car { final int id; final String carName; final String? driverName; Car({ required this.id, required this.carName, this.driverName, }); factory Car.fromJson(Map json) => _$CarFromJson(json); Map toJson() => _$CarToJson(this); }