flutter_profile/lib/src/services/profile_service.dart

30 lines
887 B
Dart
Raw Normal View History

import 'package:flutter/material.dart';
2022-08-26 15:31:42 +02:00
import 'package:profile/profile.dart';
2022-09-20 14:11:38 +02:00
/// ProfileService can be extended and set for the profilePage. The following method can be overriden.
///
/// DeleteProfile is called when the user want to delete their profile.
///
/// EditProfile is called when a user changes and submits a standard textfields.
///
/// UploadImage is called when te user presses the avatar.
2022-08-26 16:28:40 +02:00
abstract class ProfileService {
2022-08-26 15:31:42 +02:00
const ProfileService();
2022-09-21 09:20:15 +02:00
deleteProfile() async {}
2022-08-26 15:31:42 +02:00
2022-09-21 09:20:15 +02:00
editProfile<T extends ProfileData>(
User user, String key, String value) async {
2022-08-26 15:31:42 +02:00
if (user.profileData != null) {
var map = user.profileData!.toMap();
if (map.containsKey(key)) {
map[key] = value;
var profile = user.profileData!.create();
user.profileData = profile.fromMap(map);
}
}
}
uploadImage(BuildContext context) async {}
2022-08-26 15:31:42 +02:00
}