Skip to content

Instantly share code, notes, and snippets.

View VB10's full-sized avatar
🏠
Working from home

Veli Bacik VB10

🏠
Working from home
View GitHub Profile
extension IterableExtension<T> on Iterable<T?> {
List<T> makeSafe() {
return where((element) => element != null).cast<T>().toList();
}
}
class VB10ViewModel {
List<User> dummyListToSafe() {
final userList = <User?>[
const User(),
extension on String {
/// Decode your [jsonString] value with safety
Future<dynamic> safeJsonDecodeCompute() async {
try {
return await compute<String, dynamic>(
jsonDecode,
this,
);
} catch (e) {
Logger().e('Json decode error');
"explorer.fileNesting.patterns": {
"pubspec.yaml": ".flutter-plugins, .packages, .dart_tool, .flutter-plugins-dependencies, .metadata, .packages, pubspec.lock, build.yaml, analysis_options.yaml, all_lint_rules.yaml",
".gitignore": ".gitattributes, .gitmodules, .gitmessage, .mailmap, .git-blame*",
"readme.*": "authors, backers.md, changelog*, citation*, code_of_conduct.md, codeowners, contributing.md, contributors, copying, credits, governance.md, history.md, license*, maintainers, readme*, security.md, sponsors.md",
"*.dart": "$(capture).g.dart, $(capture).freezed.dart",
},
"[dart]": {
"editor.formatOnSave": true,
"editor.formatOnType": true,
"editor.rulers": [
@VB10
VB10 / int_extension_status_code.dart
Created June 30, 2023 11:05
flutter status code extension
extension IntExtension on int? {
StatusCode get httpStatusCode {
if (this == null) return StatusCode.unknown;
switch (this!) {
case < 200:
return StatusCode.continue_;
case >= 200 && <= 300:
return StatusCode.ok;
case 401:
@VB10
VB10 / add_comment_all_open_issues.py
Created June 13, 2023 10:31
send comment all issues to your repo with using chatgpt
import requests
import json
# GitHub API'ya gönderilecek olan veriler
base_url = "https://api.github.com/repos/{owner}/{repo}"
owner = "vb10"
repo = "2023-staj"
comment_body = f"""Merhaba arkadaşlar, sizler için elimden geldiğince herkese yazdım, LinkedIn postları paylaştım ve elimden gelen bir çok arkadaşa erişip staj bulmasına yardımcı oldum. Bu saate kadar size verebileceğim 'ben olsaydım' diyeceğim:
- Bu repoyu LinkedIn'de paylaşıp sadece kendim için değil, benim gibi arkadaşlar için staj arıyoruz demeniz.
@VB10
VB10 / login_view.dart
Created April 20, 2023 00:42
Use case login view
class _LoginViewState extends State<LoginView> with LoginController {
late final ClearTextAction textAction;
late final ControllerCleaner _controllerCleaner;
String _value = '';
@override
void initState() {
super.initState();
textAction = ClearTextAction();
_controllerCleaner = ControllerCleaner(textAction);
}
class CompleteDialogInherited extends InheritedWidget {
CompleteDialogInherited({
required super.child,
super.key,
});
static CompleteDialogInherited of(BuildContext context) {
final result =
context.dependOnInheritedWidgetOfExactType<CompleteDialogInherited>();
assert(result != null, 'No CompleteDialogInherited found in context');
[
{
"city": "Adana",
"name": "Bahçe?ehir Koleji",
"url": "https://twitter.com/zeydankaralar01/status/1622644817506205709?s=46&t=BPAhJVUaSEp-FhJyk7mw2A",
"validation_date": "08/02/2023",
"latitude": "37.0185766",
"longitude": "35.2510051"
},
{
class GlobalException {
static Future<T?> make<T>(AsyncValueGetter<T?> onOperation) async {
try {
final response = await onOperation.call();
if (response == null) {
throw Exception('$T data is null $response');
}
return response;
} catch (e) {
//logger
@VB10
VB10 / animated_switch_page.dart
Created October 31, 2022 11:24
Widget switcher with animation
import 'package:flutter/material.dart';
import 'package:kartal/kartal.dart';
class AnimatedPageSwitch extends StatelessWidget {
const AnimatedPageSwitch(
{super.key,
required this.isPageLoaded,
required this.loaderChild,
required this.completedChild});
final bool isPageLoaded;