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

Reduce boilerplate code #31

Closed
atn832 opened this issue Dec 6, 2022 · 1 comment
Closed

Reduce boilerplate code #31

atn832 opened this issue Dec 6, 2022 · 1 comment

Comments

@atn832
Copy link

atn832 commented Dec 6, 2022

I tried writing the simplest class:

import 'package:xml_annotation/xml_annotation.dart' as annotation;

part 'character.g.dart';

@annotation.XmlRootElement(name: 'character')
@annotation.XmlSerializable()
class Character {}

And ran the generator. It generated the character.g.dart class but it had a compile error:

The method 'buildXmlChildren' isn't defined for the type 'Character'. Try correcting the name to the name of an existing method, or defining a method named 'buildXmlChildren'.

It would be nice to handle the simplest use cases to allow us to write even less boilerplate code. Judging from your readme example, i would still need to implement a few more methods for it to compile.

@tnc1997
Copy link
Owner

tnc1997 commented Dec 6, 2022

Hi @atn832, thank you very much for your issue. It looks like your class doesn't have any fields and does not have the required methods to support XML serialization using this package. You could reduce the number of methods that you have to implement in your class by using the create mixin functionality provided by the XmlSerializable annotation.

@tnc1997 tnc1997 closed this as completed Feb 18, 2023
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

2 participants