I created a file user.json
in the folder ./assets/
.
Then I call:
File file = File('./assets/user.json');
final futureContent = file.readAsString();
futureContent.then((c) => print(c));
But getting exception:
PathNotFoundException (PathNotFoundException: Cannot open file, path = './assets/user.json' (OS Error: No such file or directory, errno = 2))
Absolute path not working as well.
I also tried this way:
import 'package:path/path.dart' as p;
void main() {
var filePath = p.join(Directory.current.path, 'assets', 'user.json');
File file = File(filePath);
final futureContent = file.readAsString();
futureContent.then((c) => print(c));
}
Still the same error.