Skip to content

Instantly share code, notes, and snippets.

View mhmadip's full-sized avatar

Mohammad Salim mhmadip

View GitHub Profile
@mhmadip
mhmadip / main.dart
Last active February 20, 2021 20:12
Rectangle App
import 'package:flutter/material.dart';
void main() => runApp(MaterialApp(
title: "Hello Rectangle",
home: Scaffold(
appBar: AppBar(
title: Text("Rectangle App"),
),
body: RectangleApp(),
),
@mhmadip
mhmadip / main.dart
Last active May 11, 2021 10:46
Sum of List Elements Challange - Mohammad Salim IT Dept. @ TIU
int sum(List<int> intList, int index) {
if (index == 0) {
return intList[index];
} else {
return intList[index] + sum(intList, index - 1);
}
}
void main() {
var test = [4, 2, 3, 4];
@mhmadip
mhmadip / gist:7779470cfcb40a4338784feecba2ea1f
Created August 18, 2021 10:13
Homework 1: Build your business app
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
debugShowCheckedModeBanner: false,
title: 'My Company App',
home: MyHomeScreen(),
));
}
@mhmadip
mhmadip / main.dart
Created August 22, 2021 16:48
Hello Switch Flutter App
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(
title: Text("Hello Switch"),
),
@mhmadip
mhmadip / main.dart
Created August 22, 2021 16:54
22.Quiz: Debug Stateful Widgets
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget { @override
Widget build(BuildContext context) {
return MaterialApp( home: MyHomePage(),
); }
}
class MyHomePage extends StatefulWidget { MyHomePage();
@override
createState() => _MyHomePageState();
@mhmadip
mhmadip / main.dart
Created August 23, 2021 07:24
Dart Control Flow Statements
// Chapter 5: Control Flow Statements
void main() {
//if statment
var testList = [2, 4, 8, 16, 32];
print(testList);
if (testList.isNotEmpty) {
print("Emptying List");
testList.clear();
}
print(testList);
@mhmadip
mhmadip / main.dart
Last active September 2, 2021 08:27
Sum of odd and even numbers and search for a specific number inside the list
import 'dart:io';
int sumEven(List li) {
int sum = 0;
for (var i in li) {
if (i % 2 == 0) {
sum = sum + i;
}
}
return sum;
}
//Enumerated types, often called enumerations or enums,
// are a special kind of class used to represent a fixed number of constant values.
//Declare an enumerated type using the enum keyword:
enum Color { red, green, blue }
//To get a list of all of the values in the enum, use the enum’s values constant.
List<Color> colors = Color.values;
void main() {
//You can use trailing commas when declaring an enumerated type.
//
@mhmadip
mhmadip / main.dart
Created October 15, 2021 17:23
Explaining OOP in Dart
// classes and objects example
/*
class Car{
int numberOfDoors=5;
void drive(){
print('wheels start turning');
}
}
void main(){
@mhmadip
mhmadip / main.dart
Created April 6, 2022 07:40
Creating Objects using Loop and store them in a list
class Object {
int id = 0;
String name='abc';
Object(this.id);
@override
String toString()=> id.toString() + name;
}
void main() {