Flutter Developer
I created the login page and it worked fine until I created the sign_up page. The problem is that when I Signup it says success, but when I check Auth, the account is still not created. I searched on sources and documents. Hope you can take a look at the code and help me?
import 'package:appwrite/appwrite.dart';
import 'package:flutter/material.dart';
import 'package:uuid/uuid.dart';
// Tạo một đối tượng UUID
var uuid = Uuid();
// Tạo một chuỗi UUID duy nhất
String userId = uuid.v4();
class SignupPage extends StatefulWidget {
final Client? client;
SignupPage({Key? key, this.client}) : super(key: key);
@override
_SignupPageState createState() => _SignupPageState();
}
class _SignupPageState extends State {
final TextEditingController _emailController = TextEditingController();
final TextEditingController _passwordController = TextEditingController();
final TextEditingController _nameController = TextEditingController();
Future _signup() async {
try {
final email = _emailController.text;
final password = _passwordController.text;
final name = _nameController.text;
print('Email: $email');
print('Password: $password');
print('Name: $name');
print('UserId: $userId');
final account = Account(widget.client ?? Client());
// Loại bỏ tham số phone từ đây
// await account.createPhoneSession(userId: userId, phone: phone);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Đăng ký thành công!'),
),
);
} on AppwriteException catch (e) {
print('Lỗi từ server: ${e.message}');
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Đăng ký không thành công!'),
),
);
}
}