2019-01-06 02:08:31 +00:00
|
|
|
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);
|
|
|
|
|
2021-04-10 13:22:20 +00:00
|
|
|
var users = await (userService.index() as FutureOr<List<User>>);
|
2019-01-06 02:08:31 +00:00
|
|
|
print('Name: ${users.first.name}');
|
|
|
|
}
|
|
|
|
|
|
|
|
class User {
|
2021-04-10 13:22:20 +00:00
|
|
|
final String? name;
|
2019-01-06 02:08:31 +00:00
|
|
|
|
|
|
|
User({this.name});
|
|
|
|
|
2021-04-10 13:22:20 +00:00
|
|
|
static User fromMap(Map data) => User(name: data['name'] as String?);
|
2019-01-06 02:08:31 +00:00
|
|
|
|
2021-04-10 13:22:20 +00:00
|
|
|
static Map<String, String?> toMap(User user) => {'name': user.name};
|
2019-01-06 02:08:31 +00:00
|
|
|
}
|