@page "/todo" @using BlazorHybridWithMAUI.Data @using System.Text.Json

Todo (@_todos.Count(t => !t.IsDone))

@code { private const string SAVE_FILE_NAME = "todo.json"; private List _todos = new List(); private string? newTodo; private void AddTodo() { if (string.IsNullOrEmpty(newTodo)) return; _todos.Add(new TodoItem() { Title = newTodo }); newTodo = string.Empty; } private async Task Save() { var contents = JsonSerializer.Serialize(_todos); var path = Path.Combine(FileSystem.AppDataDirectory, SAVE_FILE_NAME); File.WriteAllText(path, contents); await App.Current.MainPage.DisplayAlert("List Saved.", $"List has been saved to {path}", "OK"); } private void Load() { var path = Path.Combine(FileSystem.AppDataDirectory, SAVE_FILE_NAME); if (!File.Exists(path)) return; var contents = File.ReadAllText(path); var savedItems = JsonSerializer.Deserialize>(contents); _todos.Clear(); _todos.AddRange(savedItems); } }