Skip to content

Instantly share code, notes, and snippets.

View Nash0x7E2's full-sized avatar
🎯
Tinkering with Flutter, Dart and everything Apple

Neevash Ramdial (Nash) Nash0x7E2

🎯
Tinkering with Flutter, Dart and everything Apple
View GitHub Profile
@Nash0x7E2
Nash0x7E2 / send_message_using_shortcut_stream.dart
Created September 2, 2021 23:59
Send a message using a keyboard shortcut in Flutter.
import 'package:collection/collection.dart' show IterableExtension;
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
Future<void> main() async {
final client = StreamChatClient(
's2dxdhpxd94g',
logLevel: Level.INFO,
);
import 'dart:ui';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/painting.dart';
void main() {
runApp(const App());
}
@Nash0x7E2
Nash0x7E2 / interactive_card.dart
Last active August 31, 2022 20:08
Implementation of Flutter's Card widget using the MaterialStateProperty API for handling and responding to user interaction. This implementation allows developers to quick and easily customize properties on their card whenever a user taps and hover on the widget. Please see the following link for more information on MaterialStateProperty: https:…
/// Implementation of [Card] using the new [MaterialStateProperty] for handling
/// and reacting to user interactions.
class InteractiveCard extends StatefulWidget {
const InteractiveCard({
Key? key,
this.color,
this.shadowColor,
this.elevation,
this.shape,
this.borderOnForeground = true,
@Nash0x7E2
Nash0x7E2 / animating_text.dart
Created May 31, 2021 03:46
Animating text made in Flutter. As text appear on screen, they animate between a start and ending color. Demo can be found here: https://twitter.com/Nash0x7E2/status/1399194632626520067?s=20
import 'package:flutter/material.dart';
void main() {
runApp(TexColDemo());
}
class TexColDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
@Nash0x7E2
Nash0x7E2 / resizing_chat.dart
Last active January 3, 2021 17:36
Resizing chat build with Flutter and @GetStream
import 'package:flutter/material.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
import './responsive_builder.dart';
// This sample uses GetStream for chat. To get started, please see https://getstream.io/chat/flutter/tutorial/
Future<void> main() async {
final Client streamClient = Client("YOUR-STREAM-KEY", persistenceEnabled: false);
await streamClient.setUser(
User(
@Nash0x7E2
Nash0x7E2 / date-interval.dart
Created September 22, 2020 15:53
Handy little util for calculating time intervals between two DateTime in Dart.
void main() {
calculateDateInterval(DateTime(2020, 09, 22, 11, 00), DateTime(2020, 09, 22, 16, 00), 0.75);
}
void calculateDateInterval(
final DateTime startTime,
final DateTime endTime,
final double intervalInHours,
) {
final workingHours = endTime.difference(startTime).inHours;
@Nash0x7E2
Nash0x7E2 / app_bar_flutter_coffee_example.dart
Last active September 13, 2020 01:07
Sample code for meant to demonstrating writing simple widget test for your applications. Code used as part of an upcoming Flutter testing talk by @mkiisoft and myself.
import 'package:flutter/material.dart';
const kBreakpoint = 860.0;
extension Width on BuildContext {
double get width => MediaQuery.of(this).size.width;
}
void main() {
runApp(
@Nash0x7E2
Nash0x7E2 / main.dart
Created April 17, 2020 00:44
Apple's Breathe Animation in Flutter
// MIT License
//
// Copyright (c) 2020 Neevash Ramdial
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// MIT License
//
// Copyright (c) 2019 Neevash Ramdial
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@Nash0x7E2
Nash0x7E2 / distinct_list.dart
Created October 8, 2019 15:28
Filters the duplicate items from both list. Returns a new list of type T unique items.
/// Mixin containing a helper list method
mixin ListDistinct {
/// Creates a new list with the unique elements form [listOne] and [listTwo].
/// The new list is returned with the specified type [T]
List<T> distinct<T>(List<T> listOne, List<T> listTwo) {
final List<T> _newList = <T>[];
_newList.addAll(listOne);
for (final T item in listTwo) {
if (_newList.contains(item)) {
_newList.remove(item);