live_cell_widgets

Last updated:

0 purchases

live_cell_widgets Image
live_cell_widgets Images
Add to Cart

Description:

live cell widgets

This package provides wrappers over Flutter widgets which allow their properties to be accessed
and controlled by ValueCell's, a ValueNotifier-like interface. If you're new to Live Cells
see the live_cells package for a getting started guide,
documentation and examples.
Features #


This library allows you to write this:
final content = MutableCell('');

@override
Widget build(BuildContext context) {
return Column([
CellText(data: content),
ElevatedButton(
child: Text('Say Hi!'),
onPressed: () => content.value = 'Hi!'
)
]);
}
copied to clipboard
Instead of this:
final content = ValueNotifier('');

@override
void dispose() {
content.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
return Column([
ValueListenableBuilder(
valueListenable: content,
builder: (context, content, _) => Text(content)
),
ElevatedButton(
child: Text('Say Hi!'),
onPressed: () => content.value = 'Hi!'
)
]);
}
copied to clipboard


Data can flow in both ways, which allows you to write this:
final switchState = MutableCell(true);

@override
Widget build(BuildContext context) {
return Column([
CellSwitch(
value: switchState
)
]);
}
copied to clipboard
instead of this:
final switchState = ValueNotifier(true);

@override
void dispose() {
switchState.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
return Column([
ValueListenableBuilder(
valueListenable: switchState,
builder: (context, value, _) => Switch(
value: value,
onChanged: (value) => switchState.value = value
)
)
]);
}
copied to clipboard


Much less verbose than setting up (and disposing) ValueNotifier's and ValueListenableBuilder's.


Eliminates the need for controller objects (still a work in progress).


ValueCell's can be defined as an expression of other ValueCell's allowing for a declarative
style of programming. ValueNotifiers cannot.


ValueCell's do not have to be disposed manually.


Usage #
The provided wrapper classes are named the same as their corresponding Flutter widget classes but
prefixed with Cell, e.g. CellText is the wrapper for Flutter's Text, CellSwitch is the
wrapper for Flutter's Switch.
Each wrapper class provides a constructor which accepts the same arguments (with a few exceptions)
as the constructor of the equivalent Flutter widget, but instead of taking raw values each argument
takes a ValueCell. The only exception is the key argument which is not a ValueCell.
Every wrapper class also provides a bind method which creates a copy of the widget but with
different values (ValueCell's) for some of the properties.
For example, the following:
final text = CellText(data: 'hello'.cell) // Initialize with a const 'hello'
.bind(data: content) // Bind the data property to the cell `content`
.bind(style: textStyle); // Bind the style property to the cell `textStyle`
copied to clipboard
is equivalent to:
final text = CellText(
data: content,
style: textStyle
);
copied to clipboard
Additional information #

For the full list of the wrapper classes provided, check this package's API documentation.
For an introduction to ValueCell's and their capabilities, visit the
live_cells package.
If you'd like a wrapper class for a specific widget, open an issue on the package's Github
repository.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.