Scaffold out initial state management

This commit is contained in:
2026-03-17 16:14:41 -05:00
parent d4b84e4d76
commit e92c62270c
4 changed files with 62 additions and 9 deletions

View File

@@ -1,42 +1,63 @@
import "util.dart";
import 'package:adventofcode2025/main.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import "days_enum.dart";
Future<void> selectFile() async {
print("Button Pushed");
Future<String?> selectFile() async {
debugLog("selectFile Button pushed");
FilePickerResult? result = await FilePicker.platform.pickFiles();
if (result != null) {
//File file = File(result.files.single.path!);
print(result.files.single.path!);
debugLog(result.files.single.path!);
return result.files.single.path;
} else {
// User canceled the picker
return null;
}
}
class DayPage extends StatelessWidget {
const DayPage({super.key});
final AdventOfCodeDays day;
const DayPage(this.day, {super.key});
@override
Widget build(BuildContext context) {
var state = context.watch<MyAppState>();
return Center(
child: Column(
children: [
Row(
children: [
TextButton(onPressed: selectFile, child: Text("Select Input")),
TextButton(
onPressed: () async {
var selectedFile = await selectFile();
state.setSelectedFile(day, selectedFile);
},
child: Text("Select Input"),
),
SizedBox(
width: 300,
child: TextField(
decoration: InputDecoration(
border: OutlineInputBorder(),
hintText: 'Input File Path',
//hintText: 'Input File Path',
hintText: state.getSelectedFile(day),
),
),
),
],
),
Row(
children: [TextButton(onPressed: selectFile, child: Text("Run"))],
children: [
TextButton(
onPressed: () async {
debugLog("RUNNING $day!");
},
child: Text("Run"),
),
],
),
Expanded(
child: Row(