import 'package:flutter/material.dart';
import 'package:dart_e_shopee/business_logic/util/form_validator.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
class SignUpPage extends ConsumerStatefulWidget {
const SignUpPage({Key? key}) : super(key: key);
@override
_SignUpPageState createState() => _SignUpPageState();
}
class _SignUpPageState extends ConsumerState<SignUpPage> {
final _formKey = GlobalKey<FormState>();
var _email = '';
var _password = '';
var _confirmPassword = '';
var _isLoading = false;
void _submit() {
if (_formKey.currentState!.validate()) {
_formKey.currentState!.save();
// 执行注册逻辑
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Sign Up'),
),
body: _isLoading
? const Center(child: CircularProgressIndicator())
: Padding(
padding: const EdgeInsets.all(16.0),
child: Form(
key: _formKey,
child: Column(
children: [
TextFormField(
decoration: const InputDecoration(labelText: 'Email'),
validator: FormValidator.validateEmail,
onSaved: (value) => _email = value!,
),
const SizedBox(height: 10),
TextFormField(
decoration: const InputDecoration(labelText: 'Password'),
obscureText: true,
validator: FormValidator.validatePassword,
onSaved: (value) => _password = value!,
),
const SizedBox(height: 10),
TextFormField(
decoration: const InputDecoration(labelText: 'Confirm Password'),
obscureText: true,
validator: (value) => FormValidator.validateConfirmPassword(_password, value!),
onSaved: (value) => _confirmPassword = value!,
),
const SizedBox(height: 10),
评论已关闭