@@ -120,53 +120,92 @@ class MyAppState extends State<MyApp> {
120120 body: Column (
121121 children: [
122122 const Text ('Methods:' ),
123- ElevatedButton (
124- child: const Text ('init' ),
125- onPressed: () async {
126- _logger.finer ('Initializing $baseName ' );
127- final authStorageSupport =
128- await _checkAuthenticate (_authStorageInitOptions);
129- if (authStorageSupport == CanAuthenticateResponse .unsupported) {
130- _logger.severe (
131- 'Unable to use authenticate. Unable to get storage.' );
132- return ;
133- }
134- final supportsAuthenticated = authStorageSupport ==
135- CanAuthenticateResponse .success ||
136- authStorageSupport == CanAuthenticateResponse .statusUnknown;
137- if (supportsAuthenticated) {
138- _authStorage = await BiometricStorage ().getStorage (
139- '${baseName }_authenticated' ,
140- options: _authStorageInitOptions,
141- );
142- }
143- _storage = await BiometricStorage ()
144- .getStorage ('${baseName }_unauthenticated' ,
145- options: StorageFileInitOptions (
146- authenticationRequired: false ,
147- ));
148- final supportsCustomPrompt =
149- await _checkAuthenticate (_customPromptInitOptions);
150- if (supportsCustomPrompt == CanAuthenticateResponse .success) {
151- _customPrompt = await BiometricStorage ()
152- .getStorage ('${baseName }_customPrompt' ,
153- options: _customPromptInitOptions,
154- promptInfo: const PromptInfo (
155- iosPromptInfo: IosPromptInfo (
156- saveTitle: 'Custom save title' ,
157- accessTitle: 'Custom access title.' ,
158- ),
159- androidPromptInfo: AndroidPromptInfo (
160- title: 'Custom title' ,
161- subtitle: 'Custom subtitle' ,
162- description: 'Custom description' ,
163- negativeButton: 'Nope!' ,
164- ),
165- ));
166- }
167- setState (() {});
168- _logger.info ('initiailzed $baseName ' );
169- },
123+ Row (
124+ mainAxisAlignment: MainAxisAlignment .spaceAround,
125+ children: [
126+ ElevatedButton (
127+ child: const Text ('init' ),
128+ onPressed: () async {
129+ _logger.finer ('Initializing $baseName ' );
130+ final authStorageSupport =
131+ await _checkAuthenticate (_authStorageInitOptions);
132+ if (authStorageSupport ==
133+ CanAuthenticateResponse .unsupported) {
134+ _logger.severe (
135+ 'Unable to use authenticate. Unable to get storage.' );
136+ return ;
137+ }
138+ final supportsAuthenticated =
139+ authStorageSupport == CanAuthenticateResponse .success ||
140+ authStorageSupport ==
141+ CanAuthenticateResponse .statusUnknown;
142+ if (supportsAuthenticated) {
143+ _authStorage = await BiometricStorage ().getStorage (
144+ '${baseName }_authenticated' ,
145+ options: _authStorageInitOptions,
146+ );
147+ }
148+ _storage = await BiometricStorage ()
149+ .getStorage ('${baseName }_unauthenticated' ,
150+ options: StorageFileInitOptions (
151+ authenticationRequired: false ,
152+ ));
153+ final supportsCustomPrompt =
154+ await _checkAuthenticate (_customPromptInitOptions);
155+ if (supportsCustomPrompt ==
156+ CanAuthenticateResponse .success) {
157+ _customPrompt = await BiometricStorage ()
158+ .getStorage ('${baseName }_customPrompt' ,
159+ options: _customPromptInitOptions,
160+ promptInfo: const PromptInfo (
161+ iosPromptInfo: IosPromptInfo (
162+ saveTitle: 'Custom save title' ,
163+ accessTitle: 'Custom access title.' ,
164+ ),
165+ androidPromptInfo: AndroidPromptInfo (
166+ title: 'Custom title' ,
167+ subtitle: 'Custom subtitle' ,
168+ description: 'Custom description' ,
169+ negativeButton: 'Nope!' ,
170+ ),
171+ ));
172+ }
173+ setState (() {});
174+ _logger.info ('initialized $baseName ' );
175+ },
176+ ),
177+ ElevatedButton (
178+ child: const Text ('Delete and dispose all' ),
179+ onPressed: () async {
180+ _logger.info ('Deleting and disposing all storages' );
181+ try {
182+ if (_authStorage != null ) {
183+ await _authStorage! .deleteAndDispose ();
184+ _authStorage = null ;
185+ _logger.finer (
186+ 'Deleted and disposed authenticated storage' );
187+ }
188+ if (_storage != null ) {
189+ await _storage! .deleteAndDispose ();
190+ _storage = null ;
191+ _logger.finer (
192+ 'Deleted and disposed unauthenticated storage' );
193+ }
194+ if (_customPrompt != null ) {
195+ await _customPrompt! .deleteAndDispose ();
196+ _customPrompt = null ;
197+ _logger.finer (
198+ 'Deleted and disposed custom prompt storage' );
199+ }
200+ setState (() {});
201+ _logger.info ('All storages deleted and disposed' );
202+ } catch (e) {
203+ _logger
204+ .severe ('Error deleting and disposing storages: $e ' );
205+ }
206+ },
207+ ),
208+ ],
170209 ),
171210 ...? _appArmorButton (),
172211 ...(_authStorage == null
0 commit comments