修复flutter analyze提示,更新版本至v1.0.0-Beta4.8
This commit is contained in:
@@ -12,7 +12,7 @@ class LoginPage extends StatefulWidget {
|
||||
const LoginPage({super.key});
|
||||
|
||||
@override
|
||||
_LoginPageState createState() => _LoginPageState();
|
||||
State<LoginPage> createState() => _LoginPageState();
|
||||
}
|
||||
|
||||
class _LoginPageState extends State<LoginPage> {
|
||||
@@ -64,9 +64,9 @@ class _LoginPageState extends State<LoginPage> {
|
||||
if (!mounted) {
|
||||
return;
|
||||
}
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(l10n.networkError)),
|
||||
);
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text(l10n.networkError)));
|
||||
} finally {
|
||||
if (mounted) setState(() => _isLoading = false);
|
||||
}
|
||||
@@ -177,7 +177,7 @@ class _LoginPageState extends State<LoginPage> {
|
||||
TextButton(
|
||||
onPressed: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => RegisterPage()),
|
||||
MaterialPageRoute(builder: (_) => const RegisterPage()),
|
||||
),
|
||||
child: Text(l10n.dontHaveAccount),
|
||||
),
|
||||
|
||||
@@ -6,8 +6,10 @@ import '../providers/settings_provider.dart';
|
||||
import '../services/api_service.dart';
|
||||
|
||||
class RegisterPage extends StatefulWidget {
|
||||
const RegisterPage({super.key});
|
||||
|
||||
@override
|
||||
_RegisterPageState createState() => _RegisterPageState();
|
||||
State<RegisterPage> createState() => _RegisterPageState();
|
||||
}
|
||||
|
||||
class _RegisterPageState extends State<RegisterPage> {
|
||||
@@ -18,7 +20,9 @@ class _RegisterPageState extends State<RegisterPage> {
|
||||
void _handleRegister() async {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
if (_usernameController.text.isEmpty || _passwordController.text.isEmpty) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(l10n.fillAllFields)));
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text(l10n.fillAllFields)));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -27,16 +31,32 @@ class _RegisterPageState extends State<RegisterPage> {
|
||||
final api = ApiService(settings, null);
|
||||
|
||||
try {
|
||||
final response = await api.register(_usernameController.text, _passwordController.text);
|
||||
final response = await api.register(
|
||||
_usernameController.text,
|
||||
_passwordController.text,
|
||||
);
|
||||
if (!mounted) {
|
||||
return;
|
||||
}
|
||||
if (response.statusCode == 201) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(l10n.accountCreated)));
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text(l10n.accountCreated)));
|
||||
Navigator.pop(context);
|
||||
} else {
|
||||
final error = jsonDecode(response.body)['error'] ?? "Registration Failed";
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(error)));
|
||||
final error =
|
||||
jsonDecode(response.body)['error'] ?? "Registration Failed";
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text(error)));
|
||||
}
|
||||
} catch (e) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(l10n.networkError)));
|
||||
if (!mounted) {
|
||||
return;
|
||||
}
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text(l10n.networkError)));
|
||||
} finally {
|
||||
if (mounted) setState(() => _isLoading = false);
|
||||
}
|
||||
@@ -55,11 +75,17 @@ class _RegisterPageState extends State<RegisterPage> {
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.person_add_outlined, size: 64, color: Theme.of(context).colorScheme.primary),
|
||||
Icon(
|
||||
Icons.person_add_outlined,
|
||||
size: 64,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Text(
|
||||
l10n.joinHightube,
|
||||
style: Theme.of(context).textTheme.headlineMedium?.copyWith(fontWeight: FontWeight.bold),
|
||||
style: Theme.of(context).textTheme.headlineMedium?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 48),
|
||||
TextField(
|
||||
@@ -67,7 +93,9 @@ class _RegisterPageState extends State<RegisterPage> {
|
||||
decoration: InputDecoration(
|
||||
labelText: l10n.desiredUsername,
|
||||
prefixIcon: const Icon(Icons.person),
|
||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12)),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
@@ -77,7 +105,9 @@ class _RegisterPageState extends State<RegisterPage> {
|
||||
decoration: InputDecoration(
|
||||
labelText: l10n.password,
|
||||
prefixIcon: const Icon(Icons.lock),
|
||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12)),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
@@ -87,9 +117,16 @@ class _RegisterPageState extends State<RegisterPage> {
|
||||
child: ElevatedButton(
|
||||
onPressed: _isLoading ? null : _handleRegister,
|
||||
style: ElevatedButton.styleFrom(
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
child: _isLoading ? const CircularProgressIndicator() : Text(l10n.register, style: const TextStyle(fontWeight: FontWeight.bold)),
|
||||
child: _isLoading
|
||||
? const CircularProgressIndicator()
|
||||
: Text(
|
||||
l10n.register,
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
@@ -393,7 +393,7 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||
),
|
||||
Text(
|
||||
"Version: 1.0.0-beta4.1",
|
||||
"Version: 1.0.0-beta4.8",
|
||||
style: TextStyle(color: Colors.grey),
|
||||
),
|
||||
Text(
|
||||
|
||||
Reference in New Issue
Block a user