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

Dart breaking changes #711

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions architecture-examples/dart/web/dart/TodoApp.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ part of todomvc;
class TodoApp {
List<TodoWidget> todoWidgets = new List<TodoWidget>();

Element todoListElement = query('#todo-list');
Element mainElement = query('#main');
InputElement checkAllCheckboxElement = query('#toggle-all');
Element footerElement = query('#footer');
Element countElement = query('#todo-count');
Element clearCompletedElement = query('#clear-completed');
Element showAllElement = query('#filters a[href="#/"]');
Element showActiveElement = query('#filters a[href="#/active"]');
Element showCompletedElement = query('#filters a[href="#/completed"]');
Element todoListElement = querySelector('#todo-list');
Element mainElement = querySelector('#main');
InputElement checkAllCheckboxElement = querySelector('#toggle-all');
Element footerElement = querySelector('#footer');
Element countElement = querySelector('#todo-count');
Element clearCompletedElement = querySelector('#clear-completed');
Element showAllElement = querySelector('#filters a[href="#/"]');
Element showActiveElement = querySelector('#filters a[href="#/active"]');
Element showCompletedElement = querySelector('#filters a[href="#/completed"]');

TodoApp() {
initLocalStorage();
Expand All @@ -26,7 +26,7 @@ class TodoApp {
var jsonList = window.localStorage['todos-vanilladart'];
if (jsonList != null) {
try {
var todos = JSON.parse(jsonList);
var todos = JSON.decode(jsonList);
for (Map todo in todos) {
addTodo(new Todo.fromJson(todo));
}
Expand All @@ -37,7 +37,7 @@ class TodoApp {
}

void initElementEventListeners() {
InputElement newTodoElement = query('#new-todo');
InputElement newTodoElement = querySelector('#new-todo');

newTodoElement.onKeyPress.listen((KeyboardEvent e) {
if (e.keyCode == KeyCode.ENTER) {
Expand Down Expand Up @@ -160,6 +160,6 @@ class TodoApp {
for (TodoWidget todoWidget in todoWidgets) {
todos.add(todoWidget.todo);
}
window.localStorage['todos-vanilladart'] = JSON.stringify(todos);
window.localStorage['todos-vanilladart'] = JSON.encode(todos);
}
}
11 changes: 6 additions & 5 deletions architecture-examples/dart/web/dart/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ library todomvc;

import 'dart:html';
import 'dart:math';
import 'dart:json' as JSON;
import 'dart:convert';

part 'TodoWidget.dart';
part 'TodoApp.dart';
Expand All @@ -19,11 +19,12 @@ class Todo {
Todo(String this.id, String this.title, {bool this.completed : false});

Todo.fromJson(Map json) {
id = json['id'];
title = json['title'];
completed = json['completed'];
}
id = json['id'];
title = json['title'];
completed = json['completed'];
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation here looks a bit funny or is this just Github displaying it incorrectly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nop, it's me. Default tab in Dart's IDE has changed, I had to clean all my tabs, forgot these lines =/


// this is automatically called by JSON.encode
Map toJson() {
return {'id': id, 'title': title, 'completed': completed};
}
Expand Down