Last active
January 12, 2026 15:41
-
-
Save Rodsevich/07829fd5d8381c58398d33440625e9b4 to your computer and use it in GitHub Desktop.
ejecrcio 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter/material.dart'; | |
| import 'dart:math'; // Para números aleatorios | |
| import 'dart:async'; // Para Timers (Niveles avanzados) | |
| void main() { | |
| runApp(const MyApp()); | |
| } | |
| class MyApp extends StatelessWidget { | |
| const MyApp({super.key}); | |
| @override | |
| Widget build(BuildContext context) { | |
| return MaterialApp( | |
| debugShowCheckedModeBanner: false, | |
| theme: ThemeData( | |
| primarySwatch: Colors.indigo, | |
| useMaterial3: true, | |
| scaffoldBackgroundColor: Colors.grey[100], | |
| ), | |
| home: const LogicPlayground(), | |
| ); | |
| } | |
| } | |
| class LogicPlayground extends StatefulWidget { | |
| const LogicPlayground({super.key}); | |
| @override | |
| State<LogicPlayground> createState() => _LogicPlaygroundState(); | |
| } | |
| class _LogicPlaygroundState extends State<LogicPlayground> { | |
| // --- ZONA DE TRABAJO (VARIABLES) --- | |
| // Aquí declararán sus variables para cada nivel | |
| String mensaje = "¡Listo para programar!"; | |
| Color colorFondo = Colors.white; | |
| IconData iconoCentral = Icons.code; | |
| // --- ZONA DE TRABAJO (LÓGICA) --- | |
| void accionPrincipal() { | |
| setState(() { | |
| // Aquí va la lógica del ejercicio | |
| mensaje = "¡Botón presionado!"; | |
| }); | |
| } | |
| @override | |
| Widget build(BuildContext context) { | |
| return Scaffold( | |
| backgroundColor: colorFondo, | |
| appBar: AppBar(title: const Text("Logic Playground 🚀")), | |
| body: Center( | |
| child: Padding( | |
| padding: const EdgeInsets.all(20.0), | |
| child: Column( | |
| mainAxisAlignment: MainAxisAlignment.center, | |
| children: [ | |
| // Área visual dinámica | |
| Container( | |
| padding: const EdgeInsets.all(30), | |
| decoration: BoxDecoration( | |
| color: Colors.white.withOpacity(0.8), | |
| borderRadius: BorderRadius.circular(20), | |
| boxShadow: [ | |
| BoxShadow(color: Colors.black12, blurRadius: 10, spreadRadius: 2) | |
| ] | |
| ), | |
| child: Column( | |
| children: [ | |
| Icon(iconoCentral, size: 80, color: Colors.indigo), | |
| const SizedBox(height: 20), | |
| Text( | |
| mensaje, | |
| textAlign: TextAlign.center, | |
| style: const TextStyle(fontSize: 24, fontWeight: FontWeight.bold, color: Colors.black87), | |
| ), | |
| ], | |
| ), | |
| ), | |
| const SizedBox(height: 40), | |
| // Botón de acción | |
| SizedBox( | |
| width: double.infinity, | |
| height: 60, | |
| child: ElevatedButton.icon( | |
| onPressed: accionPrincipal, | |
| icon: const Icon(Icons.play_circle_fill), | |
| label: const Text("EJECUTAR LÓGICA", style: TextStyle(fontSize: 18)), | |
| style: ElevatedButton.styleFrom( | |
| elevation: 5, | |
| shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)), | |
| ), | |
| ), | |
| ), | |
| const SizedBox(height: 20), | |
| // Botón secundario (opcional para reiniciar) | |
| TextButton( | |
| onPressed: () { | |
| // Útil para reiniciar ejercicios | |
| setState(() { | |
| mensaje = "Reiniciado"; | |
| colorFondo = Colors.white; | |
| }); | |
| }, | |
| child: const Text("Reiniciar Estado") | |
| ) | |
| ], | |
| ), | |
| ), | |
| ), | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment