concept Expense in category dart

This is an excerpt from Manning's book Dart in Action.
We’ll look at event handlers in more detail in the next major section, but for now you need to know that the event handler calls a top-level library navigate(ViewType, int id) function. The interesting part is that the anonymous event-handler function (shown in italic in listing 10.4) that calls navigate() forms a closure around the specific expense object passed to _getRowElement(ex). This is because although the method exits, the event handler retains a reference to the ex.id value (see chapter 4 for more discussion on closures). The ex.id value is an autogenerated number on the Expense class that’s required by the navigate() function along with the name of the view to which you currently want to navigate.
This call stores the data passed in the first parameter "edit/1" as state information in the browser’s history. For the DartExpense app, this represents viewName/idValue, but it can be any text data to represent the current state of the app. DartExpense understands that "edit/1" means you’re in the edit view, editing an Expense with ID 1. When the user clicks the Save or Cancel button, you call pushState() again, storing the state data "list" without any ID.
In JavaScript, objects are maps of key/value pairs rather than instances of real classes as in Dart. The JSON data format, which is prevalent around the web, represents a JavaScript data structure that doesn’t map directly to Dart’s class model. Instead, it converts to Dart’s Map class, which contains key/value pairs. In order to convert your Expense and ExpenseType classes to JSON, you need to convert the list of properties in each class to a map. This map can then be passed into JSON.stringify() to convert the map to a JSON string.
which will work for most purposes. The following listing shows the toMap() methods of the Expense and ExpenseType classes.