Skip to content

Instantly share code, notes, and snippets.

View zohaib304's full-sized avatar
:octocat:
Working

Zohaib zohaib304

:octocat:
Working
View GitHub Profile
@zohaib304
zohaib304 / foo_test.dart
Created August 24, 2023 06:05 — forked from Rex-Ferrer/foo_test.dart
16 Tips for Widget Testing in Flutter
// https://gist.github.com/Esgrima/c0d4bff4b0d3909daf8994410cd659ce
// https://dartpad.dev/c0d4bff4b0d3909daf8994410cd659ce
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:boolean_selector/boolean_selector.dart';
// (TODO: Tip # 1) Consider making frequently used variables/values constants
const _fooConst1 = '';
const _fooConst2 = '';
@zohaib304
zohaib304 / canva_scroll.dart
Created August 22, 2023 09:55
Canvas Scroll Flutter
import 'package:flutter/material.dart';
class myscroll extends statelesswidget {
@override
widget build(buildcontext context) {
return new materialapp(
title: 'flutter demo',
theme: new themedata(
primaryswatch: colors.blue,
),
@zohaib304
zohaib304 / main.dart
Created July 28, 2022 08:36
Dart List of Objects
void main() {
List<Map<String, dynamic>> myList = [
{
"Name": "Vent"
},
{
"Name": "Product"
@zohaib304
zohaib304 / regex.js
Created May 31, 2022 18:07
Javascript URL regex
/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/
@zohaib304
zohaib304 / bfs.py
Last active April 28, 2021 17:33
Breadth Frist Search (BFS)
# adjancy list...which can be represent as python dictionary
graph = {
'A' : ['B','C'],
'B' : ['D', 'E'],
'C' : ['F'],
'D' : ['A'],
'E' : ['F'],
'F' : []
}
@zohaib304
zohaib304 / main.py
Created April 26, 2021 02:28
13 - Roman to Integer - LeetCode
class Solution:
def romanToInt(self, s: str) -> int:
def value(r):
if (r == 'I'):
return 1
if (r == 'V'):
return 5
if (r == 'X'):
return 10
if (r == 'L'):
@zohaib304
zohaib304 / inkwell.dart
Created March 27, 2021 21:46
Flutter Inkwell splash radius
Container(
margin: EdgeInsets.symmetric(horizontal: 10),
child: InkWell(
customBorder: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
onTap: () {},
child: Ink(
height: 100,
decoration: BoxDecoration(
@zohaib304
zohaib304 / listToWidget.dart
Created March 27, 2021 02:08
Iterating through a list to render multiple widgets in Flutter
Widget getTextWidgets(List<String> strings)
{
List<Widget> list = new List<Widget>();
for(var i = 0; i < strings.length; i++){
list.add(new Text(strings[i]));
}
return new Row(children: list);
}
// or
@zohaib304
zohaib304 / cubit.dart
Last active March 18, 2021 18:18
dart cubit
// cubit expose its inner functions
// which can be called from outside to update its state
// the cubit functions are not stream which means they are pre defined functions.
import 'package:bloc/bloc.dart';
class CounterCubit extends Cubit<int> {
CounterCubit() : super(0);
void increment() => emit(state + 1);
@zohaib304
zohaib304 / streams.dart
Created March 18, 2021 17:54
Dart Streams (Bloc)
import "dart:async";
Stream<int> boatStream() async* {
for (int i = 0; i <= 10; i++) {
await Future.delayed(Duration(seconds: 2));
yield i;
}
}
void main() {