我無法洗掉TextField. Lottie.asset在我的頂部添加一個TextField解決了這個問題,但用戶需要滾動才能看到整個頁面。
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:lottie/lottie.dart';
import 'package:email_validator/email_validator.dart';
final _emailController = TextEditingController();
bool _isValid = false;
class SignUpPage extends StatelessWidget {
const SignUpPage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.grey.shade200,
appBar: AppBar(
centerTitle: true,
backgroundColor: Colors.transparent,
elevation: 0,
leading: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: const Icon(
Icons.arrow_back_ios,
color: Colors.black,
),
),
title: const Text(
'Inscription',
style: TextStyle(
fontSize: 16,
color: Colors.black,
),
textAlign: TextAlign.center,
),
),
body: SingleChildScrollView(
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 40),
height: MediaQuery.of(context).size.height - 50,
width: double.infinity,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround, //ERROR WAS HERE
children: <Widget>[
const Text(
"Créez un compte gratuitement \net commencez à explorer les \nstudios partenaires.",
style: TextStyle(
fontSize: 16, color: Color.fromARGB(255, 0, 0, 0)),
textAlign: TextAlign.center),
const TextField(
decoration: InputDecoration(
border: OutlineInputBorder(),
hintText: 'Nom',
),
),
TextField(
controller: _emailController,
keyboardType: TextInputType.emailAddress,
decoration: const InputDecoration(
border: OutlineInputBorder(),
hintText: 'Email',
),
),
const TextField(
decoration: InputDecoration(
border: OutlineInputBorder(),
hintText: 'Mot de passe',
),
),
const TextField(
decoration: InputDecoration(
border: OutlineInputBorder(),
hintText: 'Confirmer le mot de passe',
),
),
TextButton(
child: const Text(
'Valider',
style: TextStyle(color: Color.fromARGB(255, 0, 0, 0)),
),
onPressed: () {
_isValid = EmailValidator.validate(_emailController.text);
if (_isValid) {
Fluttertoast.showToast(
msg: "Email ",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.TOP,
timeInSecForIosWeb: 1,
fontSize: 16.0);
} else if (_emailController.text.isEmpty) {
Fluttertoast.showToast(
msg: 'Entrez un email',
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.TOP,
timeInSecForIosWeb: 1,
fontSize: 16.0);
} else {
Fluttertoast.showToast(
msg: 'Veuillez fournir un email valide',
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.TOP,
timeInSecForIosWeb: 1,
fontSize: 16.0);
}
},
),
],
),
),
),
);
}
}
它的樣子:

uj5u.com熱心網友回復:
從 Column 小部件中洗掉此行并在每個 TextField 之間添加 SizedBox 以控制小部件之間的空間
mainAxisAlignment: MainAxisAlignment.spaceAround,
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/469459.html
上一篇:在顫動中保存兩個用戶聊天時出錯
