Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

freezed missing implementations #289

Open
drexhacker opened this issue Oct 13, 2024 · 2 comments
Open

freezed missing implementations #289

drexhacker opened this issue Oct 13, 2024 · 2 comments

Comments

@drexhacker
Copy link

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

@frank06
Copy link
Contributor

frank06 commented Feb 17, 2025

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

@alguintu
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants