Flutter : Mapping two lists toegther

flutter list of objects
flutter list map index
flutter map list
flutter list where
flutter sort list of objects
flutter convert map to list
flutter merge two list
flutter add to map

Here I am mapping only one list, But the case is that I want to map two lists together so the date appear and after that the photo like in the picture here. So, I want to know How can I make a map of list1 and dates, which is the two lists I have. that they will be only one list which I can use in the body of the scaffold ?

List<Meal> _list1=[Meal(dis:'it is a chicken sandwichh',name: 'chekin filla'),
Meal(dis:'it is a chicken sandwichh',name: 'chekin filla'),
Meal(dis:'it is a chicken sandwichh',name: 'chekin filla'),
Meal(dis:'it is a chicken sandwichh',name: 'chekin filla'),
Meal(dis:'it is a chicken sandwichh',name: 'chekin filla')];
List<Date> dates = [Date(dat:'20th of september 2018'),Date(dat:'21th of september 2018'),Date(dat:'22th of september 2018'),
Date(dat:'23th of september 2018')
,Date(dat: '24th of september 2018')];
Map<Object,Object> list2= {dates,_list1};
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('listviewww'),
      ),
      body:
        ListView( children:_list2
        .map((element){
          return Column(
            children: <Widget>[
          Container(
              child: Text('My name is ayaaaaaaaaaaa '),
          ),
            Container(
            margin: EdgeInsets.all(9.0),
           constraints: new BoxConstraints.expand(height: 300.0),
           decoration: new BoxDecoration(
           border: new Border.all(color: Colors.blueAccent),
           borderRadius: BorderRadius.horizontal( left:Radius.circular(30.0) ,right:Radius.circular(30.0) ),
           image: new DecorationImage(image: new AssetImage('assets/food.jpg'),fit: BoxFit.cover,),),
           padding: EdgeInsets.only(bottom: 10.0),
      child:Center(
        child:Text('HELLfffffffffffO')
      )
      )
            ], 

      );  
        }).toList()

     ) 
     );

You don't have to map the two lists to create a ListView. Just use ListView.builder()

ListView.builder(
  itemBuilder: (context, index) {
    var meal = _list1[index];
    var date = dates[index];
    return Text("Here comes your item with $meal and $date");
  },
);

How to use map() for multiple lists?, Here's how you can create such a structure with Flutter: Create a data source with different types of items. Convert the data source into a list of widgets. 1. Create  W hen I came to realize how easy it was to implement route lines on a Google Map (thanks to the Flutter Polyline Points Package!)I decided to create a quick post about this to share my experiences

From what I'm gathering, you have two lists each with the same number elements. The first list describes the items (name, display etc), while the second is the date.

You're trying to display this in a list, but can't because you have two lists of information.

The simplest answer to this is to make the two lists into one list, i.e. combine the item description and the date. You can make a simple class that has a date and description as fields.

You could theoretically make use of the Tuple library and make up a tuple of the two bits of information, but that hardly seems necessary and making a data object is more concise anyways.

If I've misinterpreted your question, feel free to let me know. The other possibility I could see is that you're trying to make a list with dates as headings, with one or more items under each date.

Create lists with different types of items, GitHub is home to over 50 million developers working together to host and For example, just comparing two lists for having (operator==) equal elements, you  This article is meant as a more detailed exploration on the ListView class, ScrollPhysics and tweaks and optimisations for the general widget. A ListView in Flutter is a linear list of scrollable items. We can use it to make a list of items scrollable or make a list of repeating items.

