how to get a list of files from the directory and pass it to the ListView?Flutter - Implementing a Navigation drawer with a TabBarView widget with dynamic Tab viewFlutter : Can I add a Header Row to a ListViewHow to offset a scaffold widget in Flutter?How to pass List in ImageCarousel?How to pass List _data from main() to Stateful widget (LIstView)?How I can put Widget above Widget using List<Widget> widget in Flutter?How to make Flutter DropDownButton's items window scrollable?passing a listView to another screenFlutter: Image.file won't read image file after taking photo with camera pluginHow to import all Dart files from a Directory?

Are these intended activities legal to do in the USA under the VWP?

Does “comme on était à New York” mean “since” or “as though”?

Is it bad to describe a character long after their introduction?

What is a macro? Difference between macro and function?

How much time passes before we understand that the drought hasn’t ended?

Is this hogweed?

What is the line crossing the Pacific Ocean that is shown on maps?

Details of video memory access arbitration in Space Invaders

How fast can a ship with rotating habitats be accelerated?

Acceleration in Circular motion

Why do I need two parameters in an HTTP parameter pollution attack?

Are metaheuristics ever practical for continuous optimization?

Avoid using C Strings on C++ code to trim leading whitespace

How would an order of Monks that renounce their names communicate effectively?

Do I have to roll to maintain concentration if a target other than me who is affected by my concentration spell takes damage?

How can I convince my reader that I will not use a certain trope?

Different budgets within roommate group

What exactly is a fey/fiend/celestial spirit?

Why isn’t the tax system continuous rather than bracketed?

How do accents of a whole town drift?

The Starks, Parks, Clarks and their kids

Do space suits measure "methane" levels or other biological gases?

What is the difference between handcrafted and learned features

Why does a brace command group need spaces after the opening brace in POSIX Shell Grammar?



how to get a list of files from the directory and pass it to the ListView?


Flutter - Implementing a Navigation drawer with a TabBarView widget with dynamic Tab viewFlutter : Can I add a Header Row to a ListViewHow to offset a scaffold widget in Flutter?How to pass List in ImageCarousel?How to pass List _data from main() to Stateful widget (LIstView)?How I can put Widget above Widget using List<Widget> widget in Flutter?How to make Flutter DropDownButton's items window scrollable?passing a listView to another screenFlutter: Image.file won't read image file after taking photo with camera pluginHow to import all Dart files from a Directory?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I get the list of files from the user's folder. The names of the files I transfer to the ListView.builder. It's work, but I think, this is bad architecture.



A method _getFilesFromDir() call with a high frequency.



How to make the correct list generation, so as not to update the interface without changing the file list?



class CharacteristList extends StatefulWidget 
@override
_CharacteristListState createState() => new _CharacteristListState();

class _CharacteristListState extends State<CharacteristList>
List<String> filesList = new List<String>();
List<String> filesL = new List<String>();
@override
void initState()
super.initState();
filesList = [];

Future<List<String>> _getFilesFromDir() async
filesL = await FilesInDirectory().getFilesFromDir();
setState(()
filesList = filesL;
);
return filesList;

_getFilesCount()
_getFilesFromDir();
int count = filesList.length;
return count;

@override
Widget build(BuildContext context)
return new Scaffold(
appBar: new AppBar(
title: const Text('Список документов'),
),
body: new Column(
children: <Widget>[
new Expanded(
child: new ListView.builder(
//TODO не успевает сформировать список файлов
itemCount: _getFilesCount(),
itemBuilder: (context, index)
return new CharacteristListItem(filesList[index]);
,
),
),
],
),
floatingActionButton: new FloatingActionButton(
onPressed: ()
Navigator.push(context,
new MaterialPageRoute(builder: (context)
=> new StartScreen()),
);,
child: new Icon(Icons.add),
),
);











share|improve this question






















  • first thing I can see is you dont have await when calling this function ` await _getFilesFromDir(); //<=here `

    – Tree
    May 25 '18 at 4:32


















0















I get the list of files from the user's folder. The names of the files I transfer to the ListView.builder. It's work, but I think, this is bad architecture.



