sai_custom_widgets 0.0.1

SDKflutter
Platformandroidioswindowslinuxmacos

A collection of customizable and reusable Flutter widgets to simplify UI development. This package includes widgets for layout gaps, state management with GetX, and more to help developers build responsive and dynamic UIs easily.

Sai Custom Widgets

Sai Custom Widgets is a Flutter package that provides a collection of highly customizable widgets designed to simplify your development process. It includes custom buttons, text fields, dropdowns, switches, date pickers, and platform-specific list tiles.

Features

  • Custom Date Picker: A customizable date picker with a builder pattern.
  • Custom Buttons: Buttons with multiple styles such as standard, outlined, and text buttons.
  • Searchable Dropdown: Dropdown with a search feature to quickly find and select items.
  • Custom Switch: A platform-adaptive switch with customizable behavior.
  • Custom Text Fields: Easy-to-validate text fields with password support.
  • Platform-Specific List Tiles: List tiles that adapt to both iOS and Android design principles.

Getting Started

Installation

To get started with sai_custom_widgets, add it to your pubspec.yaml:

dependencies:
  sai_custom_widgets: ^1.0.0

Example Usage

Here’s an example of how to use the package in your Flutter app:

  1. Custom Date Picker
  2. Custom Button
  3. Custom Switch
  4. Custom Text Field

Preview

Date Picker Preview

Custom Date Picker

The CustomDatePickerWidget allows you to select a date within a range and handle the selected date.

Example:

CustomDatePickerWidget.builder(
initialDate: DateTime.now(),
firstDate: DateTime(2000),
lastDate: DateTime(3000),
onDateSelected: (date) {
    print("Date selected: $date");
},
builder: (context, date) {
    return Text("Selected Date: $date");
},
);

Parameters:

ParameterTypeDescription
initialDateDateTimeThe initial selected date.
firstDateDateTimeThe earliest selectable date.
lastDateDateTimeThe latest selectable date.
onDateSelectedFunction(DateTime)Callback when a date is selected.
builderWidget Function()Custom builder function to display selected date.

Custom Button

The CustomButton is a button widget with several customizable options like loading state, disabled state, and outlined style.

Preview

Custom Button Preview

Example:

CustomButton(
text: "Press Me",
 onPressed: () {
    print("Button Pressed");
},
);

Parameters:

ParameterTypeDescription
textStringThe text displayed inside the button.
onPressedVoidCallback?Callback triggered when the button is pressed.
isLoadingboolIf true, shows a loading spinner. Default: false.
isDisabledboolIf true, disables the button. Default: false.
isOutlinedboolIf true, makes the button outlined. Default: false.
isIconboolIf true, shows a Icon with the title
loadingWidgetWidgetImplement a custom loading widget
fullLoadingboolIf true make the title hide while loading

Custom Outlined Button

The CustomOutlinedButton is an outlined version of the button.

Preview

Custom Outlined Button Preview

Example:

CustomOutlinedButton(
text: "Outlined Button",
onPressed: () {
    print("Outlined Button Pressed");
},
);

Parameters:

ParameterTypeDescription
textStringThe text displayed inside the button.
onPressedVoidCallback?Callback triggered when the button is pressed.
isLoadingboolIf true, shows a loading spinner. Default: false.
isDisabledboolIf true, disables the button. Default: false.

Custom Text Button

The CustomTextButton is a text-only version of the button, similar to TextButton in Flutter.

Example:

CustomTextButton(
text: "Text Button",
onPressed: () {
    print("Text Button Pressed");
},
);

Parameters:

ParameterTypeDescription
textStringThe text displayed inside the button.
onPressedVoidCallback?Callback triggered when the button is pressed.
isLoadingboolIf true, shows a loading spinner. Default: false.
isDisabledboolIf true, disables the button. Default: false.

Searchable Dropdown

The SearchableDropdown widget provides a dropdown list that supports search functionality.

Example:

SearchableDropdown.builder(
hintText: 'Select a Fruit',
items: ['Apple', 'Banana', 'Orange'],
selectedItem: null,
onChanged: (value) {
    print('Selected: $value');
},
onSearch: (text) {
    print('Searching for: $text');
},
builder: (context, selectedItem) {
    return Text(selectedItem ?? 'Select a Fruit');
},
);

Parameters:

ParameterTypeDescription
hintTextStringThe hint text to display before selection.
itemsList<String>The list of selectable items.
selectedItemString?The currently selected item (nullable).
onChangedFunction(String?)Callback when an item is selected.
onSearchFunction(String)Callback when a search query is entered.
builderWidget Function(BuildContext, String?)Custom builder for displaying the selected item.

Custom Switch

The CustomSwitch is a customizable switch widget that adapts to both Android and iOS platform styles.

Example:

CustomSwitch.builder(
onSwitch: (value) {
    print("Switch value: $value");
},
initialValue: false,
builder: (context, isSwitched, inChange) {
    return GestureDetector(
      onTap: () {
        inChange(!isSwitched);
      },
      child: Text("Switch is $isSwitched"),
    );
},
);

Parameters:

ParameterTypeDescription
initialValueboolThe initial state of the switch.
onSwitchFunction(bool)Callback when the switch state changes.
builderWidget Function(...)A builder function to customize the switch UI.

Custom Text Field

The CustomTextField is a highly customizable text field with support for validators, password fields, and more.

Example:

CustomTextField(
hintText: "Enter your name",
onChanged: (value) {
    print("Name: $value");
},
);

Parameters:

ParameterTypeDescription
hintTextStringThe placeholder text inside the text field.
controllerTextEditingController?Controls the text being edited.
isPasswordboolIf true, hides the input text. Default: false.
onChangedFunction(String)?Callback triggered when the text is changed.
validatorsList<ValidatorRule>?A list of validation rules to apply to the input.
onSubmittedFunction(String)?Callback triggered when the user submits the input.

Platform Native List Tile

The PlatformNativeListTile is a platform-specific list tile widget that adapts to both iOS and Android.

Example:

PlatformNativeListTile(
title: "List Tile",
subtitle: "This is a subtitle",
leading: Icon(Icons.person),
onTap: () => print("Tile Tapped"),
);

Parameters:

ParameterTypeDescription
titleStringThe title text for the tile.
subtitleString?The subtitle text for the tile.
leadingWidgetThe leading widget, typically an icon.
trailingWidget?The trailing widget, typically an icon or arrow.
onTapVoidCallbackCallback when the tile is tapped.

Platform Native List Section

The PlatformNativeListSection groups several list tiles together, platform-adaptively.

Example:

PlatformNativeListSection(
sectionHeader: "Section 1",
tiles: [
    PlatformNativeListTile(
      title: "Tile 1",
      subtitle: "Subtitle 1",
      leading: Icon(Icons.account_circle),
      trailing: Icon(Icons.arrow_forward_ios),
      onTap: () {
        print("Tile 1 tapped");
      },
    ),
    PlatformNativeListTile(
      title: "Tile 2",
      subtitle: "Subtitle 2",
      leading: Icon(Icons.email),
      trailing: Icon(Icons.arrow_forward_ios),
      onTap: () {
        print("Tile 2 tapped");
      },
    ),
],
 padding: const EdgeInsets.all(8.0),
);

Parameters:

ParameterTypeDescription
sectionHeaderString?The header text of the section.
tilesList<PlatformNativeListTile>List of platform-native list tiles to display.
paddingEdgeInsetsGeometry?Optional padding around the list section.