AI Project Generator App in Flutter (One main.dart) | Cyber UI | Full Source Code
Demo :
Click Video πππ
✨ Features :
-
✅ One file Flutter app (main.dart)
-
✅ Fully responsive design
-
✅ Cyberpunk / hacker UI
-
✅ No backend required
-
✅ Best for final year students
-
✅ Short-form content friendly
Code :
import 'dart:math';
import 'dart:ui';
import 'package:flutter/material.dart';
void main() {
runApp(const CyberApp());
}
class CyberApp extends StatelessWidget {
const CyberApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'AI Project Generator',
theme: ThemeData.dark().copyWith(
scaffoldBackgroundColor: Colors.black,
primaryColor: Colors.cyanAccent,
colorScheme: const ColorScheme.dark(
primary: Colors.cyanAccent,
secondary: Colors.greenAccent,
surface: Colors.black,
),
),
home: const GeneratorPage(),
);
}
}
class GeneratorPage extends StatefulWidget {
const GeneratorPage({super.key});
@override
State<GeneratorPage> createState() => _GeneratorPageState();
}
class _GeneratorPageState extends State<GeneratorPage>
with SingleTickerProviderStateMixin {
late AnimationController _controller;
late Animation<double> _glowAnimation;
String _projectTitle = "PRESS GENERATE";
String _projectDescription = "System awaiting input...";
List<String> _techStack = ["AWAITING_DATA"];
bool _isGenerating = false;
final List<String> _prefixes = [
"Quantum", "Neural", "Cyber", "Hyper", "Nano", "Meta", "Omni", "Void", "Synthetix", "Flux"
];
final List<String> _nouns = [
"Engine", "Nexus", "Matrix", "Core", "Grid", "OS", "Mind", "Sphere", "Protocol", "Hive"
];
final List<String> _domains = [
"Automated Trading", "Biometric Security", "Sentient Chatbot", "Deepfake Detection",
"Predictive Analytics", "Autonomous Drone Swarm", "Holographic Interface",
"Smart City Grid", "Neural Network Visualizer", "Blockchain Health Record"
];
final List<String> _techs = [
"Flutter", "TensorFlow", "Python", "Rust", "WebAssembly", "GraphQL",
"Solidity", "Kubernetes", "OpenAI API", "Dart", "Go", "Docker"
];
@override
void initState() {
super.initState();
_controller = AnimationController(
vsync: this,
duration: const Duration(seconds: 2),
)..repeat(reverse: true);
_glowAnimation = Tween<double>(begin: 2.0, end: 15.0).animate(
CurvedAnimation(parent: _controller, curve: Curves.easeInOutQuad),
);
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
void _generateProject() async {
setState(() => _isGenerating = true);
// Simulate high-tech processing delay
await Future.delayed(const Duration(milliseconds: 600));
final random = Random();
final prefix = _prefixes[random.nextInt(_prefixes.length)];
final noun = _nouns[random.nextInt(_nouns.length)];
final domain = _domains[random.nextInt(_nouns.length)]; // Reuse len or nouns len
// Generate Tech Stack (3 random items)
final shuffledTechs = List<String>.from(_techs)..shuffle();
final selectedTechs = shuffledTechs.take(3).toList();
setState(() {
_projectTitle = "$prefix $noun $domain";
_projectDescription = "AI-driven $domain system powered by $prefix algorithms.";
_techStack = selectedTechs;
_isGenerating = false;
});
}
@override
Widget build(BuildContext context) {
// Responsive Logic:
// Using LayoutBuilder to determine constraints and switch layout modes/padding.
// Width < 600 ? Mobile Mode (Vertical, compacted) : Desktop Mode (Centered Card with more breathing room).
// Using FittedBox to ensure text never overflows.
return Scaffold(
body: Stack(
children: [
// Background Grid Effect (Custom Painter)
Positioned.fill(
child: CustomPaint(
painter: GridPainter(),
),
),
// Main Content
Center(
child: LayoutBuilder(
builder: (context, constraints) {
final isMobile = constraints.maxWidth < 600;
final cardWidth = isMobile ? constraints.maxWidth * 0.9 : 500.0;
final padding = isMobile ? 20.0 : 40.0;
return AnimatedBuilder(
animation: _glowAnimation,
builder: (context, child) {
return Container(
width: cardWidth,
padding: EdgeInsets.all(padding),
decoration: BoxDecoration(
color: Colors.black.withOpacity(0.85),
borderRadius: BorderRadius.circular(20),
border: Border.all(
color: Colors.cyanAccent.withOpacity(0.8),
width: 2,
),
boxShadow: [
BoxShadow(
color: Colors.cyanAccent.withOpacity(0.4),
blurRadius: _glowAnimation.value,
spreadRadius: 2,
),
BoxShadow(
color: Colors.greenAccent.withOpacity(0.2),
blurRadius: 30,
spreadRadius: 5,
),
],
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// Header
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Icon(Icons.terminal, color: Colors.greenAccent),
Text(
"AI_ARCHITECT // V.1.0",
style: TextStyle(
fontFamily: 'Courier',
fontSize: 12,
color: Colors.greenAccent.withOpacity(0.8),
letterSpacing: 2,
fontWeight: FontWeight.bold,
),
),
],
),
const SizedBox(height: 30),
// Project Title
FittedBox(
fit: BoxFit.scaleDown,
child: Text(
_projectTitle.toUpperCase(),
style: const TextStyle(
fontFamily: 'Courier',
fontSize: 32,
color: Colors.white,
fontWeight: FontWeight.bold,
shadows: [
Shadow(
color: Colors.cyanAccent,
blurRadius: 10,
),
],
),
),
),
const SizedBox(height: 20),
// Description
Container(
padding: const EdgeInsets.all(15),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.05),
borderRadius: BorderRadius.circular(10),
border: Border.all(
color: Colors.greenAccent.withOpacity(0.3),
),
),
child: Text(
_projectDescription,
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: 'Courier',
fontSize: 14,
height: 1.5,
color: Colors.grey[300],
),
),
),
const SizedBox(height: 20),
// Tech Stack List
Wrap(
alignment: WrapAlignment.center,
spacing: 10,
runSpacing: 10,
children: _techStack.map((tech) {
return Chip(
backgroundColor: Colors.transparent,
shape: const StadiumBorder(
side: BorderSide(color: Colors.cyanAccent),
),
label: Text(
tech,
style: const TextStyle(
color: Colors.cyanAccent,
fontFamily: 'Courier',
fontWeight: FontWeight.bold,
),
),
elevation: 5,
shadowColor: Colors.cyanAccent.withOpacity(0.3),
);
}).toList(),
),
const SizedBox(height: 40),
// Generate Button
InkWell(
onTap: _isGenerating ? null : _generateProject,
borderRadius: BorderRadius.circular(50),
child: Container(
height: 60,
decoration: BoxDecoration(
gradient: const LinearGradient(
colors: [Colors.cyan, Colors.greenAccent],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
borderRadius: BorderRadius.circular(50),
boxShadow: [
BoxShadow(
color: Colors.cyanAccent.withOpacity(0.6),
blurRadius: 15,
spreadRadius: 2,
)
],
),
child: Center(
child: _isGenerating
? const SizedBox(
height: 24,
width: 24,
child: CircularProgressIndicator(
color: Colors.black,
strokeWidth: 3,
),
)
: const Text(
"GENERATE PROJECT",
style: TextStyle(
fontFamily: 'Courier',
fontSize: 18,
fontWeight: FontWeight.w900,
color: Colors.black,
letterSpacing: 1.5,
),
),
),
),
),
],
),
);
},
);
},
),
),
],
),
);
}
}
// Custom Painter for Cyber Grid Background
class GridPainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
final paint = Paint()
..color = Colors.greenAccent.withOpacity(0.05)
..strokeWidth = 1;
const double spacing = 40;
for (double i = 0; i < size.width; i += spacing) {
canvas.drawLine(Offset(i, 0), Offset(i, size.height), paint);
}
for (double i = 0; i < size.height; i += spacing) {
canvas.drawLine(Offset(0, i), Offset(size.width, i), paint);
}
}
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) => false;
}
Comments
Post a Comment