A method _getFilesFromDir() call with a high frequency.



How to make the correct list generation, so as not to update the interface without changing the file list?



class CharacteristList extends StatefulWidget 
@override
_CharacteristListState createState() => new _CharacteristListState();

class _CharacteristListState extends State<CharacteristList>
List<String> filesList = new List<String>();
List<String> filesL = new List<String>();
@override
void initState()
super.initState();
filesList = [];

Future<List<String>> _getFilesFromDir() async
filesL = await FilesInDirectory().getFilesFromDir();
setState(()
filesList = filesL;
);
return filesList;

_getFilesCount()
_getFilesFromDir();
int count = filesList.length;
return count;

@override
Widget build(BuildContext context)
return new Scaffold(
appBar: new AppBar(
title: const Text('Список документов'),
),
body: new Column(
children: <Widget>[
new Expanded(
child: new ListView.builder(
//TODO не успевает сформировать список файлов
itemCount: _getFilesCount(),
itemBuilder: (context, index)
return new CharacteristListItem(filesList[index]);
,
),
),
],
),
floatingActionButton: new FloatingActionButton(
onPressed: ()
Navigator.push(context,
new MaterialPageRoute(builder: (context)
=> new StartScreen()),
);,
child: new Icon(Icons.add),
),
);











share|improve this question






















  • first thing I can see is you dont have await when calling this function ` await _getFilesFromDir(); //<=here `

    – Tree
    May 25 '18 at 4:32














0












0








0


1






I get the list of files from the user's folder. The names of the files I transfer to the ListView.builder. It's work, but I think, this is bad architecture.



A method _getFilesFromDir() call with a high frequency.



How to make the correct list generation, so as not to update the interface without changing the file list?



class CharacteristList extends StatefulWidget 
@override
_CharacteristListState createState() => new _CharacteristListState();

class _CharacteristListState extends State<CharacteristList>
List<String> filesList = new List<String>();
List<String> filesL = new List<String>();
@override
void initState()
super.initState();
filesList = [];

Future<List<String>> _getFilesFromDir() async
filesL = await FilesInDirectory().getFilesFromDir();
setState(()
filesList = filesL;
);
return filesList;

_getFilesCount()
_getFilesFromDir();
int count = filesList.length;
return count;

@override
Widget build(BuildContext context)
return new Scaffold(
appBar: new AppBar(
title: const Text('Список документов'),
),
body: new Column(
children: <Widget>[
new Expanded(
child: new ListView.builder(
//TODO не успевает сформировать список файлов
itemCount: _getFilesCount(),
itemBuilder: (context, index)
return new CharacteristListItem(filesList[index]);
,
),
),
],
),
floatingActionButton: new FloatingActionButton(
onPressed: ()
Navigator.push(context,
new MaterialPageRoute(builder: (context)
=> new StartScreen()),
);,
child: new Icon(Icons.add),
),
);











share|improve this question














I get the list of files from the user's folder. The names of the files I transfer to the ListView.builder. It's work, but I think, this is bad architecture.



A method _getFilesFromDir() call with a high frequency.



How to make the correct list generation, so as not to update the interface without changing the file list?



class CharacteristList extends StatefulWidget 
@override
_CharacteristListState createState() => new _CharacteristListState();

class _CharacteristListState extends State<CharacteristList>
List<String> filesList = new List<String>();
List<String> filesL = new List<String>();
@override
void initState()
super.initState();
filesList = [];

Future<List<String>> _getFilesFromDir() async
filesL = await FilesInDirectory().getFilesFromDir();
setState(()
filesList = filesL;
);
return filesList;

_getFilesCount()
_getFilesFromDir();
int count = filesList.length;
return count;

@override
Widget build(BuildContext context)
return new Scaffold(
appBar: new AppBar(
title: const Text('Список документов'),
),
body: new Column(
children: <Widget>[
new Expanded(
child: new ListView.builder(
//TODO не успевает сформировать список файлов
itemCount: _getFilesCount(),
itemBuilder: (context, index)
return new CharacteristListItem(filesList[index]);
,
),
),
],
),
floatingActionButton: new FloatingActionButton(
onPressed: ()
Navigator.push(context,
new MaterialPageRoute(builder: (context)
=> new StartScreen()),
);,
child: new Icon(Icons.add),
),
);








