Skip to content

Instantly share code, notes, and snippets.

Avatar

Bryan Cancel b-cancel

View GitHub Profile
@b-cancel
b-cancel / sliverPersistentHeaderDelegate.dart
Created Sep 16, 2019
SliverPersistentHeaderDelegate Example
View sliverPersistentHeaderDelegate.dart
/*
SliverPersistentHeader(
pinned: true,
floating: true,
delegate: OurDelegate(
toolBarHeight: MediaQuery.of(context).padding.top,
openHeight: 250,
closedHeight: 40,
),
),
@b-cancel
b-cancel / main.dart
Last active Nov 24, 2019
FLUTTER select contact page setup
View main.dart
import 'package:flutter/material.dart';
import 'package:flutter_sticky_header/flutter_sticky_header.dart';
//-----Start App
void main() => runApp(MyApp());
//-----Entry Point
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
@b-cancel
b-cancel / alphaScrollBarOverlay.dart
Created Aug 6, 2019
FLUTTER Dynamic Alphabetic Overlay
View alphaScrollBarOverlay.dart
import 'package:flutter/material.dart';
import 'dart:math' as math;
//NOTE: this widget is designed specifically to go OVER a slider
//the idea is that the slider takes you to certain positions and this should give you some idea of what those positions are
//In order to meet it's goals as best as possible we MUST
//1. fill the entirety of the totalHeight
// - otherwise the overlay won't match the slider and it won't be helpful
@b-cancel
b-cancel / gattSpecs.dart
Last active Jun 18, 2019
Bluetooth Gatt Specification Maps For Dart
View gattSpecs.dart
//other stuff to maybe map out
//https://www.bluetooth.com/specifications/assigned-numbers/company-identifiers/
//https://www.bluetooth.com/specifications/assigned-numbers/16-bit-uuids-for-members/
//https://www.bluetooth.com/specifications/assigned-numbers/16-bit-uuids-for-sdos/
//https://www.bluetooth.com/specifications/assigned-numbers/service-discovery/
//https://www.bluetooth.com/specifications/assigned-numbers/health-device-profile/
//https://www.bluetooth.com/specifications/assigned-numbers/units/
//Gatt Service Hierarchy
//Device
@b-cancel
b-cancel / main.dart
Created Sep 4, 2018
FLUTTER => password and confirm password field validation before the creation of a user. Handles all edge cases well without blocking user input at any point.
View main.dart
String getPasswordValidationError(bool forPassword) {
String initialPasswordString = focusNodeToValue[passwordFocusNode].value;
String confirmPasswordString = focusNodeToValue[confirmPasswordFocusNode].value;
///-----make sure this particular password is valid
if (forPassword) {
if (initialPasswordString.isNotEmpty == false)
return "Password Required";
else if (initialPasswordString.length < 6)
return "The Password Requires 6 Characters Or More";
@b-cancel
b-cancel / main.dart
Created Aug 15, 2018
FLUTTER => using inputFormatters for things other than inputFormatting
View main.dart
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() => runApp(
MaterialApp(home: new MyApp())
);
class MyApp extends StatefulWidget {
@b-cancel
b-cancel / EnsureVisibleWhenFocused
Last active Jun 28, 2019
FLUTTER => Ensures that "TextFormFields" are visible when focused in Flutter
View EnsureVisibleWhenFocused
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:meta/meta.dart';
/// Note:
/// [*] some functions are async simply because that schedules them after something else that should happen first for everything to work properly
/// [*] you really should not use "ensureVisible" or "ensureErrorVisible" or "KeyboardListener" unless that field is already wrapped in "EnsureVisibleWhenFocused"
/// you will get very unusual behavior
@b-cancel
b-cancel / main.dart
Last active Aug 15, 2018
FLUTTER => Synchronous Operations Taking Up Time In An Asynchronous Function
View main.dart
import 'dart:async';
import 'package:flutter/material.dart';
/*
OUTPUT (one of many) NOTE: how far behind the Loose Timer is, is not predictable either
I/flutter (11433): Timer Restarted
I/flutter (11433): Timers Started
I/flutter (11433): Loose Timer Will Take 588 solid runs of 0:00:00.017000 and an extra run of 0:00:00.004000
@b-cancel
b-cancel / main.dart
Last active Jul 8, 2018
FLUTTER => Using Widget Sizes to calculate the Sizes of other widgets Automatically Or Manually
View main.dart
import 'package:flutter/material.dart';
import 'dart:async';
//Desired Behavior on FIRST build (It should not take 3)
//CASE 1 (parent uses child size) : eye.width = vane.width * 10
//CASE 2 (child uses parent size) : pupil.width = iris.width / 2
//CASE 3: (child uses sibling size) : iris.width = vane.width * 5
//Desired Sizes (can be read from Render Tree in Flutter Inspector) [in original config of 4 letters]
//vane = 30
@b-cancel
b-cancel / main.dart
Last active May 30, 2020
FLUTTER => Overriding Back Button in Flutter
View main.dart
import 'package:flutter/material.dart';
import 'dart:async';
void main() => runApp(new BackButtonOverrideDemoWidget());
class BackButtonOverrideDemoWidget extends StatefulWidget{
@override
_BackButtonOverrideDemoWidgetState createState() => new _BackButtonOverrideDemoWidgetState();
}
You can’t perform that action at this time.