Skip to content

Instantly share code, notes, and snippets.

@suragch
suragch / main.dart
Last active November 11, 2022 08:41
Flutter download progress demo
import 'package:download_progress_demo/state_manager.dart';
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
@suragch
suragch / state_manager.dart
Last active November 11, 2022 08:40
Flutter download progress demo
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:http/http.dart';
import 'package:path_provider/path_provider.dart';
import 'package:path/path.dart';
class StateManager {
final progressNotifier = ValueNotifier<double?>(0);
void startDownloading() async {
#include <iostream>
#include <regex>
using namespace std;
class AbstractEmployee
{
// Returns true if got promotion
virtual bool RequestPromotion() = 0;
virtual void Work() = 0;
@suragch
suragch / inheritance_example.cpp
Created May 6, 2022 03:13
Inheritance example - passing objects in constructors
#include <iostream>
using namespace std;
class Pet{
protected:
string Name;
string Breed;
int Age;
Pet(string name, string breed, int age)
@suragch
suragch / justtext.c
Created May 4, 2022 03:10
Formatting a text file in C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
FILE* getTextFromFile(char filename[]) {
FILE* ptr;
ptr = fopen("data.csv", "r");
if (NULL == ptr) {
printf("file can't be opened \n");
}
@suragch
suragch / get_it.dart
Last active May 2, 2022 02:40
Three buttons, change icon (with GetIt and manager class)
import 'package:final_exam/home_screen/home_screen_manager.dart';
import 'package:get_it/get_it.dart';
final getIt = GetIt.instance;
void setupGetIt() {
getIt.registerLazySingleton(() => HomeScreenManager());
}
@suragch
suragch / home_screen.dart
Created May 2, 2022 02:29
Three buttons, change icon (with manager class)
import 'package:flutter/material.dart';
import 'home_screen_manager.dart';
class HomeScreen extends StatefulWidget {
const HomeScreen({Key? key}) : super(key: key);
@override
State<HomeScreen> createState() => _HomeScreenState();
}
@suragch
suragch / home_screen.dart
Created May 2, 2022 02:14
Three buttons, change icon
import 'package:flutter/material.dart';
class HomeScreen extends StatefulWidget {
const HomeScreen({Key? key}) : super(key: key);
@override
State<HomeScreen> createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
@suragch
suragch / inheritance.cpp
Last active April 29, 2022 03:08
Inheritance
#include <iostream>
#include <regex>
using namespace std;
class AbstractEmployee
{
// Returns true if got promotion
virtual bool RequestPromotion() = 0;
};
@suragch
suragch / encapsulation.cpp
Last active April 29, 2022 01:51
encapsulation
// https://www.youtube.com/watch?v=wN0x9eZLix4
#include <iostream>
#include <regex>
using namespace std;
class AbstractEmployee
{
// Returns true if got promotion