Skip to content

Commit

Permalink
fixed constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
charafau committed Jul 7, 2018
1 parent d06ab6b commit 677fe77
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
9 changes: 5 additions & 4 deletions lib/parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Parser {
..name = 'toJson'
..returns = new Reference('String')
..body = new Code(
'json.encode(serializers.serializeWith(${_getPascalCaseClassName(
'return json.encode(serializers.serializeWith(${_getPascalCaseClassName(
name)}.serializer, this));')))
..methods.add(new Method((b) => b
..name = 'fromJson'
Expand All @@ -79,10 +79,11 @@ class Parser {
..body = new Code('_\$${ReCase(name).camelCase}Serializer')))
..constructors.add(new Constructor((b) => b
..factory = true
..lambda = true
..body = Code('_\$${_getPascalCaseClassName(name)}')
..redirect = refer(' _\$${_getPascalCaseClassName(name)}')
..requiredParameters.add(new Parameter((b) => b
..name = '[updates(${_getPascalCaseClassName(name)}Builder b)]')))));
..defaultTo = Code('= _\$${_getPascalCaseClassName(name)}')
..name = '[updates(${_getPascalCaseClassName(name)}Builder b)]'))),)
);

String classString = topLevelClass.accept(new DartEmitter()).toString();

Expand Down
14 changes: 8 additions & 6 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="scaffolded-by" content="https://github.com/google/stagehand">
<title>json2builtval</title>
<title>Json to built_value generator</title>
<link rel="stylesheet" href="styles.css">
<link rel="icon" href="favicon.ico">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
Expand All @@ -26,22 +26,24 @@
.inline-txtarea {
width: 48%;
height: 90vh;
border: 2px solid grey;
border: 1px solid #eeeeee;
/* color: #ffffff; */
font-size: 11pt;
margin: 0 auto;
/* background-color: #37373F; */
}
</style>
</head>

<body class="mdl-color--blue-grey-700">
<body >

<!-- <div style="margin-left: 24px;">
<h2 style="display: inline-block;">Json to Dart built_value class converter</h2>
Root class name:
<input id="root_class_name" type="text" value="RootDto"></input>
<input id="convert" type="submit" value="Convert"></input>
</div> -->
<div class="mdl-layout__header-row mdl-color--blue-grey-900 mdl-color-text--blue-grey-50">
<div class="mdl-layout__header-row header" >
<span class="mdl-layout-title">Json to Dart built_value class converter </span>
<div style="margin-left: 10px;">
<input id="root_class_name" type="text" value="RootDto"></input>
Expand All @@ -50,8 +52,8 @@ <h2 style="display: inline-block;">Json to Dart built_value class converter</h2>
</div>
<div id="texts" class="inline-div">
<center>
<textarea id="input_text" class="inline-txtarea mdl-color--blue-grey-700 mdl-color-text--blue-grey-50"></textarea>
<textarea id="output_text" class="inline-txtarea mdl-color--blue-grey-700 mdl-color-text--blue-grey-50"></textarea>
<textarea id="input_text" class="inline-txtarea "></textarea>
<textarea id="output_text" class="inline-txtarea "></textarea>
</center>
</div>

Expand Down
7 changes: 6 additions & 1 deletion web/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@ html, body {
margin: 0;
padding: 0;
font-family: 'Roboto', sans-serif;
/* background-color: #EEEEEE; */
background-color: #33333C;
/* background-color: rgba(40, 40, 40, .8); */
}

.header {
background-color: #33333C;
color: #ffffff;
}

#output {
padding: 20px;
text-align: center;
Expand Down

0 comments on commit 677fe77

Please sign in to comment.