xwidgets library

XWidgets

A small collection of reusable, customizable Flutter widgets intended to speed up common UI tasks and provide a consistent look & feel across apps.

Overview

  • Purpose: Provide lightweight, well-documented, and configurable widgets that are easy to drop into any Flutter project.
  • Scope: Visual building blocks such as app bars, buttons, cards, text helpers, dashed/divider widgets, snackbars, spacers and enhanced text-fields with validation helpers.

Widgets exported by this library

  • XAppBar — flexible AppBar replacement with built-in title, actions, and optional leading/content customization.
  • XButton — configurable button supporting variants, icons, and styles.
  • XCard — a simple card wrapper with padding, elevation and shape props.
  • XDiagonalStrikethroughText — draws a diagonal strikethrough over text (useful for sale/discount UI or decorative effects).
  • XDoubleDashedLine — renders two parallel dashed lines, useful as a decorative divider.
  • XSingleDashedLine — renders a single dashed line divider.
  • XSnackbar — a thin wrapper for showing stylable snackbars with convenience options for duration and actions.
  • XSpacer — shorthand for flexible spacing between widgets.
  • XTextField — enhanced text field with built-in validator hooks and styling options.
  • XText — lightweight text helper that consolidates common text styles.

Usage Add the package import and use widgets directly:

import 'package:xwidgets/xwidgets.dart';

Example: simple button
XButton(
  label: 'Send',
  onPressed: () => print('sent'),
);

Contributing

  • See the repository README.md for contribution guidelines, code style, and how to run code generation or tests.

Compatibility

  • Built for Flutter stable channel. Check pubspec.yaml for environment SDK constraints and dependency versions.

Classes

XAppBar
A highly configurable wrapper around Flutter's built-in AppBar, providing extended flexibility for common UI requirements.
XButton
A customizable button widget that supports icons, loading state, custom text widget, rounded style, and various appearance configurations.
XCard
A customizable card container widget with padding, margin, background color, rounded corners, and shadow.
XDiagonalStrikethroughText
A text widget with a diagonal strikethrough line drawn across it.
XDoubleDashedLine
A horizontal double-dashed divider line drawn using a custom painter.
XHeight
XSingleDashedLine
A horizontal single dashed line divider drawn using a custom painter.
XSnackbar
A utility class for displaying styled snackbars at the top or bottom of the screen. Works with Overlay for top-positioned snackbars and uses the native Flutter SnackBar for bottom-positioned snackbars.
XSnackbarType
Defines the color of the snackbar. Used internally by XSnackbar.
XSpacer
A simple spacer widget that provides vertical or horizontal spacing.
XText
A customizable text widget that supports an optional leading icon, underline decoration, tap handling, width limitation, and overflow control.
XTextField
A flexible text field widget supporting:
XWidth

Enums

XDiagonalStrikethroughType
Type of diagonal strikethrough line rendered over the text.
XSnackbarPosition
Determines where the snackbar will be displayed.
XTextFieldType
Defines supported field types for XTextField.

Functions

styleButtonRounded({double radius = 10, Color? background, Color? foreground, Color? borderColor, bool? isEnable = true, double elevation = 1, double paddingHorizontal = 12, double paddingVertical = 5, double borderWidth = 0}) ButtonStyle
Creates a rounded ButtonStyle used by XButton.