This file contains 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
// Copyright (c) 2022, TheTribe.io | |
import 'package:flutter/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return const Center( |
This file contains 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
// Copyright (c) 2022, TheTribe.io | |
import 'package:flutter/material.dart'; | |
/// | |
/// Point d'entrée de l'application. | |
/// Toutes les applications doivent avoir une fonction `main()` | |
/// | |
/// On fait appel à [runApp] pour exécuter le [Widget] | |
/// principal de notre application |
This file contains 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
// Copyright (c) 2022, TheTribe.io | |
String helloWithPositionalParameters( | |
String name, | |
int age, | |
double? size, //le ? indique qu'une valeur [null] est acceptée | |
) { | |
if (size != null) { | |
return "Bonjour $name ($age ans, $size mètres)"; | |
} |
This file contains 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
// Copyright (c) 2022, TheTribe.io | |
String helloWithNamedParameters({ | |
required String name, // les paramètres obligatoires sont préfixés de `required` | |
required int? age, // un paramètres peut être obligatoires ET nullable | |
double? size, // paramètre nullable et facultatif | |
}) { | |
if (size != null) { | |
return "Bonjour $name ($age ans, $size mètres)"; | |
} |
This file contains 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
// Copyright (c) 2022, TheTribe.io | |
/// Exemple de fonction avec un Expression body | |
/// Notez la syntaxe "=>" | |
String getTextWithExpressionBody() => "Bonjour tout le monde"; | |
/// Exemple de fonction avec un Block body | |
/// Elle est strictement équivalente à [getTextWithExpressionBody] | |
String getTextWithBlockBody() { |
This file contains 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
// Copyright (c) 2022, TheTribe.io | |
void main() { | |
final helloWorldText = getHelloWorldText(); | |
print(helloWorldText); | |
} | |
String getHelloWorldText() { | |
return "Bonjour tout le monde"; | |
} |
This file contains 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
import 'package:flutter/material.dart'; | |
class MyAppBar extends StatelessWidget { | |
const MyAppBar({required this.title, super.key}); | |
// Dans un widget, les propriétés sont toujours marquées "finales". | |
final Widget title; | |
@override | |
Widget build(BuildContext context) { |
This file contains 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
import 'package:flutter/material.dart'; | |
class ColumnDemo extends StatelessWidget { | |
const ColumnDemo({super.key}); | |
@override | |
Widget build(BuildContext context) { | |
return Column( | |
textDirection: TextDirection.ltr, | |
mainAxisAlignment: MainAxisAlignment.center, // Positionnement vertical |
This file contains 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
import 'package:flutter/material.dart'; | |
class RowDemo extends StatelessWidget { | |
const RowDemo({super.key}); | |
@override | |
Widget build(BuildContext context) { | |
return Row( | |
textDirection: TextDirection.ltr, | |
mainAxisAlignment: MainAxisAlignment.center, // Positionnement horizontal |
This file contains 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
import 'package:flutter/material.dart'; | |
class StyledContainer extends StatelessWidget { | |
const StyledContainer({super.key}); | |
@override | |
Widget build(BuildContext context) { | |
return Container( | |
// Ce Container aura : | |
// - une couleur de fond Ambre |
OlderNewer