Skip to content

Instantly share code, notes, and snippets.

View TekExplorer's full-sized avatar
👀
Looking for work

Omar Kamel TekExplorer

👀
Looking for work
View GitHub Profile
@TekExplorer
TekExplorer / cpcc_info.md
Last active November 17, 2023 00:45
A number of resources from the CPCC IT information session
@TekExplorer
TekExplorer / path_uri.dart
Last active November 9, 2023 03:54
Utility classes for ensuring that dir and file paths are consistent (tossed together)
final class DirUri extends PathUri {
DirUri(String path)
: _uri = _parsePathUri(path: '$path/'),
super._();
final Uri _uri;
@override
String? get filename => _uri.filename;
@override
@TekExplorer
TekExplorer / text_field_switch.dart
Last active November 8, 2023 20:00
Synced text field and switch
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@TekExplorer
TekExplorer / example_websocket.dart
Last active November 6, 2023 02:26
Example websocket handler
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:web_socket_channel/web_socket_channel.dart';
final _wsProvider = FutureProvider((ref) async {
final ws = YourWebsocket(Uri(/** ... */));
ref.onDispose(ws.dispose);
await ws.connect();
@TekExplorer
TekExplorer / main.dart
Last active February 24, 2023 21:34
My best riverpod mutation setup yet!
import 'dart:math';
import 'package:flutter/material.dart';
// could use flutter_riverpod
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'mutation_state.dart';
part 'main.g.dart';
@TekExplorer
TekExplorer / mutation_value_riverpod.dart
Created February 22, 2023 06:35
an AsyncValue clone for mutations, i think.
import 'package:meta/meta.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:stack_trace/stack_trace.dart';
part 'mutation_provider.g.dart';
// generic mutation
@riverpod
MutationState<void> mutation(MutationRef ref, Object mutationKey) {
return MutationState._initial(ref);
@TekExplorer
TekExplorer / riverpod_mutation_provider.dart
Last active February 21, 2023 22:40
A potential mutation provider for riverpod
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
part 'mutation_provider.g.dart';
class ExampleWidget extends ConsumerWidget {
const ExampleWidget({super.key});
@TekExplorer
TekExplorer / copy_with_examples.dart
Last active February 19, 2023 08:43
A gist containing examples for copyWith code that can allow passing in null to a copy.
void main() {
print('Wont pass null into a copy');
final e1 = Example1(id: 1, name: 'hello 1');
final e1Copy = e1.copyWith(name: null);
print('e1: ${e1.id}, ${e1.name}');
print('e1Copy: ${e1Copy.id}, ${e1Copy.name}');
print('\nSubclassing method');
void main() {
final isIdentical = identical(Singleton(), Singleton());
print(isIdentical);
assert(isIdentical == true);
}
class Singleton {
static final Singleton _instance = Singleton._();
const Singleton._();
@TekExplorer
TekExplorer / main.dart
Last active November 29, 2022 22:35
Forever Call
void main() {
C()()()()()()()()()()()()();
}
class C {
const C([this.cnt=1]);
final int cnt;