### Global Configuration Example Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/api-reference/responsive_sizing_config.md Example of how to set global breakpoints once at application startup. ```APIDOC ## Usage Example: Global Configuration ```dart import 'package:responsive_builder/responsive_builder.dart'; void main() { // Configure once at app startup ResponsiveSizingConfig.instance.setCustomBreakpoints( ScreenBreakpoints( desktop: 1280, tablet: 768, watch: 320, ), ); runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return ResponsiveApp( builder: (context) => MaterialApp( home: HomePage(), ), ); } } class HomePage extends StatelessWidget { @override Widget build(BuildContext context) { // Uses global breakpoints configured in main() return ScreenTypeLayout.builder( mobile: (context) => MobileView(), desktop: (context) => DesktopView(), ); } } ``` ``` -------------------------------- ### Responsive Padding Example Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/api-reference/sizing_information.md An example showing how to dynamically adjust padding based on the device type using SizingInformation. ```APIDOC ### Usage Example for Responsive Padding ```dart ResponsiveBuilder( builder: (context, sizingInfo) { double padding; if (sizingInfo.isDesktop) { padding = 60; } else if (sizingInfo.isTablet) { padding = 30; } else { padding = 10; } return Padding( padding: EdgeInsets.all(padding), child: MyContent(), ); }, ) ``` ``` -------------------------------- ### Responsive Pattern Example Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/INDEX.md Illustrates how device type, orientation, and refined size can be combined to create highly responsive layouts. No specific setup is required beyond understanding the concepts. ```plaintext Mobile - Portrait - Small → Compact mobile layout Mobile - Landscape - Large → Landscape phone layout Desktop - Portrait - ExtraLarge → Ultra-wide desktop layout ``` -------------------------------- ### ResponsiveBuilder Usage Example Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/api-reference/sizing_information.md Demonstrates how to use the ResponsiveBuilder widget and the SizingInformation object to create responsive layouts based on device type and size. ```APIDOC ### Usage Example ```dart ResponsiveBuilder( builder: (context, sizingInfo) { // Check device type using convenience getters if (sizingInfo.isMobile) { return MobileLayout(); } if (sizingInfo.isTablet && sizingInfo.isLarge) { return TabletLargeLayout(); } if (sizingInfo.isDesktop && sizingInfo.isExtraLarge) { return DesktopUltraWideLayout(); } // Access raw values print('Screen size: ${sizingInfo.screenSize}'); print('Available width: ${sizingInfo.localWidgetSize.width}'); return DefaultLayout(); }, ) ``` ``` -------------------------------- ### ResponsiveBuilder Usage Example Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/api-reference/responsive_builder.md Demonstrates how to use the ResponsiveBuilder widget to conditionally render UI based on device type. ```APIDOC ## ResponsiveBuilder Usage Example ### Description This example shows how to use `ResponsiveBuilder` to display different UI elements for mobile, tablet, and desktop screen sizes. ### Code ```dart ResponsiveBuilder( builder: (context, sizingInfo) { if (sizingInfo.isMobile) { return Container(color: Colors.blue, child: Text('Mobile Layout')); } if (sizingInfo.isTablet) { return Container(color: Colors.green, child: Text('Tablet Layout')); } return Container(color: Colors.red, child: Text('Desktop Layout')); }, ) ``` ``` -------------------------------- ### Responsive App Setup Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/GETTING-STARTED.md Use ResponsiveApp to wrap your MaterialApp for responsive building. This is the entry point for responsive layouts. ```dart ResponsiveApp( builder: (context) => MaterialApp( home: ScreenTypeLayout.builder( mobile: (context) => MobileHomePage(), desktop: (context) => DesktopHomePage(), ), ), ) ``` -------------------------------- ### Usage Example: Set Global Breakpoints Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/api-reference/responsive_sizing_config.md Configure global breakpoints once at app startup. This example demonstrates setting custom screen type breakpoints. ```dart void main() { // Set global breakpoints before running the app ResponsiveSizingConfig.instance.setCustomBreakpoints( ScreenBreakpoints(desktop: 1200, tablet: 700, watch: 280), ); // Also set refined breakpoints ResponsiveSizingConfig.instance.setCustomBreakpoints( ScreenBreakpoints(desktop: 1200, tablet: 700, watch: 280), customRefinedBreakpoints: RefinedBreakpoints( desktopSmall: 1200, desktopNormal: 1920, desktopLarge: 2560, desktopExtraLarge: 3840, ), ); runApp(MyApp()); } ``` -------------------------------- ### ResponsiveBuilder Usage Example Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/api-reference/sizing_information.md Example of using ResponsiveBuilder to conditionally render UI based on device type and size. Accesses convenience getters and raw data properties of SizingInformation. ```dart ResponsiveBuilder( builder: (context, sizingInfo) { // Check device type using convenience getters if (sizingInfo.isMobile) { return MobileLayout(); } if (sizingInfo.isTablet && sizingInfo.isLarge) { return TabletLargeLayout(); } if (sizingInfo.isDesktop && sizingInfo.isExtraLarge) { return DesktopUltraWideLayout(); } // Access raw values print('Screen size: ${sizingInfo.screenSize}'); print('Available width: ${sizingInfo.localWidgetSize.width}'); return DefaultLayout(); }, ) ``` -------------------------------- ### Responsive Padding Example Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/api-reference/sizing_information.md Demonstrates how to apply responsive padding using SizingInformation within a ResponsiveBuilder. Adjusts padding based on device type. ```dart ResponsiveBuilder( builder: (context, sizingInfo) { double padding; if (sizingInfo.isDesktop) { padding = 60; } else if (sizingInfo.isTablet) { padding = 30; } else { padding = 10; } return Padding( padding: EdgeInsets.all(padding), child: MyContent(), ); }, ) ``` -------------------------------- ### Usage Example: Global Configuration Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/api-reference/responsive_sizing_config.md Configure responsive breakpoints globally at app startup. Widgets will automatically use these global settings unless overridden. ```dart import 'package:responsive_builder/responsive_builder.dart'; void main() { // Configure once at app startup ResponsiveSizingConfig.instance.setCustomBreakpoints( ScreenBreakpoints( desktop: 1280, tablet: 768, watch: 320, ), ); runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return ResponsiveApp( builder: (context) => MaterialApp( home: HomePage(), ), ); } } class HomePage extends StatelessWidget { @override Widget build(BuildContext context) { // Uses global breakpoints configured in main() return ScreenTypeLayout.builder( mobile: (context) => MobileView(), desktop: (context) => DesktopView(), ); } } ``` -------------------------------- ### Basic ResponsiveApp Usage Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/api-reference/responsive_app.md Example of how to integrate ResponsiveApp into your application's main function. It wraps the MaterialApp with the ResponsiveApp builder. ```dart void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return ResponsiveApp( builder: (context) => MaterialApp( title: 'My App', home: HomePage(), ), ); } } ``` -------------------------------- ### Run flutter pub get Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/GETTING-STARTED.md Command to execute after updating the pubspec.yaml file to fetch the new dependency. ```bash flutter pub get ``` -------------------------------- ### ScreenTypeLayout Usage Example Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/api-reference/screen_type_layout.md Demonstrates the preferred way to use ScreenTypeLayout.builder with distinct widgets for mobile, tablet, and desktop layouts. ```dart ScreenTypeLayout.builder( mobile: (context) => Container( color: Colors.blue, child: Text('Mobile Layout'), ), tablet: (context) => Container( color: Colors.green, child: Text('Tablet Layout'), ), desktop: (context) => Container( color: Colors.red, child: Text('Desktop Layout'), ), ) ``` -------------------------------- ### Responsive Sizing Usage Examples Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/api-reference/responsive_app.md Illustrates various ways to use the responsive sizing extensions (screenHeight, screenWidth, sh, sw) to size widgets and text. ```dart // Set widget height to 20% of screen height SizedBox(height: 20.screenHeight) // Set widget height using shorthand SizedBox(height: 20.sh) // Set font size to 5% of screen width Text( 'Responsive Text', style: TextStyle(fontSize: 5.sw), ) // Combine with other widgets Container( padding: EdgeInsets.all(10.sw), width: 80.screenWidth, height: 50.screenHeight, child: Text('Responsive Container'), ) ``` -------------------------------- ### App Setup with Custom Breakpoints Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/quick-reference.md Configure custom screen breakpoints for your application and initialize the responsive app structure. This should be done at the entry point of your application. ```dart void main() { ResponsiveSizingConfig.instance.setCustomBreakpoints( ScreenBreakpoints(desktop: 1200, tablet: 700, watch: 300), ); runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return ResponsiveApp( builder: (context) => MaterialApp(home: HomePage()), ); } } ``` -------------------------------- ### Usage Example: Fine-Grained Control Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/api-reference/refined_layout_builder.md Demonstrates how to use RefinedLayoutBuilder to provide distinct layouts for small, normal, large, and extraLarge screen sizes. ```dart RefinedLayoutBuilder( small: (context) => SingleChildScrollView( child: Column(children: [/* Mobile-like layout */]), ), normal: (context) => Column(children: [/* Standard layout */]), large: (context) => Row(children: [/* 2-column layout */]), extraLarge: (context) => Row( children: [ Expanded(child: Column()), Expanded(child: Column()), Expanded(child: Column()), ], ), ) ``` -------------------------------- ### Get Device Type with Custom Breakpoints Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/api-reference/helper_functions.md This example shows how to use `getDeviceType` with custom screen breakpoints. This allows for more granular control over device classification. ```dart Size screenSize = MediaQuery.of(context).size; DeviceScreenType deviceType = getDeviceType( screenSize, ScreenBreakpoints( desktop: 1200, tablet: 700, watch: 280, ), ); ``` -------------------------------- ### Responsive Sizing Extensions Examples Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/configuration.md Use these extensions on numbers to calculate percentages of screen height or width. Ensure ResponsiveApp is wrapped around your application to enable these extensions. ```dart 20.screenHeight // 20% of screen height 30.sw // 30% of screen width 50.sh // 50% of screen height ``` -------------------------------- ### Wrap Root Widget with ResponsiveApp Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/GETTING-STARTED.md Ensure your application is wrapped with ResponsiveApp at the root level to enable responsive features. This is a mandatory setup step. ```dart ResponsiveApp( builder: (context) => MaterialApp(...), ) ``` -------------------------------- ### OrientationLayoutBuilder Usage Example Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/types.md Demonstrates how to use OrientationLayoutBuilder to enforce a specific orientation for the UI. This example forces a portrait layout. ```dart OrientationLayoutBuilder( mode: OrientationLayoutBuilderMode.portrait, portrait: (context) => MyPortraitView(), ) ``` -------------------------------- ### ResponsiveBuilder Usage Example Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/api-reference/responsive_builder.md Demonstrates how to use the ResponsiveBuilder widget to conditionally render different UI elements based on device type (mobile, tablet, desktop). ```dart ResponsiveBuilder( builder: (context, sizingInfo) { if (sizingInfo.isMobile) { return Container(color: Colors.blue, child: Text('Mobile Layout')); } if (sizingInfo.isTablet) { return Container(color: Colors.green, child: Text('Tablet Layout')); } return Container(color: Colors.red, child: Text('Desktop Layout')); }, ) ``` -------------------------------- ### Wrap App with ResponsiveApp Source: https://github.com/filledstacks/responsive_builder/blob/master/README.md To enable responsive sizing functionality, wrap your Material or Cupertino App with the ResponsiveApp widget. This is a mandatory setup step. ```dart ResponsiveApp( builder: (context) => MaterialApp( ... ) ) ``` -------------------------------- ### Set Global Breakpoints Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/configuration.md Set global breakpoints for screen sizes before your application starts by configuring the ResponsiveSizingConfig singleton. ```dart void main() { ResponsiveSizingConfig.instance.setCustomBreakpoints( ScreenBreakpoints(desktop: 1200, tablet: 700, watch: 280), ); runApp(MyApp()); } ``` -------------------------------- ### ScreenTypeLayout.builder Example Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/configuration.md Display different layouts for different device screen types using ScreenTypeLayout.builder. This builder is lazy and requires at least one of mobile or desktop widgets to be provided. ```dart ScreenTypeLayout.builder( breakpoints: ScreenBreakpoints(desktop: 1200, tablet: 800, watch: 300), mobile: (context) => MobileView(), tablet: (context) => TabletView(), desktop: (context) => DesktopView(), ) ``` -------------------------------- ### Usage Example: Custom Breakpoints Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/api-reference/refined_layout_builder.md Shows how to customize the breakpoint values for each refined size category across different device types using RefinedBreakpoints. ```dart RefinedLayoutBuilder( refinedBreakpoints: RefinedBreakpoints( mobileSmall: 300, mobileNormal: 400, mobileLarge: 500, mobileExtraLarge: 600, tabletSmall: 650, tabletNormal: 850, tabletLarge: 1000, tabletExtraLarge: 1200, desktopSmall: 1300, desktopNormal: 1920, desktopLarge: 2560, desktopExtraLarge: 4096, ), normal: (context) => DefaultLayout(), large: (context) => LargeLayout(), ) ``` -------------------------------- ### OrientationLayoutBuilder Example Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/configuration.md Use OrientationLayoutBuilder to display different layouts for portrait and landscape orientations. The mode can be set to auto, portrait, or landscape. ```dart OrientationLayoutBuilder( mode: OrientationLayoutBuilderMode.portrait, portrait: (context) => PortraitView(), landscape: (context) => LandscapeView(), ) ``` -------------------------------- ### Usage Example: Override Global for Specific Widget Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/api-reference/responsive_sizing_config.md Demonstrates how a specific widget can override the globally configured breakpoints by providing its own `breakpoints` parameter. ```dart // Global breakpoints are set in main() ResponsiveSizingConfig.instance.setCustomBreakpoints( ScreenBreakpoints(desktop: 1000, tablet: 600, watch: 300), ); // But this widget uses different breakpoints ScreenTypeLayout.builder( breakpoints: ScreenBreakpoints( desktop: 1200, tablet: 800, watch: 250, ), mobile: (context) => MobileView(), desktop: (context) => DesktopView(), ) ``` -------------------------------- ### Set Global Screen Breakpoints in main Source: https://github.com/filledstacks/responsive_builder/blob/master/README.md Configure global screen breakpoints once before the app starts by calling setCustomBreakpoints on ResponsiveSizingConfig.instance. This can be overridden by specific ScreenTypeLayout breakpoints. ```dart void main() { ResponsiveSizingConfig.instance.setCustomBreakpoints( ScreenBreakpoints(desktop: 800, tablet: 550, watch: 200), ); runApp(MyApp()); } ``` -------------------------------- ### ResponsiveBuilder Widget Example Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/configuration.md Use ResponsiveBuilder to control how responsive sizing information is provided to widgets. You can provide custom screen type and refined size breakpoints for this specific widget. ```dart ResponsiveBuilder( breakpoints: ScreenBreakpoints(desktop: 1000, tablet: 600, watch: 300), refinedBreakpoints: RefinedBreakpoints(desktopNormal: 1920), builder: (context, sizingInfo) => MyLayout(), ) ``` -------------------------------- ### RefinedLayoutBuilder Example Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/configuration.md Display different layouts based on refined screen sizes using RefinedLayoutBuilder. You can define custom refined breakpoints and provide builders for normal, small, large, and extra large sizes. ```dart RefinedLayoutBuilder( refinedBreakpoints: RefinedBreakpoints( desktopSmall: 1000, desktopNormal: 1920, desktopLarge: 2560, ), normal: (context) => NormalLayout(), large: (context) => LargeLayout(), extraLarge: (context) => ExtraLargeLayout(), ) ``` -------------------------------- ### Responsive Spacing with getValueForRefinedSize Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/api-reference/helper_functions.md This example demonstrates how to adjust spacing in a Column widget based on the screen size. It uses getValueForRefinedSize to provide different spacing values for normal, large, and extra-large screen sizes. ```dart Column( spacing: getValueForRefinedSize( context: context, normal: 16, large: 24, extraLarge: 32, ), children: [ Widget1(), Widget2(), ], ) ``` -------------------------------- ### Get Value for Screen Type (Visibility) Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/api-reference/helper_functions.md Conditionally render a widget based on screen type using getValueForScreenType. This example shows how to control visibility for mobile, tablet, and desktop. ```dart getValueForScreenType( context: context, mobile: false, tablet: true, desktop: true, ) ? MyWidget() : SizedBox.shrink() ``` -------------------------------- ### ScrollTransformView Usage Example Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/api-reference/scroll_transform.md This example demonstrates how to use ScrollTransformView with multiple ScrollTransformItem widgets. Each item can define its own builder for content and an optional offsetBuilder for transformations. ```dart ScrollTransformView( children: [ ScrollTransformItem( builder: (scrollOffset) => Container( color: Colors.blue, height: 100, ), ), ScrollTransformItem( builder: (scrollOffset) => Text('Scroll offset: $scrollOffset'), ), ScrollTransformItem( offsetBuilder: (scrollOffset) => Offset(scrollOffset / 10, 0), builder: (scrollOffset) => Container( color: Colors.red, width: 100, height: 100, ), ), ], ) ``` -------------------------------- ### ResponsiveApp with preferDesktop Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/api-reference/responsive_app.md Demonstrates using the preferDesktop flag in ResponsiveApp to prioritize desktop layout when available. ```dart ResponsiveApp( preferDesktop: true, builder: (context) => MaterialApp( home: HomePage(), ), ) ``` -------------------------------- ### ScrollTransformItem Usage Example Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/module-reference.md Example demonstrating how to use ScrollTransformItem with custom scale and offset transformations. The builder creates a basic Container widget that scales and translates with scroll offset. ```dart ScrollTransformItem( scaleBuilder: (offset) => 1.0 + (offset / 1000), offsetBuilder: (offset) => Offset(offset / 20, 0), builder: (offset) => Container(width: 100, height: 100), ) ``` -------------------------------- ### ResponsiveApp Configuration Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/configuration.md Use ResponsiveApp to enable responsive sizing extensions and track screen dimensions. Set preferDesktop to true to default to desktop layout. ```dart ResponsiveApp( preferDesktop: false, builder: (context) => MaterialApp(home: HomePage()), ) ``` -------------------------------- ### Get Breakpoints Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/api-reference/responsive_sizing_config.md Retrieve the currently active breakpoints, either custom or default. ```APIDOC ## Getter: breakpoints Returns the current breakpoints (custom if set, otherwise defaults). ```dart ScreenBreakpoints get breakpoints => _customBreakPoints ?? _defaultBreakPoints; ``` ``` ```APIDOC ## Getter: refinedBreakpoints Returns the current refined breakpoints (custom if set, otherwise defaults). ```dart RefinedBreakpoints get refinedBreakpoints => _customRefinedBreakPoints ?? _defaultRefinedBreakPoints; ``` ``` -------------------------------- ### Override Global for Specific Widget Example Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/api-reference/responsive_sizing_config.md Demonstrates how to override global breakpoints for a specific widget. ```APIDOC ## Usage Example: Override Global for Specific Widget ```dart // Global breakpoints are set in main() ResponsiveSizingConfig.instance.setCustomBreakpoints( ScreenBreakpoints(desktop: 1000, tablet: 600, watch: 300), ); // But this widget uses different breakpoints ScreenTypeLayout.builder( breakpoints: ScreenBreakpoints( desktop: 1200, tablet: 800, watch: 250, ), mobile: (context) => MobileView(), desktop: (context) => DesktopView(), ) ``` ``` -------------------------------- ### Compare Layout Logic: Without vs. With responsive_builder Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/GETTING-STARTED.md Demonstrates the verbose conditional logic typically used without the package versus the clean, declarative approach provided by ScreenTypeLayout.builder. ```dart // ❌ Without responsive_builder - verbose and messy if (MediaQuery.of(context).size.width > 600) { if (MediaQuery.of(context).orientation == Orientation.landscape) { // tablet landscape layout } else { // tablet portrait layout } } else { // mobile layout } ``` ```dart // ✓ With responsive_builder - clean and declarative ScreenTypeLayout.builder( mobile: (context) => MobileView(), tablet: (context) => TabletView(), desktop: (context) => DesktopView(), ) ``` -------------------------------- ### ResponsiveAppUtil Static Properties Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/api-reference/responsive_app.md Internal utility class that manages screen size tracking. It exposes static properties for current screen dimensions and desktop layout preference. ```APIDOC ## ResponsiveAppUtil Class ### Static Properties - **height** (`double`) - Current screen height in logical pixels - **width** (`double`) - Current screen width in logical pixels - **preferDesktop** (`bool`) - Whether to prefer desktop layouts when unspecified ``` -------------------------------- ### Singleton Access Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/api-reference/responsive_sizing_config.md Access the global configuration instance to manage responsive breakpoints. ```APIDOC ## Singleton Access Access the singleton instance via `ResponsiveSizingConfig.instance`. ```dart static ResponsiveSizingConfig get instance { if (_instance == null) { _instance = ResponsiveSizingConfig(); } return _instance!; } ``` ``` -------------------------------- ### Get Device Type Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/quick-reference.md Determine the current device screen type based on media query size. Requires `MediaQuery` context. ```dart DeviceScreenType deviceType = getDeviceType( MediaQuery.of(context).size, ); ``` -------------------------------- ### ResponsiveApp Constructor Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/api-reference/responsive_app.md A StatelessWidget that wraps your app's root widget to enable responsive sizing extensions (`screenWidth`, `screenHeight`, `sw`, `sh`) and provides screen size information to the widget tree. It requires a builder function that returns the app's root widget (e.g., `MaterialApp`). ```APIDOC ## Class: ResponsiveApp ### Constructor ```dart const ResponsiveApp({ Key? key, required Widget Function(BuildContext) builder, bool preferDesktop = false, }) ``` ### Parameters #### Parameters - **builder** (`Widget Function(BuildContext)`) - Required - Function that builds the app widget (typically `MaterialApp` or `CupertinoApp`) - **preferDesktop** (`bool`) - Optional - If true, prefers desktop layout when a layout is not specified in responsive widgets. Defaults to `false`. - **key** (`Key?`) - Optional - Widget key. Defaults to `null`. ``` -------------------------------- ### Responsive Sizing Extension: sw (shorthand) Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/api-reference/responsive_app.md Shorthand for screenWidth, offering a concise method for responsive width calculations. ```dart double get sw => screenWidth; ``` -------------------------------- ### Responsive Builder Package File Structure Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/INDEX.md Overview of the directory structure for the responsive_builder Flutter package. ```plaintext responsive_builder/ ├── lib/ │ ├── responsive_builder.dart (main entry point) │ └── src/ │ ├── device_screen_type.dart (enums) │ ├── sizing_information.dart (data classes) │ ├── responsive_sizing_config.dart (config singleton) │ ├── responsive_wrapper.dart (ResponsiveApp, extensions) │ ├── widget_builders.dart (core widgets) │ ├── helpers/ │ │ ├── helpers.dart (utility functions) │ │ ├── device_width.dart (native platform helper) │ │ └── device_width_web.dart (web platform helper) │ └── scroll/ │ ├── scroll_transform_view.dart │ └── scroll_transform_item.dart └── pubspec.yaml (package configuration) ``` -------------------------------- ### Module: sizing_information Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/module-reference.md Contains responsive layout sizing data and breakpoint configuration. This module provides data structures for passing sizing information to builder functions and configuring device and refined size thresholds. ```APIDOC ## Module: sizing_information `lib/src/sizing_information.dart` Responsive layout sizing data and breakpoint configuration. ### Exports | Symbol | Type | Description | |--------|------|-------------| | `SizingInformation` | Class | Container for sizing data passed to builders | | `ScreenBreakpoints` | Class | Screen type breakpoint configuration | | `RefinedBreakpoints` | Class | Refined size breakpoint configuration | ### Purpose Provides data structures for: - Passing sizing information to builder functions - Configuring device type thresholds - Configuring refined size thresholds within device types ### Key Relationships - `SizingInformation` contains `DeviceScreenType` and `RefinedSize` enums - `ScreenBreakpoints` defines thresholds for `DeviceScreenType` classification - `RefinedBreakpoints` defines thresholds for `RefinedSize` classification ``` -------------------------------- ### ResponsiveSizingConfig Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/module-reference.md Manages global breakpoint configuration for responsive widgets. This is a singleton instance. ```APIDOC ## Class: ResponsiveSizingConfig ### Description Singleton managing global breakpoint configuration. ### Public API #### Static Getter: instance ```dart static ResponsiveSizingConfig get instance ``` #### Method: setCustomBreakpoints ```dart void setCustomBreakpoints(ScreenBreakpoints? customBreakpoints, RefinedBreakpoints? refinedBreakpoints) ``` Sets custom breakpoints for the application. #### Getter: breakpoints ```dart ScreenBreakpoints get breakpoints ``` Returns the current screen breakpoints. #### Getter: refinedBreakpoints ```dart RefinedBreakpoints get refinedBreakpoints ``` Returns the current refined breakpoints. ``` -------------------------------- ### Check Device Screen Type Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/types.md Example of how to check the current device screen type using the DeviceScreenType enum. This is commonly used for conditional layout adjustments. ```dart if (sizingInfo.deviceScreenType == DeviceScreenType.mobile) { // Handle mobile layout } ``` -------------------------------- ### ResponsiveApp Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/configuration.md Enables responsive sizing extensions and tracks screen dimensions. It takes a builder function to construct the app widget and an optional boolean to prefer desktop layout. ```APIDOC ## ResponsiveApp ### Description Enables responsive sizing extensions and tracks screen dimensions. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **builder** (Widget Function(BuildContext)) - Required - Function that builds the app widget - **preferDesktop** (bool) - Optional - Prefer desktop layout when not specified ### Request Example ```dart ResponsiveApp( preferDesktop: false, builder: (context) => MaterialApp(home: HomePage()), ) ``` ### Response Success Response (200) None explicitly defined, widget renders the app. ### Response Example None ``` -------------------------------- ### Responsive Sizing Extension: sh (shorthand) Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/api-reference/responsive_app.md Shorthand for screenHeight, providing a more concise way to calculate responsive heights. ```dart double get sh => screenHeight; ``` -------------------------------- ### Get Refined Size Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/quick-reference.md Determine the refined size category (e.g., small, normal, large) based on media query size. Requires `MediaQuery` context. ```dart RefinedSize refinedSize = getRefinedSize( MediaQuery.of(context).size, ); ``` -------------------------------- ### Main Entry Point Exports Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/module-reference.md This is the primary import for all public APIs in the responsive_builder library. It re-exports all public types and functions from internal modules. ```dart library responsive_builder; export 'src/device_screen_type.dart'; export 'src/helpers/helpers.dart'; export 'src/responsive_sizing_config.dart'; export 'src/responsive_wrapper.dart'; export 'src/scroll/scroll_transform_item.dart'; export 'src/scroll/scroll_transform_view.dart'; export 'src/sizing_information.dart'; export 'src/widget_builders.dart'; ``` -------------------------------- ### Add Device Preview Package Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/GETTING-STARTED.md Include the `device_preview` package in your `dev_dependencies` to enable testing on various virtual devices within your Flutter project. ```yaml dev_dependencies: device_preview: ^1.0.0 ``` -------------------------------- ### Responsive Sizing Extensions Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/quick-reference.md Use percentage-based sizing for height and width after wrapping the app with `ResponsiveApp`. Shorthands `sh` for `screenHeight` and `sw` for `screenWidth` are available. ```dart SizedBox(height: 20.screenHeight) // 20% of screen height SizedBox(height: 20.sh) // Shorthand SizedBox(width: 30.screenWidth) // 30% of screen width SizedBox(width: 30.sw) // Shorthand Text( 'Text', style: TextStyle(fontSize: 5.sw), // 5% of screen width ) ``` -------------------------------- ### Usage Example: Nested with Screen Type Layout Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/api-reference/refined_layout_builder.md Illustrates nesting RefinedLayoutBuilder within ScreenTypeLayout to manage layouts for different device types and their respective refined sizes. ```dart ScreenTypeLayout.builder( mobile: (context) => RefinedLayoutBuilder( normal: (context) => MobileNormalLayout(), large: (context) => MobileLargeLayout(), ), desktop: (context) => RefinedLayoutBuilder( normal: (context) => DesktopNormalLayout(), large: (context) => DesktopLargeLayout(), extraLarge: (context) => DesktopExtraLargeLayout(), ), ) ``` -------------------------------- ### Widgets Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/module-reference.md Core widgets for building responsive layouts and enabling responsive features. ```APIDOC ## Widget: ResponsiveApp ### Description Enables responsive sizing features within the application. ## Widget: ResponsiveBuilder ### Description The base widget for creating responsive UI components. ## Widget: ScreenTypeLayout ### Description A widget that switches layouts based on the detected device type. ## Widget: OrientationLayoutBuilder ### Description A widget that builds layouts based on screen orientation. ## Widget: RefinedLayoutBuilder ### Description A widget that builds layouts based on refined size categories. ## Widget: ScrollTransformView ### Description A scrollable container with transform capabilities. ## Widget: ScrollTransformItem ### Description An item within a ScrollTransformView that is aware of scroll transformations. ``` -------------------------------- ### ResponsiveApp Widget Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/INDEX.md A root wrapper widget that enables responsive sizing extensions and configurations throughout your application. ```APIDOC ## ResponsiveApp Widget ### Description The `ResponsiveApp` widget should be placed at the root of your Flutter application. It sets up the necessary providers and configurations for the responsive_builder package to function correctly, including enabling responsive extensions on `BuildContext`. ### Usage ```dart ResponsiveApp( builder: (context) => MaterialApp( // ... your app configuration ), ) ``` ### Parameters - **`builder`** (ResponsiveAppBuilder) - Required. A builder function that returns the root widget of your application (e.g., `MaterialApp`, `CupertinoApp`). - **`defaultBreakpoints`** (ScreenBreakpoints, optional) - Default breakpoints to use if not provided elsewhere. - **`defaultRefinedBreakpoints`** (RefinedBreakpoints, optional) - Default refined breakpoints to use. ``` -------------------------------- ### Get Refined Size with Custom Breakpoints Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/api-reference/helper_functions.md Classifies the device into a refined size category using custom breakpoint values. This allows for more granular control over size classification. ```dart RefinedSize refinedSize = getRefinedSize( MediaQuery.of(context).size, refinedBreakpoint: RefinedBreakpoints( desktopSmall: 1000, desktopNormal: 1600, desktopLarge: 2400, desktopExtraLarge: 3200, ), ); ``` -------------------------------- ### Get Value for Screen Type Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/quick-reference.md Retrieve a value based on the current device screen type (mobile, tablet, desktop). Requires `BuildContext` and specific values for each type. ```dart Container( padding: EdgeInsets.all( getValueForScreenType( context: context, mobile: 10, tablet: 30, desktop: 60, ), ), ) ``` -------------------------------- ### Understanding SizingInformation Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/GETTING-STARTED.md Access device and screen size information within the ResponsiveBuilder widget. ```dart ResponsiveBuilder( builder: (context, sizingInfo) { // Device type checks (boolean) sizingInfo.isMobile // true if on mobile sizingInfo.isTablet // true if on tablet sizingInfo.isDesktop // true if on desktop sizingInfo.isWatch // true if on watch // Refined size checks (boolean) sizingInfo.isSmall // true if small size sizingInfo.isNormal // true if normal size sizingInfo.isLarge // true if large size sizingInfo.isExtraLarge // true if extra large size // Raw data sizingInfo.screenSize // full screen dimensions sizingInfo.localWidgetSize // widget's available space return MyWidget(); }, ) ``` -------------------------------- ### Classes Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/module-reference.md Classes for managing sizing information, breakpoints, and global configuration. ```APIDOC ## Class: SizingInformation ### Description A data container for holding sizing-related information. ## Class: ScreenBreakpoints ### Description Defines thresholds for different screen types. ## Class: RefinedBreakpoints ### Description Specifies refined size thresholds for more granular control. ## Class: ResponsiveSizingConfig ### Description A singleton class for global configuration of responsive sizing. ``` -------------------------------- ### Widget Hierarchy Overview Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/INDEX.md Shows the typical widget tree structure when using the Responsive Builder package. The root widget is ResponsiveApp, followed by MaterialApp/CupertinoApp, and then responsive layout widgets. ```plaintext ResponsiveApp (root) └── MaterialApp/CupertinoApp └── ScreenTypeLayout (or ResponsiveBuilder) └── OrientationLayoutBuilder (optional) └── RefinedLayoutBuilder (optional) └── User widgets ``` -------------------------------- ### Get Value for Refined Size Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/quick-reference.md Retrieve a value based on the refined size category (e.g., small, normal, large, extraLarge). Requires `BuildContext` and specific values for each category. ```dart GridView.count( crossAxisCount: getValueForRefinedSize( context: context, small: 2, normal: 3, large: 4, extraLarge: 6, ), ) ``` -------------------------------- ### Access Singleton Instance Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/api-reference/responsive_sizing_config.md Access the singleton instance via `ResponsiveSizingConfig.instance`. This provides a global point of access for managing responsive breakpoints. ```dart static ResponsiveSizingConfig get instance { if (_instance == null) { _instance = ResponsiveSizingConfig(); } return _instance!; } ``` -------------------------------- ### Get Value for Screen Type (Padding) Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/api-reference/helper_functions.md Use this snippet to apply responsive padding to a Container based on the device's screen type. It requires a BuildContext and provides fallback values. ```dart Container( padding: EdgeInsets.all( getValueForScreenType( context: context, mobile: 10, tablet: 30, desktop: 60, ), ), child: Text('Responsive Padding'), ) ``` -------------------------------- ### Get Device Type with Default Breakpoints Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/api-reference/helper_functions.md Use this to determine the device type based on screen size using the default breakpoints. It's useful for conditionally rendering UI elements. ```dart import 'package:flutter/material.dart'; import 'package:responsive_builder/responsive_builder.dart'; void myFunction(BuildContext context) { Size screenSize = MediaQuery.of(context).size; DeviceScreenType deviceType = getDeviceType(screenSize); if (deviceType == DeviceScreenType.mobile) { print('Running on mobile'); } else if (deviceType == DeviceScreenType.tablet) { print('Running on tablet'); } } ``` -------------------------------- ### Responsive Sizing Extensions on num Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/api-reference/responsive_app.md Once wrapped with `ResponsiveApp`, numeric types gain extensions for responsive sizing. `screenHeight` and `sh` return the percentage of screen height, while `screenWidth` and `sw` return the percentage of screen width. ```APIDOC ## Responsive Sizing Extensions ### Extension Methods on num - **screenHeight** (`double`) Returns the percentage of screen height based on the extended number. Example: `20.screenHeight` returns 20% of the current screen height. - **screenWidth** (`double`) Returns the percentage of screen width based on the extended number. Example: `30.screenWidth` returns 30% of the current screen width. - **sh** (`double`) Shorthand for `screenHeight`. - **sw** (`double`) Shorthand for `screenWidth`. ### Usage Examples ```dart // Set widget height to 20% of screen height SizedBox(height: 20.screenHeight) // Set widget height using shorthand SizedBox(height: 20.sh) // Set font size to 5% of screen width Text( 'Responsive Text', style: TextStyle(fontSize: 5.sw), ) // Combine with other widgets Container( padding: EdgeInsets.all(10.sw), width: 80.screenWidth, height: 50.screenHeight, child: Text('Responsive Container'), ) ``` ``` -------------------------------- ### Default Screen Breakpoints Configuration Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/INDEX.md Configure the default breakpoints for desktop, tablet, and watch screen sizes. ```dart ScreenBreakpoints( desktop: 950, tablet: 600, watch: 300, ) ``` -------------------------------- ### Main Entry Point Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/module-reference.md The primary import for all public APIs. This file re-exports all public types and functions from internal modules, providing a single point of access for the library's functionality. ```APIDOC ## Main Entry Point `lib/responsive_builder.dart` The primary import for all public APIs. Re-exports all public types and functions from internal modules. ### Import ```dart import 'package:responsive_builder/responsive_builder.dart'; ``` ``` -------------------------------- ### Get Value for Screen Type (Font Size) Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/api-reference/helper_functions.md Adjust the font size of a Text widget responsively using getValueForScreenType. This snippet demonstrates setting different font sizes for mobile, tablet, and desktop. ```dart Text( 'Responsive Text', style: TextStyle( fontSize: getValueForScreenType( context: context, mobile: 14, tablet: 18, desktop: 24, ), ), ) ``` -------------------------------- ### ResponsiveBuilder Usage with Custom Breakpoints Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/api-reference/responsive_builder.md Illustrates how to provide custom screen breakpoints to the ResponsiveBuilder widget. ```APIDOC ## ResponsiveBuilder Usage with Custom Breakpoints ### Description This example demonstrates how to customize the screen breakpoints used by `ResponsiveBuilder` to define different layout sizes. ### Code ```dart ResponsiveBuilder( breakpoints: ScreenBreakpoints( desktop: 1200, tablet: 700, watch: 280, ), builder: (context, sizingInfo) { return Text('Width: ${sizingInfo.screenSize.width}'); }, ) ``` ``` -------------------------------- ### Responsive Sizing Extensions Source: https://github.com/filledstacks/responsive_builder/blob/master/README.md Utilize screenHeight (sh) and screenWidth (sw) extensions to size widgets based on screen dimensions. Use the desired number as a percentage of the screen. ```dart import 'package:responsive_builder/responsive_builder.dart'; SizedBox(height: 30.screenHeight); // Or sh for shorthand Text('respond to width', style: TextStyle(fontSize: 10.sw)); ``` -------------------------------- ### Get Refined Size Category Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/api-reference/helper_functions.md Classifies the device into a refined size category. Uses the device type and applies size thresholds. The `isWebOrDesktop` parameter controls whether to use full width or shortest dimension. ```dart void myFunction(BuildContext context) { Size screenSize = MediaQuery.of(context).size; RefinedSize refinedSize = getRefinedSize(screenSize); if (refinedSize == RefinedSize.extraLarge) { print('Ultra-wide screen detected'); } } ``` -------------------------------- ### ResponsiveBuilder to check sizing information Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/quick-reference.md Use the ResponsiveBuilder widget and access the 'sizingInfo' object within its builder to print detailed responsive information to the console. This helps in understanding the current layout constraints. ```dart ResponsiveBuilder( builder: (context, sizingInfo) { print(sizingInfo); // Outputs detailed information return MyWidget(); }, ) ``` -------------------------------- ### Get Screen Type Specific Values with getValueForScreenType Source: https://github.com/filledstacks/responsive_builder/blob/master/README.md Use the generic getValueForScreenType function to retrieve values based on the current device screen type without rewriting UI. This is useful for changing properties like padding or visibility. ```dart Container( padding: EdgeInsets.all(getValueForScreenType( context: context, mobile: 10, tablet: 30, desktop: 60, )), child: Text('Best Responsive Package'), ) ``` ```dart getValueForScreenType( context: context, mobile: false, tablet: true, ) ? MyWidget() : Container() ``` -------------------------------- ### Helper Functions Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/module-reference.md Utility functions for device detection and screen-specific values. These functions help in making responsive decisions without building complex widget hierarchies, useful for individual property sizing. ```APIDOC ## getDeviceType ### Description Determine device type from screen size. ### Signature `DeviceScreenType getDeviceType(Size, [ScreenBreakpoints?])` ``` ```APIDOC ## getRefinedSize ### Description Determine refined size category from screen size. ### Signature `RefinedSize getRefinedSize(Size, {RefinedBreakpoints?, bool})` ``` ```APIDOC ## getValueForScreenType ### Description Generic helper to get values by device type. ### Signature `T getValueForScreenType({BuildContext, T, T?, T?, T?})` ### Usage Pattern ```dart Container( padding: EdgeInsets.all( getValueForScreenType( context: context, mobile: 10, tablet: 30, desktop: 60, ), ), ) ``` ``` ```APIDOC ## getValueForRefinedSize ### Description Generic helper to get values by refined size. ### Signature `T getValueForRefinedSize({BuildContext, T, T?, T?, T?})` ``` -------------------------------- ### ResponsiveAppExtensions on num Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/module-reference.md Provides extension methods on the `num` type for responsive sizing relative to screen dimensions. ```APIDOC ## Extension: ResponsiveAppExtensions on num ### Description Adds sizing methods to the `num` type for responsive design. ### Members - **screenHeight** (double): Percentage of screen height. Example: `20.screenHeight`. - **screenWidth** (double): Percentage of screen width. Example: `50.screenWidth`. - **sh** (double): Shorthand for `screenHeight`. - **sw** (double): Shorthand for `screenWidth`. ``` -------------------------------- ### Import Responsive Builder Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/module-reference.md This is the standard import statement to include the responsive_builder library in your Dart project. ```dart import 'package:responsive_builder/responsive_builder.dart'; ``` -------------------------------- ### ResponsiveApp Constructor Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/api-reference/responsive_app.md The constructor for ResponsiveApp. It takes a builder function to construct the app widget and an optional boolean to prefer desktop layout. ```dart const ResponsiveApp({ Key? key, required Widget Function(BuildContext) builder, bool preferDesktop = false, }) ``` -------------------------------- ### SizingInformation Constructor Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/api-reference/sizing_information.md Constructor for the SizingInformation class. Requires device type, refined size, screen size, and local widget size. ```dart SizingInformation({ required DeviceScreenType deviceScreenType, required RefinedSize refinedSize, required Size screenSize, required Size localWidgetSize, }) ``` -------------------------------- ### ResponsiveApp Wrapper for Responsive Sizing Source: https://github.com/filledstacks/responsive_builder/blob/master/_autodocs/module-reference.md Wrap your MaterialApp or equivalent with ResponsiveApp to enable responsive sizing extensions. The builder function provides the BuildContext needed for responsive calculations. ```dart ResponsiveApp( builder: (context) => MaterialApp( home: HomePage(), ), ) ```