how to add text file in asset folder in flutter and read all data from it. I already have an external text file with data in it. I just need to add it in assets folder and start reading from it. but how?
Asked
Active
Viewed 140 times
1
-
Read the ["Loading text assets"](https://flutter.io/docs/development/ui/assets-and-images) section from this documentation article. – soupjake Dec 04 '18 at 15:39
-
Future
loadAsset() async { return await rootBundle.loadString('assets/config.json'); } – Muhammad Hassan Dec 04 '18 at 15:42 -
but its .json. my file is .txt – Muhammad Hassan Dec 04 '18 at 15:42
-
do i need to convert it to .json first??? – Muhammad Hassan Dec 04 '18 at 15:43
-
Nah should be fine as a .txt. Try it! – soupjake Dec 04 '18 at 15:44
-
ok thanks. i am giving it a try – Muhammad Hassan Dec 04 '18 at 15:45
-
thanks. it is working perfectly fine. – Muhammad Hassan Dec 04 '18 at 15:59