Skip to content

Instantly share code, notes, and snippets.

View muchirijane's full-sized avatar
👩‍💻
Learning front-end development

Jane Tracy Muthoni muchirijane

👩‍💻
Learning front-end development
View GitHub Profile
@muchirijane
muchirijane / Dart Data Types
Created September 9, 2019 06:55
This are different types of dart data types
// This are the different data types in data language
void main() {
String a = 'Hello';
int b = 123;
dynamic c = 'Hello';
c = 123;
@muchirijane
muchirijane / Generating random number in Dart
Created September 9, 2019 11:32
This is an example of how you can generate random numbers in Dart.
//This is how to generate a rondom number in Dart
// The integer will be from 1 - 6 since i added (+1)
import 'dart:math';
void main() {
int randomNumber = Random().nextInt(6) + 1;
print(randomNumber);
void main() {
List<String> myList = [
'Charles',
'James',
'Bella',
'Jack',
];
//print(myList[3]);
//Challenge: Without changing the main() function, can you make this code work and get the result printed in the console?
void main() {
int step1Result = add(n1: 5, n2: 9);
print(step1Result);
int step2Result = multiply(step1Result, 5);
double finalResult = step2Result / 3;
// If and Else statement in dart
// Symbols used:
// == is equal to
// ! is not equal to
// > is greater than
// < is less than
// >= is greater or equal to
// && AND
// || OR
// ! NOT
void main(){
Human jenny = Human(startingHeight: 15);
jenny.talk('Mommy');
print(jenny.height);
// Human james = Human(20);
// INHERITANCE AND POLYMORPHISM
void main(){
//Car myCar = Car();
// myCar.drive();
// print (myCar.numberOfSeats);
// ElectricCar myNewCar = ElectricCar ();
// print(myNewCar.numberOfSeats);
// All about class construtor and how to use this.
void main(){
Human jenny = Human(height: 15, weight: 3.4);
//jenny.talk('Mommy');
print(jenny.height);
print(jenny.weight);
//How to use enum
void main () {
Car myCar = Car(carStyle: CarType.convertable);
print(myCar);
}
class Car {
//How to use ternary operators
void main () {
int myAge = 21;
bool canIDrink = myAge >= 21 ? true : false;
print(canIDrink);
}