• 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

        Useful functions in List

        In this lesson, we will discuss about few useful functions related to List.

        contains()

        Search elements in the list and return the result in terms of true or false.

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

        OUTPUT

        true

        indexOf()

        Similar to contain function is also the search element remind in the list but returns the index of the found item.

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

        OUTPUT

        1

        insert()

        Insert a new element In the list at a particular index that we define.

        void main() {
        List<String> movies=["Avengers","IronMan","Harry Potter-I","Harry Potter-II"];
        movies.insert(2,"Venom");
        print(movies);
        
        }

        OUTPUT

        [Avengers, IronMan, Venom, Harry Potter-I, Harry Potter-II]

        sublist()

        Returns a part of the list from the index number that we mention. if only the starting number was mentioned list is made from the starting index till the end.

        void main() {
        List<String> movies=["Avengers","IronMan","Harry Potter-I","Harry Potter-II"];
        List newList=movies.sublist(2);
        print(newList);
          
        }
        

        OUTPUT

        [Harry Potter-I, Harry Potter-II]

         

        0
        Prev Add and Remove items in List

        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