import 'dart:convert'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import '../../oath/models.dart'; final androidStateProvider = StateNotifierProvider<_StateProvider, OathState?>((ref) { return _StateProvider(null); }); class _StateProvider extends StateNotifier { _StateProvider(OathState? oathState) : super(oathState); void setFromString(String input) { var resultJson = jsonDecode(input); state = OathState.fromJson(resultJson); } } final androidCredentialsProvider = StateNotifierProvider<_CredentialsProvider, List?>((ref) { return _CredentialsProvider(null); }); class _CredentialsProvider extends StateNotifier?> { _CredentialsProvider(List? credentials) : super(credentials); void setFromString(String input) { var result = jsonDecode(input); if (result is List) { state = result.map((e) => OathPair.fromJson(e)).toList(); } else { state = []; } } }