### Flutter AlertDialog Constructor and Example Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/AlertDialog/AlertDialog Demonstrates the constructor for Flutter's AlertDialog and provides a practical example of its usage in creating a confirmation dialog. The constructor accepts various optional parameters for customization, and the example showcases how to set the title, content, and actions. ```dart const AlertDialog({ Key? key, Widget? leading, Widget? title, Widget? content, List? actions, Widget? trailing, double? surfaceBlur, double? surfaceOpacity, Color? barrierColor, EdgeInsetsGeometry? padding, }) // Example Usage: AlertDialog( title: Text('Confirm Action'), content: Text('This action cannot be undone.'), actions: [ TextButton(onPressed: () => Navigator.pop(context), child: Text('Cancel')), ElevatedButton(onPressed: _confirm, child: Text('Confirm')), ], ); // Implementation: const AlertDialog({ super.key, this.leading, this.title, this.content, this.actions, this.trailing, this.surfaceBlur, this.surfaceOpacity, this.barrierColor, this.padding, }); ``` -------------------------------- ### KeyboardDisplay Example Usage - Dart Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/KeyboardDisplay/KeyboardDisplay An example demonstrating how to instantiate the KeyboardDisplay widget with a list of keys and custom spacing. This showcases a practical application of the constructor. ```dart KeyboardDisplay( keys: [LogicalKeyboardKey.alt, LogicalKeyboardKey.tab], spacing: 6.0, ) ``` -------------------------------- ### Dart: Example Usage of NavigationMenuContent Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/NavigationMenuContent/NavigationMenuContent Demonstrates how to instantiate and use the NavigationMenuContent widget in Dart. This example shows the setup for a settings menu item with icons and descriptive text. ```dart NavigationMenuContent( leading: Icon(Icons.settings), title: Text('Settings'), content: Text('Manage application preferences'), trailing: Icon(Icons.arrow_forward_ios, size: 16), onPressed: _openSettings, ) ``` -------------------------------- ### KeyboardKeyDisplay Usage Example - Dart Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/KeyboardKeyDisplay/KeyboardKeyDisplay An example demonstrating how to instantiate and use the KeyboardKeyDisplay widget in a Flutter application. It shows how to provide the required `keyboardKey` and optional `padding` parameters. ```dart KeyboardKeyDisplay( keyboardKey: LogicalKeyboardKey.escape, padding: EdgeInsets.all(6), ) ``` -------------------------------- ### Radio Widget Usage Example - Dart Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/Radio/Radio Demonstrates how to use the Radio widget in a Flutter application. This example showcases the instantiation of the Radio widget with essential parameters like `value` and `focusing`, along with optional styling parameters such as `size`. It serves as a practical guide for developers integrating the Radio component into their UIs. ```dart Radio( value: selectedValue == itemValue, focusing: focusNode.hasFocus, size: 18, ); ``` -------------------------------- ### Avatar Widget Usage Example Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/Avatar/Avatar Demonstrates how to use the Avatar widget with custom properties. This example shows setting initials, size, background color, and adding a badge. ```dart Avatar( initials: 'JD', size: 48, backgroundColor: Colors.blue.shade100, badge: AvatarBadge(color: Colors.green), ); ``` -------------------------------- ### Example Usage of ShadcnSkeletonizerConfigLayer in Dart Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/ShadcnSkeletonizerConfigLayer/ShadcnSkeletonizerConfigLayer Demonstrates how to instantiate ShadcnSkeletonizerConfigLayer with a theme, duration, and a child widget. This example shows a typical use case for applying skeleton configurations to content. ```dart ShadcnSkeletonizerConfigLayer( theme: Theme.of(context), duration: Duration(milliseconds: 1200), child: MyContentWidget(), ); ``` -------------------------------- ### Instantiate CodeSnippet Widget with Example (Dart) Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/CodeSnippet/CodeSnippet Provides an example of how to instantiate the CodeSnippet widget in a Flutter application. This demonstrates setting the code content, programming language mode, and size constraints. ```dart CodeSnippet( code: 'print("Hello World")', mode: 'dart', constraints: BoxConstraints(maxHeight: 150), ); ``` -------------------------------- ### AccordionItem Usage Example in Dart Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/AccordionItem/AccordionItem An example demonstrating how to instantiate an AccordionItem. It shows the setup of the trigger widget (e.g., Text within AccordionTrigger) and the content widget (e.g., Container with Text), along with setting the initial expanded state. ```dart AccordionItem( trigger: AccordionTrigger( child: Text('Item Title'), ), content: Container( padding: EdgeInsets.all(16), child: Text('Item content goes here...'), ), expanded: false, ); ``` -------------------------------- ### Flutter Radio Widget Example Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/Radio-class An example demonstrating how to use the Flutter Radio widget. This code shows the basic instantiation with selection state, focus, size, and active color. ```dart Radio( value: isSelected, focusing: hasFocus, size: 20, activeColor: Colors.blue, ); ``` -------------------------------- ### DateInput Widget Example Usage (Dart) Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/DateInput/DateInput An example demonstrating how to use the DateInput widget in a Flutter application. This snippet shows how to configure the controller, mode, placeholder, and date part order. ```dart DateInput( controller: controller, mode: PromptMode.popover, placeholder: Text('Select date'), datePartsOrder: [DatePart.month, DatePart.day, DatePart.year], ) ``` -------------------------------- ### ToastLayer Initialization Example Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/ToastLayer/ToastLayer An example demonstrating how to initialize a ToastLayer widget with custom parameters for max stacked entries, expansion mode, and spacing, wrapping a MaterialApp. ```dart ToastLayer( maxStackedEntries: 5, expandMode: ExpandMode.expandOnTap, spacing: 12.0, child: MaterialApp(home: HomePage()), ); ``` -------------------------------- ### Accordion Widget Example (Dart) Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/Accordion/Accordion An example demonstrating how to create and use the Accordion widget. It shows the structure for defining trigger and content for each AccordionItem within the Accordion's items list. ```dart Accordion( items: [ AccordionItem( trigger: AccordionTrigger(child: Text('FAQ 1')), content: Text('Answer to first question...'), ), AccordionItem( trigger: AccordionTrigger(child: Text('FAQ 2')), content: Text('Answer to second question...'), ), ], ); ``` -------------------------------- ### DurationInput Usage Example - Dart Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/DurationInput/DurationInput An example demonstrating how to use the DurationInput widget with custom controllers, second display, separators, and placeholders for time parts. ```dart DurationInput( controller: controller, showSeconds: true, separator: InputPart.text(':'), placeholders: { TimePart.hour: Text('HH'), TimePart.minute: Text('MM'), TimePart.second: Text('SS'), }, ) ``` -------------------------------- ### ControlledMultipleChoice Widget Initialization Example - Dart Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/ControlledMultipleChoice/ControlledMultipleChoice An example demonstrating how to initialize and use the ControlledMultipleChoice widget. This specific example configures the widget to manage theme selection, disabling unselection and providing a callback for theme changes. ```dart ControlledMultipleChoice( initialValue: Theme.dark, allowUnselect: false, onChanged: (theme) => setAppTheme(theme), child: ThemeSelector(), ); ``` -------------------------------- ### Timeline Widget Usage Example (Dart) Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/Timeline/Timeline Provides a practical example of how to create and configure a `Timeline` widget. It demonstrates passing `timeConstraints` and a list of `TimelineData` objects, each with time, title, content, and an optional color. ```dart Timeline( timeConstraints: BoxConstraints(minWidth: 80, maxWidth: 120), data: [ TimelineData( time: Text('Yesterday'), title: Text('Initial Setup'), content: Text('Project repository created and initial structure added.'), ), TimelineData( time: Text('Today'), title: Text('Feature Development'), content: Text('Implementing core functionality and UI components.'), color: Colors.orange, ), ], ); ``` -------------------------------- ### Flutter Step Widget Usage Example Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/Step/Step Demonstrates how to create an instance of the `Step` widget in Flutter. It shows how to provide a `title`, an optional `icon`, and a `contentBuilder` for custom content. ```dart Step( title: Text('Account Setup'), icon: Icon(Icons.account_circle), contentBuilder: (context) => AccountSetupForm(), ); ``` -------------------------------- ### ToastLayer Widget Initialization Example Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/ToastLayer-class This example demonstrates how to initialize the ToastLayer widget, wrapping application content. It shows configuration options for maximum stacked entries and expansion mode, which controls how toasts behave on hover or tap. ```dart ToastLayer( maxStackedEntries: 4, expandMode: ExpandMode.expandOnHover, child: MyAppContent(), ); ``` -------------------------------- ### Flutter AutoComplete Widget Example Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/AutoComplete/AutoComplete An example demonstrating how to use the AutoComplete widget, providing suggestions, setting the mode to 'append', defining a custom completer function, and integrating it with a TextField. ```dart AutoComplete( suggestions: suggestions, mode: AutoCompleteMode.append, completer: (text) => '$text ', child: TextField(), ) ``` -------------------------------- ### Flutter showToast Example Usage Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/showToast An example demonstrating how to use the showToast function to display a success alert toast. This example shows how to provide the context, a builder function for the toast content, and configure properties like location and show duration. ```dart final toast = showToast( context: context, builder: (context, overlay) => AlertCard( title: 'Success', message: 'Operation completed successfully', onDismiss: overlay.close, ), location: ToastLocation.topRight, showDuration: Duration(seconds: 3), ); ``` -------------------------------- ### Flutter ControlledChipInput Usage Example Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/ControlledChipInput/ControlledChipInput An example demonstrating how to use the ControlledChipInput widget in Flutter. It showcases the setup of the controller, chip builder, suggestions, placeholder, and other customization options for a rich user experience. ```dart ControlledChipInput( controller: controller, chipBuilder: (context, chip) => Chip( label: Text(chip), onDeleted: () => controller.remove(chip), ), suggestions: ['apple', 'banana', 'cherry'], placeholder: Text('Type to add fruits...'), undoHistoryController: myUndoController, onSubmitted: (text) => print('Submitted: $text'), initialText: 'Start typing...', focusNode: myFocusNode, inputFormatters: [myFormatter], textInputAction: TextInputAction.done, suggestionLeadingBuilder: (context, chip) => Icon(Icons.star), suggestionTrailingBuilder: (context, chip) => Icon(Icons.close), inputTrailingWidget: Icon(Icons.add), ) ``` -------------------------------- ### show Method Documentation Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/FullScreenDialogOverlayHandler/show This section details the `show` method, its parameters, and its implementation for displaying dialog overlays. ```APIDOC ## show Method ### Description Displays a dialog overlay with customizable properties. ### Method `OverlayCompleter show(...)` ### Parameters #### Path Parameters None. #### Query Parameters None. #### Request Body * **context** (BuildContext) - Required - The build context for the overlay. * **alignment** (AlignmentGeometry) - Required - The alignment of the overlay. * **builder** (WidgetBuilder) - Required - A builder function that returns the widget to display in the overlay. * **position** (Offset?) - Optional - The position of the overlay. * **anchorAlignment** (AlignmentGeometry?) - Optional - The alignment of the anchor. * **widthConstraint** (PopoverConstraint) - Optional - The width constraint for the overlay (default: `PopoverConstraint.flexible`). * **heightConstraint** (PopoverConstraint) - Optional - The height constraint for the overlay (default: `PopoverConstraint.flexible`). * **key** (Key?) - Optional - The key for the overlay. * **rootOverlay** (bool) - Optional - Whether to use the root overlay (default: `true`). * **modal** (bool) - Optional - Whether the overlay is modal (default: `true`). * **barrierDismissable** (bool) - Optional - Whether the barrier is dismissible (default: `true`). * **clipBehavior** (Clip) - Optional - The clip behavior of the overlay (default: `Clip.none`). * **regionGroupId** (Object?) - Optional - The ID of the region group. * **offset** (Offset?) - Optional - The offset of the overlay. * **transitionAlignment** (AlignmentGeometry?) - Optional - The alignment for the transition. * **margin** (EdgeInsetsGeometry?) - Optional - The margin of the overlay. * **follow** (bool) - Optional - Whether the overlay follows the anchor (default: `true`). * **consumeOutsideTaps** (bool) - Optional - Whether to consume outside taps (default: `true`). * **onTickFollow** (ValueChanged?) - Optional - A callback for tick follow events. * **allowInvertHorizontal** (bool) - Optional - Whether to allow horizontal inversion (default: `true`). * **allowInvertVertical** (bool) - Optional - Whether to allow vertical inversion (default: `true`). * **dismissBackdropFocus** (bool) - Optional - Whether to dismiss on backdrop focus (default: `true`). * **showDuration** (Duration?) - Optional - The duration to show the overlay. * **dismissDuration** (Duration?) - Optional - The duration to dismiss the overlay. * **overlayBarrier** (OverlayBarrier?) - Optional - The overlay barrier. * **layerLink** (LayerLink?) - Optional - The layer link for the overlay. ### Request Example ```dart OverlayCompleter completer = show( context: context, alignment: Alignment.center, builder: (context) => AlertDialog( title: const Text('Example Dialog'), content: const Text('This is a sample dialog.'), actions: [ TextButton(onPressed: () => Navigator.of(context).pop('Result1'), child: const Text('Option 1')), TextButton(onPressed: () => Navigator.of(context).pop('Result2'), child: const Text('Option 2')), ], ), ); completer.future.then((value) => print('Dialog result: $value')); ``` ### Response #### Success Response (OverlayCompleter) * **future** (Future) - A future that completes when the overlay is dismissed, returning the result. #### Response Example ```json // The response is an OverlayCompleter, the actual result is obtained via its 'future' property. // Example of accessing the result: // completer.future.then((result) { print(result); }); ``` ``` -------------------------------- ### NavigationRail Constructor Example - Flutter Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/NavigationRail/NavigationRail Demonstrates how to create and configure a NavigationRail widget using its constructor. This example shows setting alignment, label type, the current index, and handling selection events. ```flutter NavigationRail( alignment: NavigationRailAlignment.start, labelType: NavigationLabelType.all, index: currentIndex, onSelected: (index) => _navigate(index), children: navigationItems, ) ``` -------------------------------- ### StepContainer Widget Usage Example in Dart Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/StepContainer/StepContainer An example demonstrating how to instantiate and use the StepContainer widget. It shows the required 'child' widget and a list of 'actions' widgets, typically buttons for navigation. ```dart StepContainer( child: FormFields(), actions: [ Button(onPressed: previousStep, child: Text('Back')), Button(onPressed: nextStep, child: Text('Continue')), ], ); ``` -------------------------------- ### Dart removeWhere Example: Remove elements starting with 'B' Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/SetNotifier/removeWhere Demonstrates how to use the removeWhere method to remove elements from a Dart Set that meet a specific condition. The condition here is that the element (a String) starts with the character 'B'. ```dart final characters = {"A", "B", "C"}; characters.removeWhere((element) => element.startsWith('B')); print(characters); // {A, C} ``` -------------------------------- ### Dart retainWhere Example: Filtering a Set of Strings Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/SetNotifier/retainWhere This example demonstrates the usage of the retainWhere method on a Set of strings. It filters the set to keep only elements that start with 'B' or 'C'. The method modifies the set in place. ```dart final characters = {"A", "B", "C"}; characters.retainWhere( (element) => element.startsWith('B') || element.startsWith('C')); print(characters); // {B, C} ``` -------------------------------- ### Menubar Usage Example (Dart) Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/Menubar/Menubar Demonstrates how to use the Menubar widget in a Flutter application. This example shows the creation of a menu with nested menu items and dividers. ```dart Menubar( border: true, popoverOffset: Offset(0, 8), children: [ MenuItem( title: Text('View'), children: [ MenuItem(title: Text('Zoom In')), MenuItem(title: Text('Zoom Out')), MenuDivider(), MenuItem(title: Text('Full Screen')), ], ), MenuItem( title: Text('Tools'), children: [ MenuItem(title: Text('Preferences')), MenuItem(title: Text('Extensions')), ], ), ], ) ``` -------------------------------- ### NavigationMenu Usage Example - Flutter Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/NavigationMenu/NavigationMenu An example demonstrating how to instantiate a NavigationMenu widget. It showcases setting optional appearance properties like surfaceOpacity and providing required NavigationMenuItem widgets for 'Home' and 'About' sections. ```dart NavigationMenu( surfaceOpacity: 0.9, children: [ NavigationMenuItem(child: Text('Home'), onPressed: _goHome), NavigationMenuItem(child: Text('About'), onPressed: _showAbout), ], ) ``` -------------------------------- ### Stepper Widget Usage Example Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/Stepper/Stepper Demonstrates how to create and use the Stepper widget in a Flutter application. It shows the initialization of a `StepperController` and the configuration of the `Stepper` with various steps and optional parameters like `direction`, `size`, and `variant`. ```dart final controller = StepperController(currentStep: 0); Stepper( controller: controller, direction: Axis.vertical, size: StepSize.large, variant: StepVariant.line, steps: [ Step(title: Text('Step 1')), Step(title: Text('Step 2')), Step(title: Text('Step 3')), ], ); ``` -------------------------------- ### Swiper Widget Usage Example - Flutter Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/Swiper-class Demonstrates how to implement the Swiper widget to display a navigation drawer triggered by a swipe gesture. This example shows the basic setup with handler, position, builder, and child widget. ```dart Swiper( handler: SwiperHandler.drawer, position: OverlayPosition.left, builder: (context) => NavigationDrawer(), child: AppBar( leading: Icon(Icons.menu), title: Text('My App'), ), ) ``` -------------------------------- ### Sortable Widget Implementation Example Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/Sortable-class This example demonstrates how to implement the Sortable widget within a SortableLayer to enable drag-and-drop functionality for a list of items. It shows the basic setup for handling accept events and reordering. ```dart SortableLayer( child: Column( children: [ Sortable( data: SortableData('Item 1'), onAcceptTop: (data) => reorderAbove(data.data), onAcceptBottom: (data) => reorderBelow(data.data), child: Card(child: Text('Item 1')), ), Sortable( data: SortableData('Item 2'), onAcceptTop: (data) => reorderAbove(data.data), onAcceptBottom: (data) => reorderBelow(data.data), child: Card(child: Text('Item 2')), ), ], ), ) ``` -------------------------------- ### Flutter TreeItemView Widget Usage Example Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/TreeItemView/TreeItemView Provides an example of how to instantiate and configure a TreeItemView widget in Flutter. This example showcases setting optional leading and trailing widgets, enabling expansion, and defining callback functions for press, double-press, and expansion events. It demonstrates a practical use case for creating interactive tree list items. ```dart TreeItemView( leading: Icon(Icons.folder), trailing: Badge(child: Text('3')), expandable: true, onPressed: () => handleSelection(), onDoublePressed: () => handleOpen(), onExpand: (expanded) => handleExpansion(expanded), child: Text('Project Folder'), ) ``` -------------------------------- ### LinearProgressIndicator Usage Example in Dart Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/LinearProgressIndicator/LinearProgressIndicator An example demonstrating how to use the LinearProgressIndicator widget with specific configurations for value, color, background color, height, and spark effects. ```dart LinearProgressIndicator( value: 0.4, color: Colors.green, backgroundColor: Colors.grey.shade300, minHeight: 8.0, showSparks: true, ); ``` -------------------------------- ### Example Usage of Drawer Swiper Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/DrawerSwiperHandler-class Demonstrates how to integrate the DrawerSwiperHandler into a Flutter application to create a drawer-style swiper. This example shows the basic setup using the Swiper widget with the drawer handler, specifying overlay position and content builder. ```dart Swiper( handler: SwiperHandler.drawer, position: OverlayPosition.left, builder: (context) => DrawerContent(), child: MenuButton(), ) ``` -------------------------------- ### ShadcnApp.router Constructor Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/ShadcnApp/ShadcnApp Documentation for the ShadcnApp.router constructor, used for initializing a Flutter application with custom routing configurations. ```APIDOC ## ShadcnApp.router Constructor ### Description This constructor is used to create a `ShadcnApp` instance with a router-based navigation setup. It allows for extensive customization of routing, theme, locale, and other application-level settings. ### Method Constructor ### Endpoint N/A (Dart Constructor) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ```dart const ShadcnApp.router({ Key? key, RouteInformationProvider? routeInformationProvider, RouteInformationParser? routeInformationParser, RouterDelegate? routerDelegate, RouterConfig? routerConfig, BackButtonDispatcher? backButtonDispatcher, TransitionBuilder? builder, String title = '', GenerateAppTitle? onGenerateTitle, NotificationListenerCallback? onNavigationNotification, Color? color, Color? background, required ThemeData theme, Locale? locale, Iterable? localizationsDelegates, LocaleListResolutionCallback? localeListResolutionCallback, LocaleResolutionCallback? localeResolutionCallback, Iterable supportedLocales = const [Locale('en', 'US')], bool debugShowMaterialGrid = false, bool showPerformanceOverlay = false, bool showSemanticsDebugger = false, bool debugShowCheckedModeBanner = true, Map? shortcuts, Map>? actions, String? restorationScopeId, ScrollBehavior? scrollBehavior, ThemeData? materialTheme, CupertinoThemeData? cupertinoTheme, AdaptiveScaling? scaling, bool disableBrowserContextMenu = true, List initialRecentColors = const [], int maxRecentColors = 50, ValueChanged>? onRecentColorsChanged, bool pixelSnap = true, bool enableScrollInterception = false, ThemeData? darkTheme, ThemeMode themeMode = ThemeMode.system, OverlayHandler? popoverHandler, OverlayHandler? tooltipHandler, OverlayHandler? menuHandler, bool enableThemeAnimation = true, }) ``` ### Response N/A (Constructor) ``` -------------------------------- ### Flutter Widget Build Method Example Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/Basic/build Demonstrates the basic structure of a Flutter `build` method within a widget. This method is responsible for describing the part of the user interface represented by this widget and is called by the framework when the widget is inserted into the tree or when its dependencies change. ```dart class MyWidget extends StatelessWidget { // ... constructor and other methods ... @override Widget build(BuildContext context) { // Return a widget that describes this widget's UI. return Container( child: Text('Hello, World!') ); } } ``` -------------------------------- ### Example Usage of ProgressTheme - Dart Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/ProgressTheme/ProgressTheme Provides an example of how to instantiate a ProgressTheme with specific color, background color, border radius, and minimum height values. This allows for fine-grained control over the progress indicator's visual style. ```dart const ProgressTheme( color: Colors.blue, backgroundColor: Colors.grey, borderRadius: BorderRadius.circular(4.0), minHeight: 6.0, ); ``` -------------------------------- ### Flutter Build Method Implementation Example Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/ActiveDotItem/build This code snippet demonstrates the implementation of a Flutter build method for a custom widget. It utilizes Theme, ComponentTheme, and styleValue to dynamically configure the widget's appearance based on context and provided properties. Dependencies include Flutter's material and widgets libraries. ```dart @override Widget build(BuildContext context) { final theme = Theme.of(context); final compTheme = ComponentTheme.maybeOf(context); final scaling = theme.scaling; final size = styleValue( widgetValue: this.size, themeValue: compTheme?.size, defaultValue: 12 * scaling); final color = styleValue( widgetValue: this.color, themeValue: compTheme?.activeColor, defaultValue: theme.colorScheme.primary); final borderRadius = styleValue( widgetValue: this.borderRadius, themeValue: compTheme?.borderRadius, defaultValue: theme.radiusMd); final borderColor = this.borderColor; final borderWidth = this.borderWidth; return Container( width: size, height: size, decoration: BoxDecoration( color: color, borderRadius: BorderRadius.circular(borderRadius), border: borderColor != null && borderWidth != null ? Border.all(color: borderColor, width: borderWidth) : null, ), ); } ``` -------------------------------- ### Get Character Range - Dart Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/Characters/getRange The getRange method in Dart's Characters class selects a range of characters from a string. It takes a non-negative start index and an optional end index. If end is omitted, it skips characters from the start. Edge cases like start index exceeding length or end index exceeding length are handled. ```dart Characters getRange(int start, [int? end]); ``` ```dart (end != null ? characters.take(end) : characters).skip(start) ``` -------------------------------- ### ControlledSelect Usage Example Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/ControlledSelect/ControlledSelect Demonstrates how to use the ControlledSelect widget in a Flutter application. This example shows initializing the widget with a generic type of String, providing a controller, and defining the popup and itemBuilder. ```dart ControlledSelect( controller: controller, popup: (context, items) => ListView(children: items), itemBuilder: (context, item, selected) => Text(item), placeholder: Text('Select option'), ) ``` -------------------------------- ### ControlledMultiSelect Usage Example Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/ControlledMultiSelect/ControlledMultiSelect Demonstrates how to use the ControlledMultiSelect widget with String data. This example shows the setup of the controller, the popup builder using a ListView, and the itemBuilder for individual items using CheckboxListTile. It also includes a multiItemBuilder to display selected items as Chips. ```dart ControlledMultiSelect( controller: controller, popup: (context, items) => ListView(children: items), itemBuilder: (context, item, selected) => CheckboxListTile( value: selected, title: Text(item), ), multiItemBuilder: (context, items) => Wrap( children: items.map((item) => Chip(label: Text(item))).toList(), ), ) ``` -------------------------------- ### Flutter Build Method Implementation Example Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/OTPSeparator/build This code snippet demonstrates a typical implementation of the build method for a Flutter widget. It accesses the current theme to apply padding and styling to a Text widget. This method is intended to be pure and should not contain side effects. ```dart @override Widget build(BuildContext context) { final theme = Theme.of(context); return const Text('-') .bold() .withPadding(horizontal: theme.scaling * 4) .base() .foreground(); } ``` -------------------------------- ### Example Usage of NavigationMenuContentList in Dart Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/NavigationMenuContentList/NavigationMenuContentList Demonstrates how to instantiate the NavigationMenuContentList widget in Dart. This example shows setting custom values for crossAxisCount and spacing, passing a list of menu items as children. It serves as a practical guide for implementing the widget in a Flutter application. ```dart NavigationMenuContentList( crossAxisCount: 2, spacing: 20.0, children: menuItems, ) ``` -------------------------------- ### Steps Widget Usage Example (Dart) Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/Steps/Steps Demonstrates how to use the Steps widget by providing a list of Text widgets as children. This illustrates creating a simple step-by-step interface. ```dart Steps( children: [ Text('First step content'), Text('Second step content'), Text('Third step content'), ], ) ``` -------------------------------- ### CodeSnippetTheme Example Usage - Dart Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/CodeSnippetTheme/CodeSnippetTheme An example demonstrating how to create a CodeSnippetTheme widget with specific styling for background color, border radius, and padding. This showcases the practical application of the constructor's optional parameters. ```dart CodeSnippetTheme( backgroundColor: Colors.black87, borderRadius: BorderRadius.circular(12.0), padding: EdgeInsets.all(20.0), ); ``` -------------------------------- ### AccordionTrigger Widget Example - Dart Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/AccordionTrigger-class Demonstrates how to use the AccordionTrigger widget within a Flutter application. This example shows a typical setup for an accordion header, including an icon, spacing, and a title with a subtitle. It requires the Flutter SDK and the necessary Accordion component. ```dart AccordionTrigger( child: Row( children: [ Icon(Icons.info_outline), SizedBox(width: 12), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text('Primary Title', style: TextStyle(fontWeight: FontWeight.bold)), Text('Subtitle', style: TextStyle(fontSize: 12)), ], ), ), ], ), ); ``` -------------------------------- ### Sortable Widget Example - Dart Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/Sortable/Sortable An example demonstrating how to use the Sortable widget to create a draggable list item. It shows the basic setup with data, accept callbacks for top and bottom, a custom placeholder, and the child widget. This illustrates a common use case for reordering list elements. ```dart Sortable( data: SortableData('item_1'), onAcceptTop: (data) => moveAbove(data.data), onAcceptBottom: (data) => moveBelow(data.data), placeholder: Container(height: 2, color: Colors.blue), child: ListTile(title: Text('Draggable Item')), ) ``` -------------------------------- ### Flutter initState Initialization Example Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/RecentColorsScopeState/initState This snippet demonstrates the typical implementation of the initState method in a Flutter State object. It shows calling the superclass's initState and then performing custom initialization logic, such as setting up a StateNotifier. ```dart @override void initState() { super.initState(); _recentColors = _ColorListNotifier(List.from(widget.initialRecentColors)); } ``` -------------------------------- ### Get Word At Caret Function in Dart Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/getWordAtCaret The `getWordAtCaret` function takes a text string, a caret position, and an optional separator character. It returns the word at the caret and its starting index. Error handling is included for invalid caret positions. Dependencies: None (built-in Dart string manipulation). ```dart WordInfo getWordAtCaret(String text, int caret, [String separator = ' ']) { if (caret < 0 || caret > text.length) { throw RangeError('Caret position is out of bounds.'); } // Find the start of the word int start = caret; while (start > 0 && !separator.contains(text[start - 1])) { start--; } // Find the end of the word int end = caret; while (end < text.length && !separator.contains(text[end])) { end++; } // Return the start index and the word at the caret position String word = text.substring(start, end); return (start, word); } ``` -------------------------------- ### Flutter Build Method Implementation Example Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/ScaffoldState/build This code snippet demonstrates a typical implementation of the `build` method within a Flutter `State` object. It returns an `Overlay` widget with an `OverlayEntry` that uses another method (`_buildContent`) to define the UI content. ```dart @override Widget build(BuildContext context) { return Overlay( initialEntries: [ OverlayEntry( builder: _buildContent, ), ], ); } ``` -------------------------------- ### Constructors Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/AbstractButtonStyle-class Details on how to create an instance of AbstractButtonStyle. ```APIDOC ## Constructors ### AbstractButtonStyle.new() Creates a new instance of the `AbstractButtonStyle` class. ``` -------------------------------- ### ControlledToggle Example - Flutter Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/ControlledToggle-class Demonstrates how to use the ControlledToggle widget with a ToggleController for external state management. This setup is useful for forms requiring managed toggle states. ```dart final controller = ToggleController(false); ControlledToggle( controller: controller, child: Row( children: [ Icon(Icons.notifications), Text('Enable notifications'), ], ), ); ``` -------------------------------- ### asMap Method Example - Dart Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/ListNotifier/asMap Demonstrates how to use the asMap method to get a Map view of a list. The keys of the map are the indices of the list elements, and the values are the elements themselves. ```dart var words = ['fee', 'fi', 'fo', 'fum']; var map = words.asMap(); // {0: fee, 1: fi, 2: fo, 3: fum} map.keys.toList(); // [0, 1, 2, 3] ``` -------------------------------- ### ShadcnSkeletonizerConfigLayer Usage Example Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/ShadcnSkeletonizerConfigLayer-class Demonstrates how to use the ShadcnSkeletonizerConfigLayer widget to wrap content with skeleton animation settings, integrating with the theme. ```dart ShadcnSkeletonizerConfigLayer( theme: Theme.of(context), child: YourContentWidget(), ); ``` -------------------------------- ### ResizableTableController Get Column Width Example Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/ResizableTableController-class This snippet shows how to retrieve the current width of a specific column using the `getColumnWidth` method. It takes the column index and returns its current width. ```dart final width = controller.getColumnWidth(0); print('Width of column 0: $width'); ``` -------------------------------- ### Avatar Widget Initialization Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/Avatar-class This example demonstrates how to create an Avatar widget with initials, size, background color, and an optional badge. It showcases the basic setup for displaying a user's avatar. ```dart Avatar( initials: 'JD', size: 48, backgroundColor: Colors.blue.shade100, badge: AvatarBadge( color: Colors.green, size: 12, ), ); ``` -------------------------------- ### Command Palette Example - Dart Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/Command/Command An example demonstrating how to use the Command widget to create a command palette. It configures autofocus, debounce duration, search placeholder, and provides a builder function to filter and display commands based on user input. ```dart Command( autofocus: false, debounceDuration: Duration(milliseconds: 200), searchPlaceholder: Text('Search commands...'), builder: (context, query) async* { final filtered = commands.where((cmd) => cmd.name.toLowerCase().contains(query?.toLowerCase() ?? '') ); yield filtered.map((cmd) => CommandItem( child: Text(cmd.name), onSelected: () => cmd.execute(), )).toList(); }, ) ``` -------------------------------- ### ResizableTableController Get Row Height Example Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/ResizableTableController-class Demonstrates retrieving the current height of a specific row using the `getRowHeight` method. It requires the row index and returns the row's current height. ```dart final height = controller.getRowHeight(0); print('Height of row 0: $height'); ``` -------------------------------- ### SelectTheme Constructor Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/SelectTheme/SelectTheme Details about the SelectTheme constructor, including its parameters and how to implement it. ```APIDOC ## SelectTheme Constructor ### Description Provides details on the SelectTheme constructor, including its optional parameters for customizing popup constraints, alignment, border radius, padding, hover effects, and selection behavior. ### Method Constructor ### Endpoint N/A (Dart Class Constructor) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```dart const SelectTheme({ this.popupConstraints, this.popoverAlignment, this.popoverAnchorAlignment, this.borderRadius, this.padding, this.disableHoverEffect, this.canUnselect, this.autoClosePopover, }); ``` ### Response #### Success Response (N/A) This is a constructor, not an API endpoint. No direct success response. #### Response Example N/A ``` -------------------------------- ### Get Range of List Elements (Dart) Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/ListNotifier-class Creates a new iterable that contains elements from a specific range [start, end) of the list. This provides a view into a sub-section of the list without copying elements. ```dart Iterable getRange(int start, int end) { // Implementation to get a range of elements } ``` -------------------------------- ### InstantTooltip Implementation - Dart Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/InstantTooltip/InstantTooltip Provides the actual implementation of the InstantTooltip constructor in Dart. This code initializes the widget's properties based on the provided arguments, ensuring the tooltip functions as expected with the given child, builder, and alignment settings. ```dart const InstantTooltip({ super.key, required this.child, required this.tooltipBuilder, this.behavior = HitTestBehavior.translucent, this.tooltipAlignment = Alignment.bottomCenter, this.tooltipAnchorAlignment, }); ``` -------------------------------- ### Flutter initState Method Implementation Example Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/DrawerEntryWidgetState/initState This code snippet demonstrates a typical implementation of the initState method in a Flutter State object. It initializes an AnimationController and a ControlledAnimation, handles auto-opening animations, and unfocuses the primary focus node. Dependencies include Flutter's animation and widgets libraries. ```dart @override void initState() { super.initState(); _controller = widget.animationController ?? AnimationController( vsync: this, duration: const Duration(milliseconds: 350)); _controlledAnimation = ControlledAnimation(_controller); if (widget.animationController == null && widget.autoOpen) { _controlledAnimation.forward(1, Curves.easeOut); } // discard any focus that was previously set FocusManager.instance.primaryFocus?.unfocus(); } ``` -------------------------------- ### Dart getRange Method Example Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/ListNotifier/getRange Demonstrates how to use the `getRange` method to extract a sub-range of elements from a list. It shows creating an iterable for a specific start and end index and printing the joined elements. ```dart final colors = ['red', 'green', 'blue', 'orange', 'pink']; final firstRange = colors.getRange(0, 3); print(firstRange.join(', ')); // red, green, blue final secondRange = colors.getRange(2, 5); print(secondRange.join(', ')); // blue, orange, pink ``` -------------------------------- ### Get Rect Animation Begin Value (Dart) Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/ShadcnRectArcTween/begin Retrieves the initial value of a Rect animation. This value represents the state of the animation at its start. It might be null depending on the specific animation subclass. ```dart T? begin; @override Rect? get begin ``` -------------------------------- ### ColorScheme Constructors Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/ColorScheme-class Provides details on how to create new instances of the ColorScheme class. ```APIDOC ## ColorScheme Constructors ### `ColorScheme.new()` Creates a new ColorScheme with specified colors and brightness. **Parameters:** - `brightness` (Brightness) - Required - The overall brightness theme. - `background` (Color) - Required - The background color. - `foreground` (Color) - Required - The foreground color. - `card` (Color) - Required - The card background color. - `cardForeground` (Color) - Required - The card foreground color. - `popover` (Color) - Required - The popover background color. - `popoverForeground` (Color) - Required - The popover foreground color. - `primary` (Color) - Required - The primary color. - `primaryForeground` (Color) - Required - The primary foreground color. - `secondary` (Color) - Required - The secondary color. - `secondaryForeground` (Color) - Required - The secondary foreground color. - `muted` (Color) - Required - The muted color. - `mutedForeground` (Color) - Required - The muted foreground color. - `accent` (Color) - Required - The accent color. - `accentForeground` (Color) - Required - The accent foreground color. - `destructive` (Color) - Required - The destructive action color. - `destructiveForeground` (Color) - Optional (Defaults to transparent) - The destructive action foreground color. - `border` (Color) - Required - The border color. - `input` (Color) - Required - The input field background color. - `ring` (Color) - Required - The ring color. - `chart1` to `chart5` (Color) - Required - Colors for chart elements. - `sidebar` (Color) - Required - The sidebar background color. - `sidebarForeground` (Color) - Required - The sidebar foreground color. - `sidebarPrimary` (Color) - Required - The sidebar primary accent color. - `sidebarPrimaryForeground` (Color) - Required - The sidebar primary accent foreground color. - `sidebarAccent` (Color) - Required - The sidebar secondary accent color. - `sidebarAccentForeground` (Color) - Required - The sidebar secondary accent foreground color. - `sidebarBorder` (Color) - Required - The sidebar border color. - `sidebarRing` (Color) - Required - The sidebar ring color. ### `ColorScheme.fromColors()` Creates a ColorScheme from a map of named colors and a brightness. **Parameters:** - `colors` (Map) - Required - A map where keys are color names and values are Color objects. - `brightness` (Brightness) - Required - The overall brightness theme. ### `ColorScheme.fromMap()` Creates a ColorScheme from a map of dynamic values. **Parameters:** - `map` (Map) - Required - The map containing color scheme data. ``` -------------------------------- ### List `last` Property Usage Example (Dart) Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/ListNotifier/last Demonstrates how to get and set the last element of a Dart list, including handling the case where the list becomes empty and attempting to access `last`. ```dart final numbers = [1, 2, 3]; print(numbers.last); // 3 numbers.last = 10; print(numbers.last); // 10 numbers.clear(); // numbers.last; // Throws. ``` -------------------------------- ### Progress Constructor Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/Progress/Progress Documentation for the `Progress` constructor, detailing its parameters and behavior. ```APIDOC ## Progress Constructor ### Description Creates a Progress indicator widget. The progress value must be between `min` and `max` when provided. If progress is null, the indicator shows indeterminate animation. ### Method Constructor ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **key** (Key?, optional) - Widget key - **progress** (double?, optional) - Current progress value or null for indeterminate - **min** (double, default: 0.0) - Minimum progress value - **max** (double, default: 1.0) - Maximum progress value - **disableAnimation** (bool, default: false) - Whether to disable smooth transitions - **color** (Color?, optional) - Progress fill color override - **backgroundColor** (Color?, optional) - Progress track color override ### Request Example ```dart Progress( progress: 75, min: 0, max: 100, color: Colors.green, ); ``` ### Response #### Success Response (200) N/A (This is a widget constructor) #### Response Example N/A ``` -------------------------------- ### List.setAll Method Usage Example Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/ListNotifier/setAll Demonstrates how to use the setAll method to overwrite elements in a list starting from a specific index. This method modifies the list in place and requires valid index and iterable inputs. ```dart final list = ['a', 'b', 'c', 'd']; list.setAll(1, ['bee', 'sea']); print(list); // [a, bee, sea, d] ``` -------------------------------- ### Instantiate ShadcnUI Widget Source: https://pub.dev/documentation/shadcn_flutter/latest/shadcn_flutter/ShadcnUI-class Demonstrates the constructor for the ShadcnUI widget. It requires a key for widget identification and a child widget to be wrapped. An optional TextStyle can be provided to customize text appearance. ```dart ShadcnUI.new({ Key? key, TextStyle? textStyle, required Widget child, }) ```