Initial commit: Penyerahan final Source code Tugas Akhir
This commit is contained in:
61
lib/providers/update_data_diri_provider.dart
Normal file
61
lib/providers/update_data_diri_provider.dart
Normal file
@ -0,0 +1,61 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user