From 7c17e0afa9b1b4b72831eb1dbfbe460bd0c3930e Mon Sep 17 00:00:00 2001 From: Eli <88557639+lishaduck@users.noreply.github.com> Date: Mon, 3 Mar 2025 12:02:33 -0600 Subject: [PATCH] docs: fix example Temporary fix, but this gets it compiling. --- packages/freezed/README.md | 8 +++++--- packages/freezed/example/lib/diagnosticable.dart | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/freezed/README.md b/packages/freezed/README.md index 17728090..b01770bf 100644 --- a/packages/freezed/README.md +++ b/packages/freezed/README.md @@ -143,17 +143,19 @@ part 'my_file.freezed.dart'; ``` -**CONSIDER** also importing `package:flutter/foundation.dart`.\ +**CONSIDER** also importing `package:flutter/foundation.dart`. The reason being, importing `foundation.dart` also imports classes to make an -object nicely readable in Flutter's devtool.\ +object nicely readable in Flutter's devtool. If you import `foundation.dart`, [Freezed] will automatically do it for you. +Do note that if you override `toString`, +then you will need to manually add `@With()` to your factories. ## Creating a Model using Freezed Freezed offers two ways of creating data-classes: - [Primary constructors](#primary-constructors) ; where you define a constructor and Freezed generates the associated fields. - This is simulating the [Primary Constructor](https://github.com/dart-lang/language/issues/2364 using `factory`. + This is simulating the [Primary Constructor](https://github.com/dart-lang/language/issues/2364) using `factory`. - [Classic classes](#classic-classes), where you write a normal Dart class and Freezed only handles `toString/==/copyWith` ### Primary constructors diff --git a/packages/freezed/example/lib/diagnosticable.dart b/packages/freezed/example/lib/diagnosticable.dart index 6a61c773..e9a64f4b 100644 --- a/packages/freezed/example/lib/diagnosticable.dart +++ b/packages/freezed/example/lib/diagnosticable.dart @@ -22,6 +22,8 @@ abstract class ConcreteExample with _$ConcreteExample { @freezed abstract class ToString with _$ToString { ToString._(); + + @With() factory ToString() = _ToString; @override