xyz_gen_annotations 0.4.1 copy "xyz_gen_annotations: ^0.4.1" to clipboard
xyz_gen_annotations: ^0.4.1 copied to clipboard

This package includes the annotations for the xyz_gen package. See https://pub.dev/packages/xyz_gen for more information.

example/example.dart

//.title
// ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
//
// Your Project Name
// Copyright Ⓒ Your Name
//
// Licensing details can be found in the LICENSE file in the root directory.
//
// ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
//.title~

import 'package:xyz_gen_annotations/xyz_gen_annotations.dart';

part '_model_user.g.dart';

// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

// This is just one of many generators included in the `xyz_gen` package! This
// Model generator is much more flexible than `json_serializable` and easier
// to use in your project.

@GenerateModel(
  fields: {
    "email": $LowerCaseString,
    "searchable_name": $LowerCaseString,
    "display_name": "String?",
    "type": $UpperSnakeCaseString,
  },
  shouldInherit: true,
  keyStringCase: "lower_snake_case",
)
abstract class _ModelUser extends ThisModel<ModelUser> {
  @Field()
  String? firstName;

  @Field()
  String? lastName;

  String get fullName => "$firstName $lastName";

  bool get isAdmin => this.model.type == ModelUserType.ADMIN.name;
  bool get isUser => this.model.type == ModelUserType.USER.name;

  bool emailContains(String value) {
    return this.model.email?.contains(value.toLowerCase()) == true;
  }

  bool nameContains(String value) {
    return this.model.searchableName?.contains(value.toLowerCase()) == true;
  }
}

enum ModelUserType {
  ADMIN,
  USER,
}
1
likes
0
points
473
downloads

Publisher

unverified uploader

Weekly Downloads

This package includes the annotations for the xyz_gen package. See https://pub.dev/packages/xyz_gen for more information.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

collection, xyz_utils

More

Packages that depend on xyz_gen_annotations