platform/packages/client/example/main.dart
Tobe O 998aa62303 Add 'packages/client/' from commit '180edbc46a556f6d572c3b4ade4b396a31a1bc42'
git-subtree-dir: packages/client
git-subtree-mainline: ae0afd3408
git-subtree-split: 180edbc46a
2020-02-15 18:28:35 -05:00

21 lines
513 B
Dart

import 'dart:async';
import 'package:angel_client/angel_client.dart';
Future doSomething(Angel app) async {
var userService = app
.service<String, Map<String, dynamic>>('api/users')
.map(User.fromMap, User.toMap);
var users = await userService.index();
print('Name: ${users.first.name}');
}
class User {
final String name;
User({this.name});
static User fromMap(Map data) => User(name: data['name'] as String);
static Map<String, String> toMap(User user) => {'name': user.name};
}