Posts

Showing posts from March, 2025

Dart notes:

1- using final and const with data collection   you cannot modify data collection "Set,List,and Map'  if it is const . example:  const List empList = ['Tarek','Ali','Hamed'];   empList.add('Adel'); // Error in correct  empList = ['Hani']; // error In correct   However , with final there is a difference. You can modify a final List ,Set,Map using only add or addAll method.  example :  final List empList = ['Tarek','Ali','Hamed'];   empList.add('Hani'); // correct  empList.addAll(list2); //correct    2- Switch case used to test literal value.  example:  String name = 'Ramy'; Switch(name) {   case 'rami': print(false);   case 'RamY': print(false);   case 'Ramy' : print(true);   default: print('not valid');   }   In dart, you do not have to use break, it will break automatically.Unlike java, if condition evaluated true,statment will be execute...