I guess you want to do something like that. Check below, you can run this code in Dartpad (you'll need to copy and paste it).

class Meal {
  Meal({this.dis, this.name});
  final String dis;
  final String name;
}

class Date {
  Date({this.dat});
  final String dat;
}

void main() {

  List<Meal> _list1 = [
    Meal(dis:'it is a chicken sandwichh', name: 'chekin filla'),
    Meal(dis:'it is a chicken sandwichh', name: 'chekin filla'),
    Meal(dis:'it is a chicken sandwichh', name: 'chekin filla'),
    Meal(dis:'it is a chicken sandwichh', name: 'chekin filla'),
    Meal(dis:'it is a chicken sandwichh', name: 'chekin filla')
  ];

  List<Date> dates = [
    Date(dat:'20th of september 2018'),
    Date(dat:'21th of september 2018'),
    Date(dat:'22th of september 2018'),
    Date(dat:'23th of september 2018'),
    Date(dat:'24th of september 2018')
  ];

  // this is where the mapping will be placed
  Map<Date, Meal> mealsEachDay = new Map();

  // and here the relationship between the dates and the meals is done
  for(var i = 0; i < dates.length; i++)
    mealsEachDay[dates[i]] = _list1[i];

  List<String> yourObjects = mealsEachDay.keys.map((date) {
    return "The date is '${date.dat}' and the meal is '${mealsEachDay[date].dis}'";
  }).toList();

  yourObjects.forEach((s) {
    print(s);    
  });
}

But yet this is not yet worth much. You'll have to understand better the relationship between the objects, lists and maps.

Check this other example below and run it in dartpad as well. For each date there are meals and it's easier to go through them. Another improvement is also not using dates as text.

class Meal {
  Meal({this.dis, this.name});
  final String dis;
  final String name;
}

class MealDate {
  MealDate({this.date, this.meals});
  final DateTime date;
  final List<Meal> meals;
}

void main() {

  List<MealDate> mealsForEachDate = [
    MealDate(
      date: DateTime(2018, 9, 20),
      meals: [
        Meal(name: 'eggs', dis: 'scrambed eggs'),
        Meal(name: 'chiken filet', dis: 'chicken sandwich'),
      ]
    ),
    MealDate(
      date: DateTime(2018, 9, 21),
      meals: [
        Meal(name: 'bread', dis: 'bread and water'),
      ]
    ),
    MealDate(
      date: DateTime(2018, 9, 22),
      meals: [
        Meal(name: 'rice', dis: 'rice and beans'),
      ]
    ),
  ];

  mealsForEachDate.forEach((date) {
    print("[Date ${date.date}]");
    print("  Number of meals ${date.meals.length}");
    var n = 0;
    date.meals.forEach((meal) {
      print("    Meal ${++n}: ${meal.dis}");
    });
    print("\n");
  });
}

Good luck and never stop coding!

List, Set and Map should have a method to compare if elements are , An item can be removed in two main ways (there are others, feel free to check out Iterating Over Lists: for, map, and forEach We've found out how to generate  In this tutorial, we’ll show you many methods and functions to work with a Map in Dart (also in Flutter ). A Dart Map is a collection of key-value pairs. It maps each key to exactly one value. We can iterate over a Map. There are three types of map, depending in the order of iteration: HashMap is unordered.

Programming Flutter: Native, Cross-Platform Apps the Easy Way, Lists have the [index] operator to access elements at the given index and, two lists by returning a new list with the left operand followed by the right one. Dart Maps are dynamic collections for storing values on a key basis, where the  Make sure PanBoundaries are within offline map boundary to stop missing asset errors. See the flutter_map_example/ folder for a working example. Note that there is also FileTileProvider(), which you can use to load tiles from the filesystem. Plugins. flutter_map_marker_cluster: Provides Beautiful Animated Marker Clustering functionality

Flutter for Beginners: An introductory guide to building , var myList = ['zero', 'one', 'two', 'three', 'four', 'five']; var uppers = myList.map((item) => item. flutter / packages / flutter / lib / src / widgets / list_wheel_scroll_view.dart Find file Copy path chunhtai reland Refactors global key duplication detection ( #49896 ) 2dc71a3 Feb 1, 2020

Dart/Flutter List Tutorial with Examples, As you may recall, this will return a List<Map<String, dynamic>>. at the top of the _ItemsScreenState class, we'll create two properties: one will be the  This plugin does not currently support displaying a Google Map within the Flutter widget hierarchy. A common workaround for this is to show a static image using the Google Static Maps API . Included in this Plugin is the StaticMapProvider class which will allow you to easily generate a static map.