🚗🏍️ Welcome to Motoshare!

Turning Idle Vehicles into Shared Rides & New Earnings.
Why let your bike or car sit idle when it can earn for you and move someone else forward?

From Idle to Income. From Parked to Purpose.
Earn by Sharing, Ride by Renting.
Where Owners Earn, Riders Move.
Owners Earn. Riders Move. Motoshare Connects.

With Motoshare, every parked vehicle finds a purpose. Partners earn. Renters ride. Everyone wins.

Start Your Journey with Motoshare

How to iterate over a Dart List using

Uncategorized
  • forEach() expression.
  • iterator property to get Iterator that allows iterating.
  • every() method
  • simple for-each loop
  • for loop with item index

forEach() expression:

void main()
 {
var myList = [0, 'one', 'two', 'three', 'four', 'five'];
myList.forEach((item) => print(item));
 }

Output:

0
one
two
three
four
five

Iterator property to get Iterator that allows iterating:

void main()
 {
     var myList = [0, 'one', 'two', 'three', 'four', 'five'];
     var listIterator = myList.iterator;
     while (listIterator.moveNext()) {
     print(listIterator.current);
     }
 }

Output

 0
one
two
three
four
five

every() method:

 void main()
 {
     var myList = [0, 'one', 'two', 'three', 'four', 'five'];
     myList.every((item) {
     print(item);
     return true;
     });
 }

Output

0
one
two
three
four
five

simple for-each loop:

void main()
 {
     var myList = [0, 'one', 'two', 'three', 'four', 'five'];
     for (var item in myList) {
     print(item);
     }
 }

Output

0
one
two
three
four
five

for loop with item index:

void main()
 {
     var myList = [0, 'one', 'two', 'three', 'four', 'five'];
    for (var i = 0; i < myList.length; i++) {
    print(myList[i]);
     }
 }

Output

0
one
two
three
four
five

How to Replace a Substring of a String in Dart?

main() {
    String data = "welcome";
      
    //replace substring of the given string
    String result = data.replaceAll("hii", "Abhishek!");
      
    print(result);
}

OutPut

hii Abhishek!
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x