Dart Flutter Freezed Classes

Flutter plugin for generating Dart classes from GraphQL queries. It uses the freezed package.

Version
5.0.1
Weekly downloads
2k
License
MIT
Updated
Apr 19, 2026

Installation

          npm i -D @graphql-codegen/flutter-freezed
        

Config API Reference

camelCasedEnums

type: {(boolean | DartIdentifierCasing)}

Setting this option to true will camelCase enum values as required by Dart’s recommended linter.

If set to false, the original casing as specified in the Graphql Schema is used

You can also transform the casing by specifying your preferred casing for Enum values.

Available options are: 'snake_case', 'camelCase' and 'PascalCase'

For consistency, this option applies the same configuration to all Enum Types in the GraphQL Schema Default value: “true”

copyWith

type: {(boolean | TypeNamePattern)}

The freezed library has this option enabled by default. Use this option to enable/disable this option completely.

The plugin by default generates immutable Freezed models using the @freezed decorator.

If this option is configured, the plugin will generate immutable Freezed models using the @Freezed(copyWith: value) instead.

Setting a boolean value will enable/disable this option globally for every GraphQL Type but you can also set this option to true for one or more GraphQL Types using a TypeNamePattern. Default value: “undefined”

customScalars

type: {(Record<string, string>)}

The key is the GraphQL Scalar Type and the value is the equivalent Dart Type

The plugin automatically handles built-in GraphQL Scalar Types so only specify the custom Scalars in your Graphql Schema. Default value: “[object Object]“

defaultValues

type: {([pattern: FieldNamePattern, value: string, appliesOn: AppliesOnParameters[]][])}

This will annotate the generated parameter with a @Default(value: defaultValue) decorator.

The default value will be interpolated into the @Default(value: ${value}) decorator so Use backticks for the value element so that you can use quotation marks for string values. E.g: "I'm a string default value" but Episode.jedi is not a string value.

Use the appliesOn to specify where this option should be applied on Default value: “undefined”

deprecated

type: {([pattern: Pattern, appliesOn: (AppliesOnFactory | AppliesOnParameters)[]][])}

Using a TypeNamePattern, you can mark an entire factory constructor for one or more GraphQL types as deprecated.

Likewise, using a FieldNamePattern, you can mark one or more fields as deprecated

Since the first element in the tuple has a type signature of Pattern, you can use either TypeNamePattern or FieldNamePattern or use both by composing them with Pattern.compose(...)

Use the appliesOn to specify which block this option should be applied on Default value: “undefined”

equal

type: {(boolean | TypeNamePattern)}

The freezed library has this option enabled by default. Use this option to enable/disable this option completely.

The plugin by default generates immutable Freezed models using the @freezed decorator.

If this option is configured, the plugin will generate immutable Freezed models using the @Freezed(equal: value) instead.

Setting a boolean value will enable/disable this option globally for every GraphQL Type but you can also set this option to true for one or more GraphQL Types using a TypeNamePattern. Default value: “undefined”

escapeDartKeywords

type: {(boolean | [pattern: Pattern, prefix?: string, suffix?: string, appliesOn?: AppliesOn[]][])}

Wraps the fields names that are valid Dart keywords with the prefix and suffix given Default value: “true”

final

type: {([pattern: FieldNamePattern, appliesOn: AppliesOnParameters[]][])}

This will mark the specified parameters as final Default value: “undefined”

ignoreTypes

type: {(TypeNamePattern)}

names of GraphQL types to ignore when generating Freezed classes Default value: “undefined”

immutable

type: {(boolean | TypeNamePattern)}

The freezed library by default generates immutable models decorated with the @freezed decorator. This option if set to false the plugin will generate mutable Freezed models using the @unfreezed decorator instead.

Setting a boolean value will enable/disable this option globally for every GraphQL Type but you can also set this option to true for one or more GraphQL Types using a TypeNamePattern. Default value: “undefined”

makeCollectionsUnmodifiable

type: {(boolean | TypeNamePattern)}

allows collections(lists/maps) to be modified even if class is immutable Default value: “undefined”

mergeTypes

type: {(Record<string, TypeName[]>)}

maps over the value(array of typeNames) and transform each as a named factory constructor inside a class generated for the key(target GraphQL Object Type). Default value: “undefined”

mutableInputs

type: object

since inputs will be used to collect data, it makes sense to make them mutable with Freezed’s @unfreezed decorator.

This overrides(in order words: has a higher precedence than) the immutable config value ONLY for GraphQL input types. Default value: “true”

privateEmptyConstructor

type: object

if true, defines a private empty constructor to allow getter and methods to work on the class Default value: “true”

unionClass

type: array[]

customize the key to be used for fromJson with multiple constructors Default value: “undefined”

The flutter-freezed plugin generates [Freezed] models using a GraphQL Schema.

Please refer the Flutter Freezed Guide for how to get started with this plugin.