Skip to content

Instantly share code, notes, and snippets.

@callmephil
callmephil / connectivity_widget.dart
Last active April 9, 2024 11:23
borken connectivity widget flutter
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:internet_connection_checker_plus/internet_connection_checker_plus.dart';
import 'package:xverse_flutter/utils/environment.dart';
class ConnectivityWidget extends StatefulWidget {
const ConnectivityWidget({
super.key,
required this.builder,
void main() {
const isDoorVisible = false;
const isClassVisible = false;
const isHazineVisible = false;
const isFaragiranVisible = false;
const isErsalPayamVisible = false;
List<bool> visibleWidgets = [
isDoorVisible,
isClassVisible,
@callmephil
callmephil / main.dart
Last active January 15, 2024 08:24
In Memory Store (Article Example)
import 'dart:async';
void main() {
final authRepo = AuthenticationRepository();
// listen to cache updates
authRepo.user.listen((event) => print(event));
const user = User(firstName: 'John', lastName: 'Doe', age: 29);
// Create user
@callmephil
callmephil / main.dart
Created January 10, 2024 16:15
go router deeplink bug
import 'package:flutter/material.dart';
import 'package:flutter_web_plugins/url_strategy.dart';
import 'package:go_router/go_router.dart';
final _navKey = GlobalKey<NavigatorState>();
void main() {
usePathUrlStrategy();
runApp(const MyApp());
@callmephil
callmephil / tempate.store.dart
Created September 12, 2023 08:27
Template riverpod store
@riverpod
BookService bookService(BookServiceRef _) {
return const BookService();
}
// fetch single book
@riverpod
Future<Book?> book(BookServiceRef ref, String id) {
return ref.read(bookServiceProvider).getBook(id);
@callmephil
callmephil / main.dart
Last active September 8, 2023 08:02
stream memory caching example for flutter/dart
import 'dart:async';
import 'dart:math';
/// {@template cache_client}
/// An in-memory cache client.
/// {@endtemplate}
class CacheClient {
/// {@macro cache_client}
CacheClient() : _cache = <String, Object>{};
@callmephil
callmephil / main.dart
Last active September 1, 2023 16:45
ValueNotifier Counter example
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
@callmephil
callmephil / main.dart
Last active May 6, 2023 23:08
merge multiple stream example (DART)
import 'dart:async';
import 'dart:math';
/// {@template cache_client}
/// An in-memory cache client.
/// {@endtemplate}
class CacheClient {
/// {@macro cache_client}
CacheClient() : _cache = <String, Object>{};
@callmephil
callmephil / blur_layer.dart
Created March 25, 2023 14:55
optimizied backdrop and blurlayer widgets flutter
class BlurLayer extends StatelessWidget {
final double strength;
final Widget? child;
const BlurLayer({
super.key,
this.strength = 1,
this.child,
});
static const _strengthMultiplier = 15;
@callmephil
callmephil / googlesheetsmerger.js
Last active March 2, 2023 12:04
[app script] Google Sheets Merger Example
function onOpen(e) {
// Add a custom menu to the spreadsheet.
SpreadsheetApp.getUi() // Or DocumentApp, SlidesApp, or FormApp.
.createMenu('Merge Sheets')
.addItem('Press to Merge', 'writeToSheet')
.addToUi();
}
const READ_ONLY_SHEET_NAME = "_merged_";