Xtended is a collection of Widgets and extension methods that improve the way we construct widget trees in Flutter.
This was started by @dancamdev while trying to get closer to SwiftUI modifiers syntax in Flutter.
Modifiers are all about applying changes to a widget - you won't see this package using extensions to wrap widgets in other widgets, with a few exceptions.
This package is in an early stage, we're still figuring out the best way to do things, so expect breaking changes. We're definitely open to suggestions.
The API is not well documented yet, but we're working on it.
A collection of small extensions that allow you to modify any widget in a declarative way.
centered
- centers a widget in its parentexpanded
- expands a widget to fill its parentclip
- applies clipping to a widget, given a border radiusalign
- aligns a widget within its parentoffset
- offsets a widget by a given amount
A collection of extensions that allow you to modify strictly Text widgets.
copyWith
- copies a Text widget with new values, serves as a basis for the following ones.textAlign
- sets the text alignmentfontWeight
- sets the font weightbold
- sets the font weight to bold, as it is a common use case.fontSize
- sets the font sizecolor
- sets the font color
A single extension that allows you to modify the padding of a widget. It supports paddings concatenations and maintains Padding widget interoperability.
padding
- sets the padding of a widget, get's two parameters:List<Edge>
- a list of edges to apply the padding to.double
- the amount of padding to apply.
An example of this would be:
Text('Hello World').padding([Edge.top, Edge.horizontal], 10);
A single extension that allows you to add interactivity to a widget. It supports multiple actions (tap, long tap and double tap).
action
- sets the action of a widget, get's two parameters:VoidCallback
- sets the action of a widget, get's a function as a parameter.Action
- sets the action type of a widget, get's an ActionType as a parameter. Defaults toAction.tap
.
An example of this would be:
Text('Hello World').action(() => print('Double Tap!'), Action.doubleTap);
Wrappers around Column and Row, that provide sensible defaults, we expect you to just pass the children and be done with it, most of the time.
-
VStack
- a wrapper around Column, its height is defined by its children. -
VStack.expanded
- a wrapper around Column, its height is defined by its parent. -
VStack.scrollable
- a wrapper around Column, but scrolls for your list-based designs. -
HStack
- a wrapper around Row, its width is defined by its children. -
HStack.expanded
- a wrapper around Row, its width is defined by its parent. -
HStack.scrollable
- a wrapper around Row, but scrolls.
An example of this would be:
VStack([
Text('Hello World'),
Text('Hello World'),
Text('Hello World'),
])
A wrapper around GridView, that provides sensible defaults, we expect you to just pass the children and be done with it, most of the time.
Grid
- a wrapper around GridView, its height is defined by its children.Grid.horizontal
- a wrapper around GridView, its height is defined by its parent.
flutter pub add xtended
import 'package:xtended/xtended.dart';
and then use any of the extensions or widgets.
This was started by @dancamdev while trying to get SwiftUI modifiers syntax in Flutter.
It is maintained by @dancamdev and App and Up Srl (https://www.appandup.app/). While battle testing it in production projects.
Feel free to contribute to this package, it's a work in progress and we're open to suggestions.