Skip to content

Instantly share code, notes, and snippets.

View JaveedIshaq's full-sized avatar
🇵🇰
Passion to help others

Javeed Ishaq JaveedIshaq

🇵🇰
Passion to help others
View GitHub Profile
@JaveedIshaq
JaveedIshaq / foo_test.dart
Created August 11, 2022 10:46 — 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 = '';
@JaveedIshaq
JaveedIshaq / main.dart
Last active April 24, 2022 03:51
How do I convert a date/time string to a DateTime object in Dart?
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
@JaveedIshaq
JaveedIshaq / contcatbook.dart
Last active April 23, 2022 17:29
how to create a singleton instance of a class in dart flutter
class ContactBook {
ContactBook._sharedInstance();
static final ContactBook _shared = ContactBook._sharedInstance();
factory ContactBook() => _shared;
}
@JaveedIshaq
JaveedIshaq / main.dart
Created April 16, 2022 14:05
Creat Singletone pattern in dart
class LoginApi implements LoginApiProtocol {
const LoginApi._sharedInstance();
static const LoginApi _shared = LoginApi._sharedInstance();
factory LoginApi.instance() => _shared;
@override
Future<LoginHandle?> login(
{required String email, required String password}) {
@JaveedIshaq
JaveedIshaq / persons2.json
Created April 12, 2022 15:50
Persons JSON
[
{
"name": "Foo 2",
"age": 20
},
{
"name": "Foo 2",
"age": 20
},
{
@JaveedIshaq
JaveedIshaq / persons1.json
Created April 12, 2022 15:48
Persons 1 json
[
{
"name": "Foo 1",
"age": 20
},
{
"name": "Foo 1",
"age": 20
},
{
// Player
AnimatedAlign(
alignment: _playerAlignment,
duration: Duration(milliseconds: 250),
curve: Curves.easeInOut,
child: Container(
width: 100,
height: 100,
decoration: BoxDecoration(
color: _targetData.color,
@JaveedIshaq
JaveedIshaq / dart_flutter_log_extension.dart
Created March 5, 2022 19:00
dart_flutter_log_extension
import 'dart:developer' as devtools show log;
extension Log on Object {
void log() => devtools.log(toString());
}
class StatusCategoryButton extends StatelessWidget {
const StatusCategoryButton({
required this.icon,
required this.title,
Key? key,
}) : super(key: key);
final String icon;
final String title;
@JaveedIshaq
JaveedIshaq / main.dart
Created January 15, 2022 06:20
Flutter Return List of objects from Json for a model class created with data class generator vs code extension
return (jsonDecode(response.body) as List)
.map((i) => PostModel.fromJson(jsonEncode(i)))
.toList();