mobile_skt/lib/screens/mine/useinfo/userinfo.controller.dart

29 lines
1009 B
Dart

import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:sk_base_mobile/models/user_info.model.dart';
import 'package:sk_base_mobile/store/auth.store.dart';
import 'package:sk_base_mobile/apis/api.dart' as Api;
class UserInfoController extends GetxController {
final nickNameController = TextEditingController(text: '');
final countryController = TextEditingController(text: '');
final birthdayController = TextEditingController();
@override
void onReady() async {
nickNameController.text = AuthStore.to.userInfo.value.nickname ?? '';
birthdayController.text = AuthStore.to.userInfo.value.birthday ?? '';
countryController.text = AuthStore.to.userInfo.value.country ?? '';
super.onReady();
}
Future<void> saveUserInfo() async {
Map<String, dynamic> data = {
'nickname': nickNameController.text,
'birthday': birthdayController.text,
'country': countryController.text,
};
await AuthStore.to.saveUserInfo(data);
}
}