Skip to content

Instantly share code, notes, and snippets.

View Chinecherem20199's full-sized avatar

Chinecherem Augustina Ugwuanyi Chinecherem20199

View GitHub Profile
@Chinecherem20199
Chinecherem20199 / main.dart
Created May 5, 2022 04:47
const, final, var etc in Dart
void main() {
//Exercise 3
//Question 1
//Use the declared variables below to decide whether or not a person is eligible to rent movies
//A person is eligible when the age is more than 20 and the person can show his/her ID
//An example printout: Eligible to rent movies? false
@Chinecherem20199
Chinecherem20199 / main.dart
Created May 12, 2022 13:21
functions_dart
void main() {
var values = [1, 2, 3, 4, 5, 6, 7, 8, 9];
var newVlues = <int>[];
void Function(int) multiply5 = (value) => newVlues.add(value * 5);
listOperation(values, multiply5);
print(newVlues);
}
void listOperation(List<int> list, void Function(int) action) {
for (var item in list) {
void main() {
var values = [1, 2, 3, 4, 5, 6, 7, 8, 9];
var newVlues = <int>[];
var multiply5 = (int value) => newVlues.add(value * 5);
listOperation(values, multiply5);
print(newVlues);
}
void listOperation(List<int> list, void Function(int) action) {
for (var item in list) {
//typedef is a keyword
typedef Action = void Function(int);
void main() {
var values = [1, 2, 3, 4, 5, 6, 7, 8, 9];
var newVlues = <int>[];
void Function(int) multiply5 = (value) => newVlues.add(value * 5);
listOperation(values, multiply5);
print(newVlues);
}
@Chinecherem20199
Chinecherem20199 / main.dart
Created May 16, 2022 10:59
Generic_Function_Dart
void main() {
var doubleValues = [10.2, 2.2, 3.0, 4.5, 5.5, 6.0, 7.4, 80.0, 9.0];
var stringValues = ['@','*', '&' ];
var newDoubleVlues = <double>[];
var newStringValue = <String>[];
//listOperation(doubleValues, (double val) => newDoubleValues.add(val *3));
listOperation(doubleValues,(double val) => newDoubleVlues.add(val * 5));
listOperation(stringValues,(String val)=> newStringValue.add(val * 2));
@Chinecherem20199
Chinecherem20199 / main.dart
Created May 16, 2022 11:02
Generic_Function_Dart
void main() {
var doubleValues = [10.2, 2.2, 3.0, 4.5, 5.5, 6.0, 7.4, 80.0, 9.0];
var stringValues = ['@','*', '&' ];
var newDoubleVlues = <double>[];
var newStringValue = <String>[];
//listOperation(doubleValues, (double val) => newDoubleValues.add(val *3));
listOperation(doubleValues,(double val) => newDoubleVlues.add(val * 5));
listOperation(stringValues,(String val)=> newStringValue.add(val * 2));
@Chinecherem20199
Chinecherem20199 / main.dart
Created May 16, 2022 11:24
forEach_map_function
void main() {
final list = [10, 20, 33];
// for (var item in list) {
// print(item);
// }
//forEach
list.forEach((item) => print(item));
list.forEach(print);
//Map Function
@Chinecherem20199
Chinecherem20199 / main.dart
Created May 16, 2022 12:43
Class Fundamental in Dart
//use classes to define new type
//we are used to int, String, bool, List, Map, Set, Function
//classes - blueprint for objects
//object - container that holds some data (functionality in manipulate the data)
void main() {
var myHouse = House(nuOfWindows: 8, nuOfDoors: 4, typesOfWalls: 'Brick', typesOfRoof:'Tile');
// myHouse.nrOfDoors = 10;
//
// print(myHouse.nrOfDoors);
myHouse.printHouses();
@Chinecherem20199
Chinecherem20199 / loves.dart
Created May 31, 2022 19:28
Love Random Calculator
import 'dart:math';
void main() {
loveCalculator();
}
void loveCalculator(){
int loveScore = Random().nextInt(100) + 1;
print(loveScore);
@Chinecherem20199
Chinecherem20199 / main.dart
Created November 14, 2022 18:56
rustic-snow-0638
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override