dart flutter






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked May 25 '18 at 3:51









ВячеславВячеслав

521 silver badge9 bronze badges




521 silver badge9 bronze badges












  • first thing I can see is you dont have await when calling this function ` await _getFilesFromDir(); //<=here `

    – Tree
    May 25 '18 at 4:32


















  • first thing I can see is you dont have await when calling this function ` await _getFilesFromDir(); //<=here `

    – Tree
    May 25 '18 at 4:32

















first thing I can see is you dont have await when calling this function ` await _getFilesFromDir(); //<=here `

– Tree
May 25 '18 at 4:32






first thing I can see is you dont have await when calling this function ` await _getFilesFromDir(); //<=here `

– Tree
May 25 '18 at 4:32













3 Answers
3






active

oldest

votes


















0














Don't call _getFilesCount() in build(). build() can be called very frequently. Call it in initState() and store the result instead of re-reading over and over again.






share|improve this answer























  • It's don't work. Now I'm using FutureBuilder, but I have issue with this

    – Вячеслав
    May 27 '18 at 4:21



















0














I changed the architecture of the class - I used FutureBuilder.



class _CharacteristListState extends State<CharacteristList> 

@override
Widget build(BuildContext context)

return new Scaffold(
appBar: new AppBar(
title: const Text('Список документов'),
),
body: new Center(
child: new Column(
children: <Widget>[
new FutureBuilder(
future: _inFutureList(),
builder: (BuildContext context, AsyncSnapshot snapshot)
if(snapshot.connectionState == ConnectionState.waiting)
return new Text('Data is loading...');

else
return customBuild(context, snapshot);


)
],
),
),
floatingActionButton: new FloatingActionButton(
onPressed: ()
Navigator.push(context,
new MaterialPageRoute(builder: (context)
=> new StartScreen()),
);,
child: new Icon(Icons.add),
),
);


Widget customBuild(BuildContext context, AsyncSnapshot snapshot)
List<String> values = snapshot.data;
return new Container(
child: new Expanded(
child: new ListView.builder(
itemCount: values.length,
itemBuilder: (context, index)
return new CharacteristListItem(values[index]);
,
),
)
);


Future<List<String>>_inFutureList() async
var filesList = new List<String>();
filesList = await FilesInDirectory().getFilesFromDir();
await new Future.delayed(new Duration(milliseconds: 500));
return filesList;








