platform/packages/client/example/main.dart
2024-10-12 03:35:14 -07:00

21 lines
547 B
Dart

import 'dart:async';
import 'package:angel3_client/angel3_client.dart';
Future doSomething(Protevus app) async {
var userService = app
.service<String, Map<String, dynamic>>('api/users')
.map(User.fromMap, User.toMap);
var users = await (userService.index() as FutureOr<List<User>>);
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};
}