So this is my razor code file
@inject Blazored.LocalStorage.ILocalStorageService localStoragevar test = await localStorage.GetItemAsync<String>("MyKey");And this WORKS.
So i need to get the data into Utility.cs class
internal class Utility { protected readonly ILocalStorageService _localStorage; public Utility(ILocalStorageService LocalStorage) { _localStorage = LocalStorage; } public async Task updateLocalStorage() { await _localStorage.SetItemAsync("test", "123"); } public async Task getLocalStorage() { ResponseLogin login = await _localStorage.GetItemAsync<ResponseLogin>(LocalStorageNames.ResponseLogin); } }and into MauiProgram.cs i added this:
builder.Services.AddScoped(p => new Utility(p.GetRequiredService<ILocalStorageService>()));But, i didn't understand why my Utility class keep null when i start.. i can't understand how to init this class
Utility _utility = new Utility(????);Any help? I need to use this class like a singletonAlso tried this:
[Inject]public blazored.LocalStorage.ILocalStorageService localStorage { get; set;}But always null...