make back gesture work properly

This commit is contained in:
RafayAhmad7548 2025-08-08 10:33:42 +05:00
parent 23cd60701c
commit e86324fa55

View file

@ -78,7 +78,7 @@ class _SftpExplorerState extends State<SftpExplorer> {
), ),
IconButton( IconButton(
onPressed: () { onPressed: () {
// TODO: show donwload details here
}, },
icon: Icon(Icons.upload) icon: Icon(Icons.upload)
), ),
@ -87,7 +87,16 @@ class _SftpExplorerState extends State<SftpExplorer> {
], ],
), ),
floatingActionButton: _buildFABs(context), floatingActionButton: _buildFABs(context),
body: AnimatedSwitcher( body: PopScope(
canPop: false,
onPopInvokedWithResult: (_, _) {
if (path != '/') {
path = path.substring(0, path.length - 1);
path = path.substring(0, path.lastIndexOf('/')+1);
_listDir();
}
},
child: AnimatedSwitcher(
duration: Duration(milliseconds: 300), duration: Duration(milliseconds: 300),
transitionBuilder: (child, animation) { transitionBuilder: (child, animation) {
final curved = CurvedAnimation( final curved = CurvedAnimation(
@ -224,6 +233,7 @@ class _SftpExplorerState extends State<SftpExplorer> {
); );
}, },
) )
),
) )
); );
} }
@ -252,7 +262,7 @@ class _SftpExplorerState extends State<SftpExplorer> {
TextButton( TextButton(
onPressed: () async { onPressed: () async {
try { try {
await widget.sftpWorker.mkdir('${path}${nameController.text}'); await widget.sftpWorker.mkdir('$path${nameController.text}');
_listDir(); _listDir();
} }
catch (e) { catch (e) {