Skip to content

Instantly share code, notes, and snippets.

View BarryDaBee's full-sized avatar
💻

Olusesi Boluwatife Barry BarryDaBee

💻
View GitHub Profile
@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(
@BarryDaBee
BarryDaBee / password_validator.dart
Last active March 2, 2023 13:04
A simple widget for validating password conditions like length >= 8, hasNumber etc
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
@BarryDaBee
BarryDaBee / read_more_with_mention.dart
Last active December 29, 2022 08:50
Read More text with support for @mention. To be extended to accept a map of indicators and corresponding textStyles
class ReadMoreWithMention extends StatefulWidget {
final String text;
final TextStyle? textStyle;
final String readMoreText;
final TextStyle? readMoreTextStyle;
final int maxLines;
final int steps;
// final bool shouldUseSteps;
const ReadMoreWithMention({
Key? key,
@BarryDaBee
BarryDaBee / resizing_card.dart
Created November 22, 2022 06:35
Demonstration of how to get the size of a widget and delay its rendering by one frame
class ResizingCard extends StatefulWidget {
const ResizingCard({Key? key, this.onClose}) : super(key: key);
final VoidCallback? onClose;
@override
State<ResizingCard> createState() => _ResizingCardState();
}
class _ResizingCardState extends State<ResizingCard>
@BarryDaBee
BarryDaBee / custom_track_shape.dart
Created November 13, 2022 06:04
Custom track shape for flutter slider widget without height
import 'package:flutter/material.dart';
class CustomTrackShape extends RoundedRectSliderTrackShape {
@override
Rect getPreferredRect(
{required RenderBox parentBox,
Offset offset = Offset.zero,
required SliderThemeData sliderTheme,
bool isEnabled = false,
bool isDiscrete = false}) {
@BarryDaBee
BarryDaBee / read_more.dart
Last active October 8, 2022 15:32
Implementation of common "Read more" feature to truncate and expand lengthy text on demand
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
class ReadMore extends StatefulWidget {
final String text;
final TextStyle? textStyle;
final String readMoreText;
final TextStyle? readMoreTextStyle;
final int maxLines;
final int steps;