flutter写一个漂亮的登录界面
以下是一个简单的Flutter登录界面示例,使用了Material Design和一些简单的动画:
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: LoginPage(),
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
),
);
}
}
class LoginPage extends StatefulWidget {
@override
_LoginPageState createState() => _LoginPageState();
}
class _LoginPageState extends State<LoginPage> with TickerProviderStateMixin {
AnimationController _controller;
Animation<Offset> _slideAnimation;
@override
void initState() {
super.initState();
_controller = AnimationController(
vsync: this,
duration: Duration(milliseconds: 300),
);
_slideAnimation = Tween<Offset>(
begin: Offset(0, 1),
end: Offset(0, 0),
).animate(_controller);
_controller.forward();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
fit: StackFit.expand,
children: <Widget>[
Image.asset(
'assets/background.jpg',
fit: BoxFit.cover,
alignment: Alignment.center,
),
SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
SizedBox(height: 100.0),
Image.asset(
'assets/logo.png',
width: 200.0,
height: 200.0,
),
SizedBox(height: 30.0),
AnimatedBuilder(
animation: _controller,
builder: (context, child) {
return SlideTransition(
position: _slideAnimation,
child: child,
);
},
child: Padding(
padding: const EdgeInsets.all(30.0),
child: Column(
children: <Widget>[
TextField(
decoration: InputDecoration(
hintText: 'Enter your email',
),
),
SizedBox(height: 20.0),
评论已关闭