Skip to content

Instantly share code, notes, and snippets.

View muddassirm's full-sized avatar

Muddassir muddassirm

View GitHub Profile
@muddassirm
muddassirm / LoadJson1.dart
Last active April 26, 2021 18:04
Display JSON data in Flutter : Using the main() function
import 'package:flutter/material.dart';
import 'dart:convert';
import 'dart:async' show Future;
import 'package:flutter/services.dart' show rootBundle;
class Student {
String studentId;
String studentName;
int studentScores;
Student({this.studentId, this.studentName, this.studentScores});
@muddassirm
muddassirm / LoadJson2.dart
Created August 24, 2018 18:18
Display JSON data in Flutter : Using the setState() method
import 'package:flutter/material.dart';
import 'dart:convert';
import 'dart:async' show Future;
import 'package:flutter/services.dart' show rootBundle;
class Student {
String studentId;
String studentName;
int studentScores;
Student({this.studentId, this.studentName, this.studentScores});
@muddassirm
muddassirm / LoadJson3.dart
Created August 24, 2018 18:30
Display JSON data in Flutter : Using a FutureBuilder
import 'package:flutter/material.dart';
import 'dart:convert';
import 'dart:async' show Future;
import 'package:flutter/services.dart' show rootBundle;
class Student {
String studentId;
String studentName;
int studentScores;
@muddassirm
muddassirm / ContextApp1.js
Last active March 18, 2020 04:52
Different ways of using React Context API
//Use React Context + Provider/Consumer - Works with both Functional and Class Components
import React from 'react';
const Context = React.createContext();
const ContextApp = () => {
return (
<Context.Provider value={['THE', 'QUICK', 'BROWN', 'FOX', 'JUMPS', 'OVER', 'THE', 'LAZY', 'DOG']}>
<CustomComponent/>
</Context.Provider>
@muddassirm
muddassirm / CopyState
Created June 2, 2020 10:59
A a very simple immer alternative
let state = {
lists: [1, 2, 3, 4],
items: ['a', 'b', 'c'],
}
const cloneMyState = (f) => {
let copy = {
items: [...state.items],
lists: [...state.lists]
}