utils library

Extensions

IterableExtension on Iterable<T>

Functions

buildCopyWithSnippet(ClassDeclaration classDecl) String?
Builds a copyWith(...) snippet for the class based on the best constructor. Returns null if no suitable constructor/fields found.
buildEqualityAndHashCodeSnippet(String className, List<({bool isCollection, bool isNamed, bool isNullable, String name, String type})> fields, {required DartFileEditBuilder builder}) String
Builds equality operator and hashCode getter snippet.
buildEqualitySnippet(String className, List<({bool isCollection, bool isNamed, bool isNullable, String name, String type})> fields, {required DartFileEditBuilder builder}) String
Builds equality operator snippet.
buildHashCodeSnippet(List<({bool isCollection, bool isNamed, bool isNullable, String name, String type})> fields, {DartFileEditBuilder? builder}) String
Builds hashCode getter snippet.
buildToStringSnippet(String className, Iterable<String> fieldNames) String
Code generation helpers (kept in one place to avoid duplication) Builds a toString() override snippet for the given class and fields.
getBestConstructorForCopyWith(ClassDeclaration node) → ConstructorDeclaration?
Gets the best constructor for copyWith generation Returns null if no suitable constructor is found
getClassFields(ClassDeclaration node, {bool constructorOnly = false}) List<({bool isCollection, bool isNamed, bool isNullable, String name, String type})>
Gets the fields of a class as a list of records containing name, type, isNamed, and isNullable. If constructorOnly is true, only fields present in the best constructor are returned.
getClassName(ClassDeclaration node) String
Gets the name of the class
getCopyWithMethod(ClassDeclaration node) → MethodDeclaration?
Gets the copyWith method from a class, if it exists
getCopyWithParameters(MethodDeclaration method) Set<String>
Gets the parameter names from a copyWith method
getEqualityMethod(ClassDeclaration node) → MethodDeclaration?
Gets the equality (==) method from a class, if it exists
getFieldsInFunctionBody(MethodDeclaration method) Set<String>
getHashCodeMethod(ClassDeclaration node) → MethodDeclaration?
Gets the hashCode method from a class, if it exists
getMissingFieldsInCopyWith(ClassDeclaration classDecl, MethodDeclaration copyWithMethod) Set<String>
Returns the set of fields that are missing from an existing copyWith method
getMissingFieldsInEquality(ClassDeclaration classDecl, MethodDeclaration equalityMethod) Set<String>
Returns the set of fields that are missing from an existing equality operator
getMissingFieldsInHashCode(ClassDeclaration classDecl, MethodDeclaration hashCodeMethod) Set<String>
Returns the set of fields that are missing from an existing hashCode getter
getMissingFieldsInToString(ClassDeclaration classDecl, MethodDeclaration toStringMethod) Set<String>
Returns the set of fields that are missing from an existing toString method
getToStringMethod(ClassDeclaration node) → MethodDeclaration?
Gets the toString method from a class, if it exists
isConstructorSuitableForCopyWith(ConstructorDeclaration constructor) bool
Validates if constructor is suitable for copyWith generation