Skip to content

freezed missing implementations #289

Open

Description

@drexhacker

Hey @frank06 thanks for the great work. am having a small issue here trying to use freezed with flutter_data. Here is the log

lib/models/business.freezed.dart:231:7: Error: The non-abstract class '_$BusinessImpl' is missing implementations
for these members:
 - _DataModel&Object&DataModelMixin.init
Try to either
 - provide an implementation,
 - inherit an implementation from a superclass or mixin,
 - mark the class as abstract, or
 - provide a 'noSuchMethod' implementation.

class _$BusinessImpl implements _Business {
      ^^^^^^^^^^^^^^
../../.pub-cache/hosted/pub.dev/flutter_data-1.6.0/lib/src/model/data_model.dart:86:5: Context: 'Object with
DataModelMixin.init' is defined here.
  T init() {
    ^^^^

And here is my DataModel

import 'package:flutter_data/flutter_data.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:meno/adapters/appwrite.dart';
import 'package:meno/models/location.dart';

part 'business.freezed.dart';
part 'business.g.dart';

@freezed
@DataRepository([AppwriteAdapter])
class Business extends DataModel<Business> with _$Business {
  factory Business({
    @override String? id,
    required String name,
    required String ownerId,
    required String teamId,
    String? businessType,
    String? address,
    String? phone,
    String? email,
    HasMany<Location>? locations,
    DateTime? createdAt,
    DateTime? updatedAt,
  }) = _Business;

  factory Business.fromJson(Map<String, dynamic> json) =>
      _$BusinessFromJson(json);
}

Thanks in advance for any support. And by the way json_serializable is working well, so I just wanted to have extra features of freezed

Activity

  1. frank06 commented on Feb 17, 2025

    @frank06
    Contributor

    Have you sorted out? You can instead try with DataModelMixin but you will need to manually initialize your models.

  2. alguintu commented on Feb 18, 2025

    @alguintu

    Hi frank06. Trying out the latest release with freezed as well and getting the same compilation error. Is there an example with the mixin/freezed you mentioned?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions