Giter VIP home page Giter VIP logo

built_union.dart's People

Contributors

iteanjd123 avatar realcr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

built_union.dart's Issues

Deserializing Using Attribute

Hi,

Is it possible to deserialize an object using attribte?

Suppose I have classes:

class Type1 {
       string name;
       string value;
       string type;
       BuiltList<Type1> types1;
}

class Type2 {
       string name;
       string value;
       string type;
       BuiltList<Type2> types2;
}

and I need to deserialize based on the attribute called "type". if type == "type1", the deserialized object must be of type Type1, if type == "type2", the deserialized object must be of type Type2.

Thanks

Linter warnings should be ignored

First of all great package!

If you use something like pedantic in your flutter/dart project you can receive linter warnings and errors to help improve productivity.

  • I think it is possible to hide linter warnings from generated files, but I think it would be better for the generator to ignore them itself. I know built value already does this.
  • Built value currently adds this line to the bottom of the generator
// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,lines_longer_than_80_chars,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new
  • The specific linter warnings i get from this package are:

unnecessary_const

This can be...

specifiedType: const FullType(List, const [const FullType(Post)]))

changed to this...

specifiedType: const FullType(List, [FullType(Post)]))

unused_element

If i don't use a serializer i get this warning for my HomeViewState union

The declaration '_$homeViewStateSerializer' isn't referenced.
Try removing the declaration of '_$homeViewStateSerializer'.

unnecessary_new

which comes from the serializer

Serializer<HomeViewState> _$homeViewStateSerializer =
    new _$HomeViewStateSerializer();

Update packages to support null-safety and Flutter 2

Hello,

When I try to upgrade the packages, I get this error:

Because built_union_generator 0.1.3 depends on built_collection >=2.0.0 <5.0.0 and no versions of built_union_generator match >0.1.3 <0.2.0, built_union_generator ^0.1.3 requires built_collection >=2.0.0 <5.0.0.

Can we do upgrade built_collection, built_value and analyzer, please?

Wirename For Fields

Hi,
I'd like to match my camel case attributes in Flutter with snake case attributes from the backend. this is done using wirename in BuiltValue.
For example, I have a field in Flutter called aInt but the backend sends it as a_int.

I have not found any way to do this in this lib, any help would be appreciated.

thanks.

FormatterException while generating code

Hi, I was trying to run the example given in the package. But when I run the code generator I get the following exception.

[SEVERE] built_union_generator:built_value on lib/models/union.dart:
An error `FormatterException` occurred while formatting the generated source for
  `package:basicappl/models/union.dart`
which was output to
  `lib/models/union.built_union.g.part`.
This may indicate an issue in the generator, the input source code, or in the
source formatter.
Could not format because the source could not be parsed:

line 20, column 28: Expected to find ')'.
   ╷
20 │ _$SimpleUnion.string(String* string): _type = _$SimpleUnionType.string, assert(string != null, '_$SimpleUnion constructor argument string can not be null!'), _values = [string];
   │                            ^
   ╵
line 24, column 25: Expected to find ')'.
   ╷
24 │ @required T Function(int*) integer,
   │                         ^
   ╵
line 101, column 66: Expected an identifier.
    ╷
101 │ serializers.serialize(integer, specifiedType: const FullType(int*))
    │                                                                  ^
    ╵
line 108, column 142: Expected an identifier.
    ╷
108 │ serializers.serialize(tupleInt, specifiedType: const FullType(int*)),serializers.serialize(tupleString, specifiedType: const FullType(String*))
    │                                                                                                                                              ^
    ╵
line 19, column 24: Expected to find ')'.
   ╷
19 │ _$SimpleUnion.tuple(int* tupleInt,String* tupleString): _type = _$SimpleUnionType.tuple, assert(tupleInt != null, '_$SimpleUnion constructor argument tupleInt can not be null!'), assert(tupleString != null, '_$SimpleUnion constructor argument tupleString can not be null!'), _values = [tupleInt,tupleString];
   │                        ^
   ╵
line 132, column 106: Expected an identifier.
    ╷
132 │ result = SimpleUnion.integer(serializers.deserialize(iterator.current, specifiedType: const FullType(int*)));
    │                                                                                                          ^
    ╵
line 25, column 25: Expected to find ')'.
   ╷
25 │ @required T Function(int*,String*) tuple,
   │                         ^
   ╵
line 142, column 68: Expected an identifier.
    ╷
142 │ serializers.deserialize(tupleInt,specifiedType: const FullType(int*)),
    │                                                                    ^
    ╵
line 26, column 28: Expected to find ')'.
   ╷
26 │ @required T Function(String*) string,
   │                            ^
   ╵
line 148, column 108: Expected an identifier.
    ╷
148 │ result = SimpleUnion.string(serializers.deserialize(iterator.current, specifiedType: const FullType(String*)));
    │                                                                                                            ^
    ╵

This is the exact code in my model file

import 'package:built_union/built_union.dart';
import 'package:built_value/serializer.dart';

part 'union.g.dart';

@BuiltUnion()
class SimpleUnion extends _$SimpleUnion {
  static Serializer<SimpleUnion> get serializer => _$simpleUnionSerializer;

  SimpleUnion.empty() : super.empty();
  SimpleUnion.integer(int integer) : super.integer(integer);
  SimpleUnion.tuple(int tupleInt, String tupleString)
      : super.tuple(tupleInt, tupleString);
  SimpleUnion.string(String string) : super.string(string);
  SimpleUnion.builtList(BuiltList<int> builtList) : super.builtList(builtList);
}

And these are dependencies I am using -

dependencies:
  meta: ^1.2.3
  built_union: ^0.1.3

dev_dependencies:
  built_union_generator: ^0.1.3
  build_runner: 1.10.1
  built_value_generator: 7.1.0

Could you please let me know, what is causing this issue?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.