import 'package:flutter/material.dart';
class PolishedUIScreen extends StatefulWidget {
@override
_PolishedUIScreenState createState() => _PolishedUIScreenState();
}
class _PolishedUIScreenState extends State<PolishedUIScreen> with SingleTickerProviderStateMixin {
late AnimationController _colorController;
late Animation<Color?> _colorAnimation;
late AnimationController _fadeController;
late Animation<double> _fadeAnimation;
@override
void initState() {
super.initState();
_colorController = AnimationController(
vsync: this,
duration: Duration(seconds: 3),
)..repeat(reverse: true);
_colorAnimation = ColorTween(
begin: Colors.blue.shade200,
end: Colors.purple.shade200,
).animate(_colorController);
_fadeController = AnimationController(
vsync: this,
duration: Duration(seconds: 2),
);
_fadeAnimation = CurvedAnimation(
parent: _fadeController,
curve: Curves.easeIn,
);
_fadeController.forward();
}
@override
void dispose() {
_colorController.dispose();
_fadeController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Polished UI Example')),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
decoration: BoxDecoration(
color: Colors.orange,
borderRadius: BorderRadius.circular(12),
boxShadow: [
BoxShadow(
color: Colors.orangeAccent.withOpacity(0.7),
blurRadius: 12,
spreadRadius: 1,
offset: Offset(0, 0),
),
],
),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.orange,
shadowColor: Colors.transparent,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
onPressed: () {},
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 24, vertical: 12),
child: Text('Glowing Button', style: TextStyle(fontSize: 18)),
),
),
),
SizedBox(height: 40),
AnimatedBuilder(
animation: _colorAnimation,
builder: (context, child) {
return Container(
width: 150,
height: 100,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16),
gradient: LinearGradient(
colors: [
_colorAnimation.value ?? Colors.blue.shade200,
Colors.white,
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
),
);
},
),
SizedBox(height: 40),
FadeTransition(
opacity: _fadeAnimation,
child: Text(
'Smooth Fade-in Text',
style: TextStyle(fontSize: 22, fontWeight: FontWeight.w600),
),
),
],
),
),
);
}
}
This screen uses Flutter animations and decorations to create a polished look:
- The button uses a
Container with BoxShadow to create a glowing effect around the orange button. - The container below uses an
AnimatedBuilder with a ColorTween to smoothly change its gradient colors every 3 seconds. - The text uses a
FadeTransition with an animation controller to fade in smoothly when the screen loads.
These small touches make the UI feel lively and professional, showing how advanced UI features improve app polish.