62 lines
1.6 KiB
Dart
62 lines
1.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:initial_folder/models/update_data_diri_model.dart';
|
|
import 'package:initial_folder/services/user_info_service.dart';
|
|
|
|
enum ResultState { loading, succes }
|
|
|
|
class UpdateDataDiriProvider with ChangeNotifier {
|
|
UpdateDataDiriModel? _updateDataDiriModel;
|
|
|
|
UpdateDataDiriModel? get updateDataDiriModel => _updateDataDiriModel;
|
|
ResultState? _state;
|
|
ResultState? get state => _state;
|
|
set updateDataDiriModel(UpdateDataDiriModel? _updateDataDiriModel) {
|
|
_updateDataDiriModel = updateDataDiriModel;
|
|
notifyListeners();
|
|
}
|
|
|
|
Future<bool> dataDiriUpdate(
|
|
{String? fullname,
|
|
String? biograph,
|
|
String? twitter,
|
|
String? facebook,
|
|
String? linkedin,
|
|
String? instagram,
|
|
String? datebirth,
|
|
String? phone,
|
|
String? gender,
|
|
String? headline,
|
|
String? email}) async {
|
|
try {
|
|
_state = ResultState.loading;
|
|
notifyListeners();
|
|
_updateDataDiriModel = await UserInfoService().updateDataDiri(
|
|
fullname: fullname,
|
|
biograph: biograph,
|
|
phone: phone,
|
|
// datebirth: datebirth,
|
|
// gender: gender,
|
|
facebook: facebook,
|
|
linkedin: linkedin,
|
|
twitter: twitter,
|
|
instagram: instagram,
|
|
headline: headline,
|
|
email: email,
|
|
);
|
|
if (_updateDataDiriModel != null) {
|
|
if (_updateDataDiriModel!.status == 200) {
|
|
_state = ResultState.succes;
|
|
notifyListeners();
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
} catch (e) {
|
|
print("Exception: $e");
|
|
_updateDataDiriModel = null;
|
|
return false;
|
|
}
|
|
}
|
|
}
|