1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
| class _HomePageState extends State<HomePage> { late double deviceHeight, deviceWidth;
String? _newTaskContent;
_HomePageState();
@override Widget build(BuildContext context) { deviceHeight = MediaQuery.of(context).size.height; deviceWidth = MediaQuery.of(context).size.width; print("Input Value: $_newTaskContent"); return Scaffold( appBar: AppBar( backgroundColor: Colors.red, toolbarHeight: deviceHeight * 0.15, title: const Text( "Taskly!", style: TextStyle( fontSize: 25, color: Colors.white, ) ), ), body: _tasksList(), floatingActionButton: _addTaskButton(), ); }
Widget _tasksList() { return ListView( children: [ ListTile( title: Text( "Do Laundry!", style: TextStyle(decoration: TextDecoration.lineThrough), ), subtitle: Text(DateTime.now().toString()), trailing: const Icon( Icons.check_box_outlined, color: Colors.red, ), ), ], ); }
Widget _addTaskButton() { return FloatingActionButton( backgroundColor: Colors.red, shape: CircleBorder(), onPressed: () { _displayTaskPopup(context); }, child: const Icon( Icons.add, color: Colors.white, ), ); }
void _displayTaskPopup(BuildContext context) { showDialog( context: context, builder: (BuildContext context) { return AlertDialog( title: const Text("Add new Task"), content: TextField( onSubmitted: (value) { Navigator.pop(context); }, onChanged: (value) { setState(() { _newTaskContent = value; }); }, ), ); }, ); } }
|