body method

  1. @override
String body(
  1. String path,
  2. String baseName,
  3. String className
)
override

Defines the actual body code. path is passed relative to lib, baseName is the filename, and className is the filename converted to Pascal case.

実際の本体コードを定義します。pathlibからの相対パス、baseNameにファイル名が渡され、classNameにファイル名をパスカルケースに変換した値が渡されます。

Implementation

@override
String body(String path, String baseName, String className) {
  return """
/// Alias for ModelRef<CounterModel>.
///
/// When defining parameters for other Models, you can define them as follows
///
/// ```dart
/// @refParam CounterModelRef $baseName
/// ```
typedef CounterModelRef = ModelRef<CounterModel>?;

/// Value for model.
@freezed
@formValue
@immutable
@DocumentModelPath("app/counter")
class CounterModel with _\$CounterModel {
const factory CounterModel({
   @Default(ModelCounter(0)) ModelCounter counter,
}) = _CounterModel;
const CounterModel._();

factory CounterModel.fromJson(Map<String, Object?> json) => _\$CounterModelFromJson(json);

/// Query for document.
///
/// ```dart
/// appRef.model(CounterModel.document());       // Get the document.
/// ref.app.model(CounterModel.document())..load();  // Load the document.
/// ```
static const document = _\$CounterModelDocumentQuery();

/// Query for form value.
///
/// ```dart
/// ref.app.form(CounterModel.form(CounterModel()));    // Get the form controller in app scope.
/// ref.page.form(CounterModel.form(CounterModel()));    // Get the form controller in page scope.
/// ```
static const form = _\$CounterModelFormQuery();
}
""";
}