AdaptiveBuilder class
Typical usage is as follows:
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
return AdaptiveBuilder(
builder: (BuildContext context, Screen screen) {
return const Center(
child: Text('Default Builder'),
);
},
androidDelegate: _getAndroidDelegate(),
windowsDelegate: _getWindowsDelegate(),
linuxDelegate: _getLinuxDelegate(),
webDelegate: _getWebDelegate(),
allPlatformsDelegate: _getAlllatformsDelegate(),
);
}
AdaptiveLayoutDelegate? _getAndroidDelegate() {
return AdaptiveLayoutDelegateWithMinimallScreenType(
handset: (BuildContext context, Screen screen) {
return const Center(
child: Text('Android - Handset'),
);
},
);
}
AdaptiveLayoutDelegate? _getWindowsDelegate() {
return AdaptiveLayoutDelegateWithScreenType(
smallHandset: (BuildContext context, Screen screen) {
return const Center(
child: Text('Windows - Small handset'),
);
},
mediumHandset: (BuildContext context, Screen screen) {
return const Center(
child: Text('Windows - Medium handset'),
);
},
largeHandset: (BuildContext context, Screen screen) {
return const Center(
child: Text('Windows - Large handset'),
);
},
smallTablet: (BuildContext context, Screen screen) {
return const Center(
child: Text('Windows - Small Tablet'),
);
},
largeTablet: (BuildContext context, Screen screen) {
return const Center(
child: Text('Windows - Large Tablet'),
);
},
smallDesktop: (BuildContext context, Screen screen) {
return const Center(
child: Text('Windows - Small Desktop'),
);
},
mediumDesktop: (BuildContext context, Screen screen) {
return const Center(
child: Text('Windows - Medium Desktop'),
);
},
largeDesktop: (BuildContext context, Screen screen) {
return const Center(
child: Text('Windows - Large Desktop'),
);
},
);
}
AdaptiveLayoutDelegate? _getLinuxDelegate() {
return AdaptiveLayoutDelegateWithMinimallScreenType(
handset: (BuildContext context, Screen screen) {
return const Center(
child: Text('Linux - Handset'),
);
},
tablet: (BuildContext context, Screen screen) {
return const Center(
child: Text('Linux - Tablet'),
);
},
desktop: (BuildContext context, Screen screen) {
return const Center(
child: Text('Linux - Desktop'),
);
},
);
}
AdaptiveLayoutDelegate? _getWebDelegate() {
return AdaptiveLayoutDelegateWithScreenSize(
xSmall: (BuildContext context, Screen screen) {
return const Center(
child: Text('Web - X Small'),
);
},
medium: (BuildContext context, Screen screen) {
return const Center(
child: Text('Web - Medium'),
);
},
large: (BuildContext context, Screen screen) {
return const Center(
child: Text('Web - large'),
);
},
);
}
AdaptiveLayoutDelegate? _getAlllatformsDelegate() {
return AdaptiveLayoutDelegateWithScreenSize(
xSmall: (BuildContext context, Screen screen) {
return const Center(
child: Text('All OS - X Small'),
);
},
medium: (BuildContext context, Screen screen) {
return const Center(
child: Text('All OS - Medium'),
);
},
large: (BuildContext context, Screen screen) {
return const Center(
child: Text('All OS - large'),
);
},
xLarge: (BuildContext context, Screen screen) {
return const Center(
child: Text('All Platforms - X large'),
);
},
);
}
}
See also:
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- AdaptiveBuilder
Constructors
- AdaptiveBuilder({Key? key, required AdaptiveWidgetBuilder defaultBuilder, AdaptiveLayoutDelegate? layoutDelegate, @Deprecated('Use `AdaptiveBuilder.custom` counstructor instead. Will be removed in v1.0.0') AdaptiveLayoutDelegate? androidDelegate, @Deprecated('Use `AdaptiveBuilder.custom` counstructor instead. Will be removed in v1.0.0') AdaptiveLayoutDelegate? fuchsiaDelegate, @Deprecated('Use `AdaptiveBuilder.custom` counstructor instead. Will be removed in v1.0.0') AdaptiveLayoutDelegate? iosDelegate, @Deprecated('Use `AdaptiveBuilder.custom` counstructor instead. Will be removed in v1.0.0') AdaptiveLayoutDelegate? windowsDelegate, @Deprecated('Use `AdaptiveBuilder.custom` counstructor instead. Will be removed in v1.0.0') AdaptiveLayoutDelegate? macosDelegate, @Deprecated('Use `AdaptiveBuilder.custom` counstructor instead. Will be removed in v1.0.0') AdaptiveLayoutDelegate? linuxDelegate, @Deprecated('Use `AdaptiveBuilder.custom` counstructor instead. Will be removed in v1.0.0') AdaptiveLayoutDelegate? webDelegate, @Deprecated('Use `layoutDelegate` instead. Will be removed in v1.0.0') AdaptiveLayoutDelegate? allPlatformsDelegate, BreakpointData? breakpointData})
-
const
- AdaptiveBuilder.custom({Key? key, required AdaptiveWidgetBuilder defaultBuilder, AdaptiveLayoutDelegate? androidDelegate, AdaptiveLayoutDelegate? fuchsiaDelegate, AdaptiveLayoutDelegate? iosDelegate, AdaptiveLayoutDelegate? windowsDelegate, AdaptiveLayoutDelegate? macosDelegate, AdaptiveLayoutDelegate? linuxDelegate, AdaptiveLayoutDelegate? webDelegate, AdaptiveLayoutDelegate? allPlatformsDelegate, BreakpointData? breakpointData})
-
const
Properties
- allPlatformsDelegate → AdaptiveLayoutDelegate?
-
final
- androidDelegate → AdaptiveLayoutDelegate?
-
final
- breakpointData → BreakpointData?
-
final
- defaultBuilder → AdaptiveWidgetBuilder
-
final
- fuchsiaDelegate → AdaptiveLayoutDelegate?
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- iosDelegate → AdaptiveLayoutDelegate?
-
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- linuxDelegate → AdaptiveLayoutDelegate?
-
final
- macosDelegate → AdaptiveLayoutDelegate?
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- webDelegate → AdaptiveLayoutDelegate?
-
final
- windowsDelegate → AdaptiveLayoutDelegate?
-
final
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's location in the tree.
inherited
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of
DiagnosticsNode
objects describing this node's children.inherited -
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited