• Courses
  • YouTube
  • Dev News
  • Technology
  • Blogs
  • Flutter Jobs
  • Contact
    • About Us
    • RegisterLogin
    Navoki
    • Courses
    • YouTube
    • Dev News
    • Technology
    • Blogs
    • Flutter Jobs
    • Contact
      • About Us
    • RegisterLogin

      List in Dart Programming language

      • Home
      • All courses
      • Dart Programming Language
      • List in Dart Programming language
      CoursesDart Programming LanguageDart TutorialList in Dart Programming language
      • List
        6
        • Lecture1.1
          Video- List in Dart
        • Lecture1.2
          What is a List in Dart?
        • Lecture1.3
          Declare a List in Dart
        • Lecture1.4
          Traverse a List in Dart
        • Lecture1.5
          Add and Remove items in List
        • Lecture1.6
          Useful functions in List

        Declare a List in Dart

        To declare a List the syntax is

        List<data-type> <variableName>=List();

        Here data type can be any like integer String, Map or user-defined(Class) object like Student(), if you don’t mention any data type by default dynamic type is assigned that means any type of elements can be used in a List . Mentioning data type make sure only a particular data type items will be added, if you are not sure about the value which is coming in List then use dynamic datatype.

        void main() {
        
        List<String> movies=["Avengers","IronMan","Harry Potter-I","Harry Potter-II"];
        print(movies);
        print(movies.runtimeType);
          
        List someData=["Avengers",2019,4.4,true];
        print(someData);
        print(someData.runtimeType);
        
        }

        OUTPUT

        [Avengers, IronMan, Harry Potter-I, Harry Potter-II]
        List<String>
        [Avengers, 2019, 4.4, true]
        List<dynamic>
        

        variableName can be any name like studentList, favoriteMovies etc, and List() create a new empty list i.e that is at the start there will be no items in list length will be 0. if you want to declare a variable with some predefined items then you can use it like this:

        List<String> movies=["Avengers","IronMan","Harry Potter-I","Harry Potter-II"];

        You can also create an empty list by

        List<data-type> <variableName>=[];

        0
        Prev What is a List in Dart?
        Next Traverse a List in Dart

        DON’T MISS
        FLUTTER UPDATES

        Be the first to know when our blog is published.

        flutter-mobile-mockup

        Check your inbox or spam folder to confirm your subscription.

        Contact

        •   Navoki Technologies Pvt. Ltd.
          JMD Megapolis , Sector 48, Gurugram, Haryana 122018

        Company

        • About Us
        • Blogs
        • Contact
        • Privacy policy
        • Terms & Condition

        Useful Links

        • Courses
        • Youtube
        • Dev News

        Mobile

        Click and Get started in seconds

        "Navoki" is a registered trademark of Navoki.com ® 2020–2030 Navoki Technologies Pvt Ltd.

        • Terms & Condition

        Login with your site account

        Continue with Google

        By "Sign in” above to accept Navoki’s Terms of Service & Privacy Policy.

        Not a member yet? Register now

        Register a new account

        Continue with Google

        By "Sign Up” above to accept Navoki’s Terms of Service & Privacy Policy.

        Are you a member? Login now

        Modal title

        Message modal