Skip to content

Instantly share code, notes, and snippets.

View BarryDaBee's full-sized avatar
💻

Olusesi Boluwatife Barry BarryDaBee

💻
View GitHub Profile
@BarryDaBee
BarryDaBee / app_slidable.dart
Created February 24, 2025 06:38
Flutter Hook implementation of a Slidable widget that snaps to parentWidth / 2 and automatically closes on swipe. This was created because flutter_slidable's action buttons always fill the parent height, which is not always the intended behavior.
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
class AppSlidable extends HookWidget {
const AppSlidable({
required this.child,
required this.actions,
super.key,
});
@BarryDaBee
BarryDaBee / stripes_painter.dart
Created February 20, 2025 09:05
CustomPainter for diagonal stripes. PS: Check the first comment
import 'package:flutter/material.dart';
class StripesPainter extends CustomPainter {
StripesPainter({required this.stripeColor});
final Color stripeColor;
@override
void paint(Canvas canvas, Size size) {
final paint = Paint()
..color = stripeColor
@BarryDaBee
BarryDaBee / app_typography.dart
Last active February 7, 2025 06:41
A robust approach to handling app typography using theme_extensions for large scale apps with SOLID principles. PS: Open to questions, suggestions and improvements.
import 'package:flutter/material.dart';
abstract class AppTypography {
AppTypography({
required this.name,
required this.regular,
required this.medium,
required this.semiBold,
required this.bold,
});
@BarryDaBee
BarryDaBee / bouncing_button.dart
Created January 26, 2025 01:20
Bouncing effect onClick widget with flutter_hooks
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
class BouncingButton extends HookWidget {
const BouncingButton({
required this.child,
required this.onTap,
super.key,
this.scaleDown = 0.91,
@BarryDaBee
BarryDaBee / semantics_overlay.dart
Created January 23, 2025 01:02
Custom tooltip that shows TextStyle info on flutter web
class AppText extends StatelessWidget {
const AppText(
this.text, {
super.key,
required this.textStyle,
required this.textAlign,
});
final String text;
final TextStyle textStyle;
@BarryDaBee
BarryDaBee / phone_number_input_formatter.dart
Created April 1, 2024 06:30
Phone Number TextInputFormatter for (XXX) XXX-XXXX
import 'package:flutter/services.dart';
class PhoneNumberFormatter extends TextInputFormatter {
@override
TextEditingValue formatEditUpdate(
TextEditingValue oldValue, TextEditingValue newValue,) {
if (newValue.text.isEmpty) {
return newValue;
}
@BarryDaBee
BarryDaBee / rounded_trapezoid_painter.dart
Created April 1, 2024 06:27
Trapezoid shape with rounded corners
import 'dart:math' as math;
class RoundedTrapezoidShapePainter extends CustomPainter {
/// BackgroundColor of the shape
///
final Color? color;
/// Radius of the topRight and topLeft corners
///
final double radius;
@BarryDaBee
BarryDaBee / custom_navigation_bar.dart
Created July 18, 2023 18:11
CustomNavigationBar built using BottomAppBar with BottomNavigationBar functionality and a similar API
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
@BarryDaBee
BarryDaBee / clickable_text_view.dart
Created April 13, 2023 00:19
Sample showing how to create Text with clickable words
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
class ClickableTextView extends StatelessWidget {
final String text;
const ClickableTextView({Key? key, required this.text}) : super(key: key);
@override
Widget build(BuildContext context) {
return RichText(
@BarryDaBee
BarryDaBee / card_input_formatter.dart
Created March 6, 2023 08:54
A simple text input formatter for grouping text by splitAt and separating with the separator e.g. 2222-1111 has splitAt: 4 and seperator: '-'
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class CardInputFormatter extends TextInputFormatter {
CardInputFormatter({required this.separator, this.splitAt = 4});
final String separator;
final int splitAt;
@override
TextEditingValue formatEditUpdate(