| OLD | NEW |
| (Empty) |
| 1 /** | |
| 2 * Mock implementation of the data service library. | |
| 3 */ | |
| 4 library dataservice; | |
| 5 | |
| 6 import 'dart:async'; | |
| 7 | |
| 8 // List of fake companies | |
| 9 List _companies = [ | |
| 10 { | |
| 11 'id': 100001, | |
| 12 'name': 'Company 100001', | |
| 13 'revenue': 3000000.00 | |
| 14 }, | |
| 15 { | |
| 16 'id': 111111, | |
| 17 'name': 'Company 1111111', | |
| 18 'revenue': 1001100.00 | |
| 19 }, | |
| 20 { | |
| 21 'id': 100003, | |
| 22 'name': 'Mom & Pop Shop', | |
| 23 'revenue': 201000.00 | |
| 24 }, | |
| 25 { | |
| 26 'id': 333333, | |
| 27 'name': 'Sunny & Bob', | |
| 28 'revenue': 301000.00 | |
| 29 }, | |
| 30 { | |
| 31 'id': 444444, | |
| 32 'name': 'Sun In the Sky Inc.', | |
| 33 'revenue': 5001000.00 | |
| 34 }, | |
| 35 { | |
| 36 'id': 555555, | |
| 37 'name': 'Sunny Java', | |
| 38 'revenue': 401000.00 | |
| 39 } | |
| 40 ]; | |
| 41 | |
| 42 /// simulate an RPC call to fetch companies | |
| 43 Future<List<Map>> fetchCompanies(String query) => | |
| 44 new Future.delayed(new Duration(milliseconds: 500), () => | |
| 45 _companies.where((company) => | |
| 46 company['name'].toLowerCase().indexOf(query.toLowerCase()) > -1)); | |
| 47 | |
| 48 /// simulate an RPC call to fetch a company | |
| 49 Future<Map> fetchCompany(int id) => | |
| 50 new Future.delayed(new Duration(seconds: 1), () => | |
| 51 _companies.firstWhere((c) => c['id'] == id, orElse: () => null)); | |
| OLD | NEW |