share|improve this answer






























    0














     // add dependancy in pubspec.yaml
    path_provider:

    import 'dart:io' as io;
    import 'package:path_provider/path_provider.dart';

    //Declare Globaly
    String directory;
    List file = new List();
    @override
    void initState()
    // TODO: implement initState
    super.initState();
    _listofFiles();


    // Make New Function
    void _listofFiles() async
    directory = (await getApplicationDocumentsDirectory()).path;
    setState(()
    file = io.Directory("$directory/resume/").listSync(); //use your folder name insted of resume.
    );


    // Build Part
    @override
    Widget build(BuildContext context)
    return MaterialApp(
    navigatorKey: navigatorKey,
    title: 'List of Files',
    home: Scaffold(
    appBar: AppBar(
    title: Text("Get List of Files with whole Path"),
    ),
    body: Container(
    child: Column(
    children: <Widget>[
    // your Content if there
    Expanded(
    child: ListView.builder(
    itemCount: file.length,
    itemBuilder: (BuildContext context, int index)
    return Text(file[index].toString());
    ),
    )
    ],
    ),
    ),
    ),
    );






    share|improve this answer



























      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50521274%2fhow-to-get-a-list-of-files-from-the-directory-and-pass-it-to-the-listview%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      Don't call _getFilesCount() in build(). build() can be called very frequently. Call it in initState() and store the result instead of re-reading over and over again.






      share|improve this answer























      • It's don't work. Now I'm using FutureBuilder, but I have issue with this

        – Вячеслав
        May 27 '18 at 4:21
















      0














      Don't call _getFilesCount() in build(). build() can be called very frequently. Call it in initState() and store the result instead of re-reading over and over again.






      share|improve this answer























      • It's don't work. Now I'm using FutureBuilder, but I have issue with this

        – Вячеслав
        May 27 '18 at 4:21














      0












      0








      0







      Don't call _getFilesCount() in build(). build() can be called very frequently. Call it in initState() and store the result instead of re-reading over and over again.






      share|improve this answer













      Don't call _getFilesCount() in build(). build() can be called very frequently. Call it in initState() and store the result instead of re-reading over and over again.







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered May 25 '18 at 4:32









      Günter ZöchbauerGünter Zöchbauer

      351k81 gold badges1098 silver badges1006 bronze badges




      351k81 gold badges1098 silver badges1006 bronze badges












      • It's don't work. Now I'm using FutureBuilder, but I have issue with this

        – Вячеслав
        May 27 '18 at 4:21


















      • It's don't work. Now I'm using FutureBuilder, but I have issue with this

        – Вячеслав
        May 27 '18 at 4:21

















      It's don't work. Now I'm using FutureBuilder, but I have issue with this

      – Вячеслав
      May 27 '18 at 4:21






      It's don't work. Now I'm using FutureBuilder, but I have issue with this

      – Вячеслав
      May 27 '18 at 4:21














      0














      I changed the architecture of the class - I used FutureBuilder.



      class _CharacteristListState extends State<CharacteristList> 

      @override
      Widget build(BuildContext context)

      return new Scaffold(
      appBar: new AppBar(
      title: const Text('Список документов'),
      ),
      body: new Center(
      child: new Column(
      children: <Widget>[
      new FutureBuilder(
      future: _inFutureList(),
      builder: (BuildContext context, AsyncSnapshot snapshot)
      if(snapshot.connectionState == ConnectionState.waiting)
      return new Text('Data is loading...');

      else
      return customBuild(context, snapshot);


      )
      ],
      ),
      ),
      floatingActionButton: new FloatingActionButton(
      onPressed: ()
      Navigator.push(context,
      new MaterialPageRoute(builder: (context)
      => new StartScreen()),
      );,
      child: new Icon(Icons.add),
      ),
      );


      Widget customBuild(BuildContext context, AsyncSnapshot snapshot)
      List<String> values = snapshot.data;
      return new Container(
      child: new Expanded(
      child: new ListView.builder(
      itemCount: values.length,
      itemBuilder: (context, index)
      return new CharacteristListItem(values[index]);
      ,
      ),
      )
      );


      Future<List<String>>_inFutureList() async
      var filesList = new List<String>();
      filesList = await FilesInDirectory().getFilesFromDir();
      await new Future.delayed(new Duration(milliseconds: 500));
      return filesList;








      share|improve this answer



























        0














        I changed the architecture of the class - I used FutureBuilder.



        class _CharacteristListState extends State<CharacteristList> 

        @override
        Widget build(BuildContext context)

        return new Scaffold(
        appBar: new AppBar(
        title: const Text('Список документов'),
        ),
        body: new Center(
        child: new Column(
        children: <Widget>[
        new FutureBuilder(
        future: _inFutureList(),
        builder: (BuildContext context, AsyncSnapshot snapshot)
        if(snapshot.connectionState == ConnectionState.waiting)
        return new Text('Data is loading...');

        else
        return customBuild(context, snapshot);


        )
        ],
        ),
        ),
        floatingActionButton: new FloatingActionButton(
        onPressed: ()
        Navigator.push(context,
        new MaterialPageRoute(builder: (context)
        => new StartScreen()),
        );,
        child: new Icon(Icons.add),
        ),
        );


        Widget customBuild(BuildContext context, AsyncSnapshot snapshot)
        List<String> values = snapshot.data;
        return new Container(
        child: new Expanded(
        child: new ListView.builder(
        itemCount: values.length,
        itemBuilder: (context, index)
        return new CharacteristListItem(values[index]);
        ,
        ),
        )
        );


        Future<List<String>>_inFutureList() async
        var filesList = new List<String>();
        filesList = await FilesInDirectory().getFilesFromDir();
        await new Future.delayed(new Duration(milliseconds: 500));
        return filesList;








        share|improve this answer

























          0












          0








          0







          I changed the architecture of the class - I used FutureBuilder.



          class _CharacteristListState extends State<CharacteristList> 

          @override
          Widget build(BuildContext context)

          return new Scaffold(
          appBar: new AppBar(
          title: const Text('Список документов'),
          ),
          body: new Center(
          child: new Column(
          children: <Widget>[
          new FutureBuilder(
          future: _inFutureList(),
          builder: (BuildContext context, AsyncSnapshot snapshot)
          if(snapshot.connectionState == ConnectionState.waiting)
          return new Text('Data is loading...');

          else
          return customBuild(context, snapshot);


          )
          ],
          ),
          ),
          floatingActionButton: new FloatingActionButton(
          onPressed: ()
          Navigator.push(context,
          new MaterialPageRoute(builder: (context)
          => new StartScreen()),
          );,
          child: new Icon(Icons.add),
          ),
          );


          Widget customBuild(BuildContext context, AsyncSnapshot snapshot)
          List<String> values = snapshot.data;
          return new Container(
          child: new Expanded(
          child: new ListView.builder(
          itemCount: values.length,
          itemBuilder: (context, index)
          return new CharacteristListItem(values[index]);
          ,
          ),
          )
          );


          Future<List<String>>_inFutureList() async
          var filesList = new List<String>();
          filesList = await FilesInDirectory().getFilesFromDir();
          await new Future.delayed(new Duration(milliseconds: 500));
          return filesList;








          share|improve this answer













          I changed the architecture of the class - I used FutureBuilder.



          class _CharacteristListState extends State<CharacteristList> 

          @override
          Widget build(BuildContext context)

          return new Scaffold(
          appBar: new AppBar(
          title: const Text('Список документов'),
          ),
          body: new Center(
          child: new Column(
          children: <Widget>[
          new FutureBuilder(
          future: _inFutureList(),
          builder: (BuildContext context, AsyncSnapshot snapshot)
          if(snapshot.connectionState == ConnectionState.waiting)
          return new Text('Data is loading...');

          else
          return customBuild(context, snapshot);


          )
          ],
          ),
          ),
          floatingActionButton: new FloatingActionButton(
          onPressed: ()
          Navigator.push(context,
          new MaterialPageRoute(builder: (context)
          => new StartScreen()),
          );,
          child: new Icon(Icons.add),
          ),
          );


          Widget customBuild(BuildContext context, AsyncSnapshot snapshot)
          List<String> values = snapshot.data;
          return new Container(
          child: new Expanded(
          child: new ListView.builder(
          itemCount: values.length,
          itemBuilder: (context, index)
          return new CharacteristListItem(values[index]);
          ,
          ),
          )
          );


          Future<List<String>>_inFutureList() async
          var filesList = new List<String>();
          filesList = await FilesInDirectory().getFilesFromDir();
          await new Future.delayed(new Duration(milliseconds: 500));
          return filesList;









          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered May 27 '18 at 16:50









          ВячеславВячеслав

          521 silver badge9 bronze badges




          521 silver badge9 bronze badges





















              0














               // add dependancy in pubspec.yaml
              path_provider:

              import 'dart:io' as io;
              import 'package:path_provider/path_provider.dart';

              //Declare Globaly
              String directory;
              List file = new List();
              @override
              void initState()
              // TODO: implement initState
              super.initState();
              _listofFiles();


              // Make New Function
              void _listofFiles() async
              directory = (await getApplicationDocumentsDirectory()).path;
              setState(()
              file = io.Directory("$directory/resume/").listSync(); //use your folder name insted of resume.
              );


              // Build Part
              @override
              Widget build(BuildContext context)
              return MaterialApp(
              navigatorKey: navigatorKey,
              title: 'List of Files',
              home: Scaffold(
              appBar: AppBar(
              title: Text("Get List of Files with whole Path"),
              ),
              body: Container(
              child: Column(
              children: <Widget>[
              // your Content if there
              Expanded(
              child: ListView.builder(
              itemCount: file.length,
              itemBuilder: (BuildContext context, int index)
              return Text(file[index].toString());
              ),
              )
              ],
              ),
              ),
              ),
              );






              share|improve this answer





























                0














                 // add dependancy in pubspec.yaml
                path_provider:

                import 'dart:io' as io;
                import 'package:path_provider/path_provider.dart';

                //Declare Globaly
                String directory;
                List file = new List();
                @override
                void initState()
                // TODO: implement initState
                super.initState();
                _listofFiles();


                // Make New Function
                void _listofFiles() async
                directory = (await getApplicationDocumentsDirectory()).path;
                setState(()
                file = io.Directory("$directory/resume/").listSync(); //use your folder name insted of resume.
                );


                // Build Part
                @override
                Widget build(BuildContext context)
                return MaterialApp(
                navigatorKey: navigatorKey,
                title: 'List of Files',
                home: Scaffold(
                appBar: AppBar(
                title: Text("Get List of Files with whole Path"),
                ),
                body: Container(
                child: Column(
                children: <Widget>[
                // your Content if there
                Expanded(
                child: ListView.builder(
                itemCount: file.length,
                itemBuilder: (BuildContext context, int index)
                return Text(file[index].toString());
                ),
                )
                ],
                ),
                ),
                ),
                );






                share|improve this answer



























                  0












                  0








                  0







                   // add dependancy in pubspec.yaml
                  path_provider:

                  import 'dart:io' as io;
                  import 'package:path_provider/path_provider.dart';

                  //Declare Globaly
                  String directory;
                  List file = new List();
                  @override
                  void initState()
                  // TODO: implement initState
                  super.initState();
                  _listofFiles();


                  // Make New Function
                  void _listofFiles() async
                  directory = (await getApplicationDocumentsDirectory()).path;
                  setState(()
                  file = io.Directory("$directory/resume/").listSync(); //use your folder name insted of resume.
                  );


                  // Build Part
                  @override
                  Widget build(BuildContext context)
                  return MaterialApp(
                  navigatorKey: navigatorKey,
                  title: 'List of Files',
                  home: Scaffold(
                  appBar: AppBar(
                  title: Text("Get List of Files with whole Path"),
                  ),
                  body: Container(
                  child: Column(
                  children: <Widget>[
                  // your Content if there
                  Expanded(
                  child: ListView.builder(
                  itemCount: file.length,
                  itemBuilder: (BuildContext context, int index)
                  return Text(file[index].toString());
                  ),
                  )
                  ],
                  ),
                  ),
                  ),
                  );






                  share|improve this answer















                   // add dependancy in pubspec.yaml
                  path_provider:

                  import 'dart:io' as io;
                  import 'package:path_provider/path_provider.dart';

                  //Declare Globaly
                  String directory;
                  List file = new List();
                  @override
                  void initState()
                  // TODO: implement initState
                  super.initState();
                  _listofFiles();


                  // Make New Function
                  void _listofFiles() async
                  directory = (await getApplicationDocumentsDirectory()).path;
                  setState(()
                  file = io.Directory("$directory/resume/").listSync(); //use your folder name insted of resume.
                  );


                  // Build Part
                  @override
                  Widget build(BuildContext context)
                  return MaterialApp(
                  navigatorKey: navigatorKey,
                  title: 'List of Files',
                  home: Scaffold(
                  appBar: AppBar(
                  title: Text("Get List of Files with whole Path"),
                  ),
                  body: Container(
                  child: Column(
                  children: <Widget>[
                  // your Content if there
                  Expanded(
                  child: ListView.builder(
                  itemCount: file.length,
                  itemBuilder: (BuildContext context, int index)
                  return Text(file[index].toString());
                  ),
                  )
                  ],
                  ),
                  ),
                  ),
                  );







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Mar 25 at 12:37

























                  answered Mar 25 at 12:30









                  Jay GadariyaJay Gadariya

                  12 bronze badges




                  12 bronze badges



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50521274%2fhow-to-get-a-list-of-files-from-the-directory-and-pass-it-to-the-listview%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                      용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

                      155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해