Created
January 8, 2026 21:08
-
-
Save sabiou/c2e09cfdaccf30fab88d5fe6e18eee4e to your computer and use it in GitHub Desktop.
Seance 1: Les bases de Dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // main minimale | |
| void main() { | |
| print("Bonjour Dart"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // main avec deux fonctions print | |
| void main() { | |
| print("Bonjour"); | |
| print("Bienvenue dans Dart"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // type de données | |
| void main() { | |
| int age = 25; | |
| double taille = 1.75; | |
| String prenom = "Amina"; | |
| bool estInscrit = true; | |
| print(age); | |
| print(taille); | |
| print(prenom); | |
| print(estInscrit); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // inference de type | |
| void main() { | |
| var age = 30; | |
| var nom = "Ali"; | |
| var estConnecte = false; | |
| print(age); | |
| print(nom); | |
| print(estConnecte); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // const | |
| void main() { | |
| final pays = "Niger"; | |
| print(pays); | |
| } | |
| void main() { | |
| final heure = DateTime.now().hour; | |
| print("Heure actuelle : $heure"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // const | |
| void main() { | |
| const pi = 3.14; | |
| const appName = "Dart Learning"; | |
| print(pi); | |
| print(appName); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // List | |
| void main() { | |
| List<String> noms = ["Ali", "Amina", "Omar"]; | |
| print(noms); | |
| print(noms[0]); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Set | |
| void main() { | |
| Set<int> nombres = {1, 2, 2, 3}; | |
| print(nombres); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Map | |
| void main() { | |
| Map<String, int> prix = { | |
| "cafe": 500, | |
| "the": 300, | |
| }; | |
| print(prix["cafe"]); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // if - else | |
| void main() { | |
| int note = 12; | |
| if (note >= 10) { | |
| print("Admis"); | |
| } else { | |
| print("Refusé"); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // boucle for simple | |
| void main() { | |
| for (int i = 1; i <= 5; i++) { | |
| print(i); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // boucle for appliquée sur une liste | |
| void main() { | |
| List<String> villes = ["Niamey", "Maradi", "Zinder"]; | |
| for (int i = 0; i < villes.length; i++) { | |
| print(villes[i]); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // boucle while simple | |
| void main() { | |
| int compteur = 0; | |
| while (compteur < 3) { | |
| print(compteur); | |
| compteur++; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // exemple switch | |
| void main() { | |
| int choix = 2; | |
| switch (choix) { | |
| case 1: | |
| print("Addition"); | |
| break; | |
| case 2: | |
| print("Soustraction"); | |
| break; | |
| case 3: | |
| print("Multiplication"); | |
| break; | |
| default: | |
| print("Choix invalide"); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // fonction sans paramètre | |
| void direBonjour() { | |
| print("Bonjour !"); | |
| } | |
| void main() { | |
| direBonjour(); | |
| direBonjour(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // fonction avec paramètre | |
| void saluer(String prenom) { | |
| print("Bonjour $prenom"); | |
| } | |
| void main() { | |
| saluer("Amina"); | |
| saluer("Ali"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // mot clé return | |
| int addition(int a, int b) { | |
| return a + b; | |
| } | |
| void main() { | |
| int resultat = addition(3, 4); | |
| print(resultat); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // exemples | |
| int soustraction(int a, int b) { | |
| return a - b; | |
| } | |
| int multiplication(int a, int b) { | |
| return a * b; | |
| } | |
| double division(double a, double b) { | |
| return a / b; | |
| } | |
| void main() { | |
| print(soustraction(10, 3)); | |
| print(multiplication(4, 5)); | |
| print(division(10, 4)); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // fonctions flechées | |
| int addition(int a, int b) => a + b; | |
| int multiplication(int a, int b) => a * b; | |
| void main() { | |
| print(addition(2, 3)); | |
| print(multiplication(4, 5)); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // fonction anonyme | |
| void main() { | |
| var afficher = (String message) { | |
| print(message); | |
| }; | |
| afficher("Bonjour"); | |
| afficher("Dart est puissant"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // fonction anonyme foreach | |
| void main() { | |
| var noms = ["Ali", "Amina", "Omar"]; | |
| noms.forEach((nom) { | |
| print("Bonjour $nom"); | |
| }); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // version courte fonction avec => (retuurn) | |
| int addition(int a, int b) => a + b; | |
| void afficherResultat(int resultat) { | |
| print("Résultat : $resultat"); | |
| } | |
| void main() { | |
| int r = addition(5, 7); | |
| afficherResultat(r); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // exemple calculatrice | |
| int addition(int a, int b) => a + b; | |
| int soustraction(int a, int b) => a - b; | |
| int multiplication(int a, int b) => a * b; | |
| double division(double a, double b) => a / b; | |
| void main() { | |
| int choix = 1; | |
| int a = 10; | |
| int b = 5; | |
| switch (choix) { | |
| case 1: | |
| print(addition(a, b)); | |
| break; | |
| case 2: | |
| print(soustraction(a, b)); | |
| break; | |
| case 3: | |
| print(multiplication(a, b)); | |
| break; | |
| case 4: | |
| print(division(a.toDouble(), b.toDouble())); | |
| break; | |
| default: | |
| print("Choix invalide"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment