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
//Programming is too easy. What if we wrote functions like this? | |
//Instead of just calling the function, we create types to bundle | |
//up the arguments and then pass the type to the function that accepts | |
//a generic type. | |
// | |
//This is the essence of the Bloc pattern. | |
class AdditionArguments { | |
final num a; | |
final num b; |
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
//Programming is too easy. What if we wrote functions like this? | |
//Instead of just calling the function, we create types to bundle | |
//up the arguments and then pass the type to the function that accepts | |
//a generic type. | |
// | |
//This is the essence of the Bloc pattern. | |
sealed class Event {} | |
class AdditionArguments extends Event { |
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'; | |
void main() => runApp( | |
MaterialApp( | |
debugShowCheckedModeBanner: false, | |
home: Scaffold( | |
body: Center( | |
child: FutureBuilder( | |
future: Future<String>.delayed( | |
const Duration(seconds: 3), () => 'Hello World!'), |
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
(int a, int b) returnMulti() => (1, 2); | |
void main() { | |
var numbers = returnMulti(); | |
var dayNumber = switch (numbers) { | |
(int a, int b) when a == 1 && b == 2 => 'One and Two', | |
(_, _) => 'Default' | |
}; | |
print(dayNumber); | |
} |
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 'dart:math'; | |
sealed class Shape {} | |
class Square extends Shape { | |
Square(this.length, this.width); | |
final double length; | |
final double width; | |
} |
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
abstract class Animal { | |
String get name; | |
} | |
class Dog extends Animal { | |
@override | |
String get name => 'Spot'; | |
} | |
class Cat extends Animal { |
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
void main() { | |
var dayOfWeek = 'Monday'; | |
var dayNumber = switch (dayOfWeek) { | |
'Monday' => 1, | |
'Tuesday' => 2, | |
'Wednesday' => 3, | |
'Thursday' => 4, | |
'Friday' => 5, | |
'Saturday' => 6, | |
'Sunday' => 7, |
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'; | |
void main() => runApp( | |
MaterialApp( | |
debugShowCheckedModeBanner: false, | |
home: Scaffold( | |
body: Center( | |
child: FutureBuilder( | |
future: Future<String>.delayed( | |
const Duration(seconds: 3), () => 'Hello World!'), |
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'; | |
final colors = [ | |
const Color.fromARGB(255, 255, 0, 0), | |
const Color.fromARGB(255, 0, 255, 0), | |
const Color.fromARGB(255, 0, 0, 255), | |
]; | |
void main() { | |
runApp( |
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'; | |
void main() => runApp( | |
MaterialApp( | |
theme: ThemeData( | |
useMaterial3: true, | |
colorScheme: ColorScheme.fromSeed(seedColor: Colors.red) | |
.copyWith(surface: Colors.pink), | |
cardTheme: CardTheme( | |
shape: RoundedRectangleBorder( |