@@ -67,12 +67,21 @@ class _GrantedUriCardState extends State<GrantedUriCard> {
6767 ),
6868 ),
6969 ActionButton (
70- 'Open tree here' ,
70+ 'Open file picker here' ,
7171 onTap: () => openDocumentTree (initialUri: widget.permissionUri.uri),
7272 )
7373 ];
7474 }
7575
76+ @override
77+ void didUpdateWidget (covariant GrantedUriCard oldWidget) {
78+ super .didUpdateWidget (oldWidget);
79+
80+ documentFile = null ;
81+ loading = false ;
82+ error = null ;
83+ }
84+
7685 DocumentFile ? documentFile;
7786 bool loading = false ;
7887 String ? error;
@@ -97,11 +106,17 @@ class _GrantedUriCardState extends State<GrantedUriCard> {
97106 }
98107 }
99108
109+ VoidCallback get _onTapHandler => widget.permissionUri.isTreeDocumentFile
110+ ? _openListFilesPage
111+ : _showDocumentFileContents;
112+
100113 List <Widget > _getDocumentAvailableOptions () {
101114 return [
102115 ActionButton (
103- 'Open document' ,
104- onTap: _showDocumentFileContents,
116+ widget.permissionUri.isTreeDocumentFile
117+ ? 'Open folder'
118+ : 'Open document' ,
119+ onTap: _onTapHandler,
105120 ),
106121 ActionButton (
107122 'Load extra document data linked to this permission' ,
@@ -114,9 +129,8 @@ class _GrantedUriCardState extends State<GrantedUriCard> {
114129 return Wrap (
115130 children: [
116131 if (widget.permissionUri.isTreeDocumentFile)
117- ..._getTreeAvailableOptions ()
118- else
119- ..._getDocumentAvailableOptions (),
132+ ..._getTreeAvailableOptions (),
133+ ..._getDocumentAvailableOptions (),
120134 Padding (padding: k2dp.all),
121135 DangerButton (
122136 'Revoke' ,
@@ -143,9 +157,7 @@ class _GrantedUriCardState extends State<GrantedUriCard> {
143157 @override
144158 Widget build (BuildContext context) {
145159 return SimpleCard (
146- onTap: widget.permissionUri.isTreeDocumentFile
147- ? _openListFilesPage
148- : _showDocumentFileContents,
160+ onTap: _onTapHandler,
149161 children: [
150162 Padding (
151163 padding: k2dp.all.copyWith (top: k8dp, bottom: k8dp),
0 commit comments