This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"name": "Debug Generator", | |
"request": "launch", | |
"program": ".dart_tool/build/entrypoint/build.dart", | |
"type": "dart", | |
"args": [ | |
"build" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
targets: | |
$default: | |
builders: | |
dataclass_generator|data_class: | |
enabled: true | |
generate_for: | |
- lib/**/**_model.dart |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
builders: | |
data_class: | |
import: 'package:dataclass_generator/generators/data_class_generator.dart' | |
builder_factories: ['dataClassGenerator'] | |
build_extensions: { '.dart': ['.dataclass.dart'] } | |
build_to: source |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:analyzer/dart/element/element.dart'; | |
import 'package:build/build.dart'; | |
import 'package:source_gen/source_gen.dart'; | |
import '../annotation/data_class.dart'; | |
Builder dataClassGenerator(BuilderOptions options) => | |
PartBuilder([DataClassGenerator()], '.dataclass.dart'); | |
class DataClassGenerator extends GeneratorForAnnotation<DataClass> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (final field in fields) { | |
if (field.isStatic) continue; | |
if (field.setter != null) continue; | |
final fieldName = field.name ?? ''; | |
final fieldType = field.type.getDisplayString(); | |
params.add( | |
'$fieldType${fieldType.endsWith('?') ? '' : '?'} $fieldName', | |
); | |
constructor.add('$fieldName: $fieldName ?? this.$fieldName'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:analyzer/dart/element/element.dart'; | |
import 'package:build/build.dart'; | |
import 'package:source_gen/source_gen.dart'; | |
import '../annotation/data_class.dart'; | |
Builder dataClassGenerator(BuilderOptions options) => | |
PartBuilder([DataClassGenerator()], '.dataclass.dart'); | |
class DataClassGenerator extends GeneratorForAnnotation<DataClass> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:analyzer/dart/element/element.dart'; | |
import 'package:build/build.dart'; | |
import 'package:source_gen/source_gen.dart'; | |
import '../annotation/data_class.dart'; | |
Builder dataClassGenerator(BuilderOptions options) => | |
PartBuilder([DataClassGenerator()], '.dataclass.dart'); | |
class DataClassGenerator extends GeneratorForAnnotation<DataClass> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:build/build.dart'; | |
import 'package:source_gen/source_gen.dart'; | |
import '../annotation/data_class.dart'; | |
Builder dataClassGenerator(BuilderOptions options) => | |
PartBuilder([DataClassGenerator()], '.dataclass.dart'); | |
class DataClassGenerator extends GeneratorForAnnotation<DataClass> {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:source_gen/source_gen.dart'; | |
import '../annotation/data_class.dart'; | |
class DataClassGenerator extends GeneratorForAnnotation<DataClass> {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:source_gen/source_gen.dart'; | |
import '../annotation/data_class.dart'; | |
class DataClassGenerator extends GeneratorForAnnotation<DataClass> {} |
NewerOlder