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 / 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(
Property/Callback Description
onTapDown OnTapDown is fired everytime the user makes contact with the screen.
onTapUp When the user stops touching the screen, onTapUp is called.
onTap When the screen is briefly touched, onTap is triggered.
onTapCancel When a user touches the screen but does not complete the Tap, this event is fired.
onDoubleTap onDoubleTap is called when the screen is touched twice in quick succession.
// 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 / page_view_indicator.dart
Created July 19, 2018 19:55
A modified version of a page view indicator for @flutter. Based on code originally created by @collinjackson
import 'dart:math';
import 'package:flutter/material.dart';
class PageViewIndicator extends StatefulWidget {
PageViewIndicator({
this.controller,
this.pageCount,
this.color: Colors.lightBlueAccent,
});
@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);
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Nested tab bar list demo',
theme: ThemeData(
@Nash0x7E2
Nash0x7E2 / page_navigation_bug.dart
Created September 23, 2019 19:47
Sample code demonstrating back navigation bug in Flutter 1.10.5
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
@Nash0x7E2
Nash0x7E2 / ConstrainedView.dart
Last active March 28, 2019 02:37
Used to constrain the child of a scrollable to the max height of the view.
import 'package:flutter/material.dart';
class ConstrainedView extends StatelessWidget {
const ConstrainedView({Key key, this.child}) : super(key: key);
final Widget child;
@override
Widget build(BuildContext context) {
return LayoutBuilder(