Answers for "listview in dart"

0

list in dart

main(List<String> args) {
  //Syntax : List<ValuesDataType> ListName = [Values]
  List<int> x = [10, 20, 30, 50, 70, 90];

  //? printing specific value : print (ListNameHere[ItsArrangeStartFrom0]);
  //! example
  print(x[0]);

  //? printing the whole list : print (ListName)
  print(x);

  //? calculate list values :
  //! example 
  print(x[0] * x[5]);

  //? to add a new value to the list use <ListName>.add(Value);
  //! example 
  x.add(155);
}
Posted by: Guest on August-06-2021
0

listview flutter

Widget _myListView(BuildContext context) {

      // backing data
      final europeanCountries = ['Albania', 'Andorra', 'Armenia', 'Austria', 
        'Azerbaijan', 'Belarus', 'Belgium', 'Bosnia and Herzegovina', 'Bulgaria',
        'Croatia', 'Cyprus', 'Czech Republic', 'Denmark', 'Estonia', 'Finland',
        'France', 'Georgia', 'Germany', 'Greece', 'Hungary', 'Iceland', 'Ireland',
        'Italy', 'Kazakhstan', 'Kosovo', 'Latvia', 'Liechtenstein', 'Lithuania',
        'Luxembourg', 'Macedonia', 'Malta', 'Moldova', 'Monaco', 'Montenegro',
        'Netherlands', 'Norway', 'Poland', 'Portugal', 'Romania', 'Russia',
        'San Marino', 'Serbia', 'Slovakia', 'Slovenia', 'Spain', 'Sweden', 
        'Switzerland', 'Turkey', 'Ukraine', 'United Kingdom', 'Vatican City'];

      return ListView.builder(
        itemCount: europeanCountries.length,
        itemBuilder: (context, index) {
          return ListTile(
            title: Text(europeanCountries[index]),
          );
        },
      );

    }
Posted by: Guest on October-22-2020

Browse Popular Code Answers by Language