close
0

Flutter. Check if a file exists before loading it

avatar
asked 13-09-2021

2 Answers


0

in internal local storage of the app use:

import 'dart:io' as io;
var syncPath = await path;
// for a file
io.File(syncPath).exists();
// for a directory
io.Directory(syncPath).exists();
avatar
answered 14-09-2021

0

simply worked this:

import 'dart:io';
File("path/to/file").exists() 

or, for checking it synchronously

import 'dart:io';
File("path/to/file").existsSync()
avatar
answered 14-09-2021