timelines
a powerful & easy to use timeline package for flutter!
caveat: this package is an early stage. not enough testing has been done to guarantee stability. some apis may change.
examples
check it out on the web or look at the .
timeline status | package delivery tracking | process timeline |
---|---|---|
more examples
�� wip ��
features
the timeline and each components are all widget.
- common styles can be easily implemented with predefined components.
- vertical, horizontal direction.
- alternating contents.
- combination with flutter widgets(row, column, customscrollview, etc).
- customize each range with themes.
installation
1. depend on it
add this to your package’s pubspec.yaml file:
dependencies:
timelines: ^[latest_version]
2. install it
you can install packages from the command line:
with flutter:
$ flutter pub get
alternatively, your editor might support flutter pub get. check the docs for your editor to learn more.
3. import it
now in your dart code, you can use:
import 'package:timelines/timelines.dart';
basic usage
@override
widget build(buildcontext context) {
return timeline.tilebuilder(
builder: timelinetilebuilder.fromstyle(
contentsalign: contentsalign.alternating,
contentsbuilder: (context, index) => padding(
padding: const edgeinsets.all(24.0),
child: text('timeline event $index'),
),
itemcount: 10,
),
);
}
check the example or the api reference for more details.
components
theme
check out theme demo to see how the values inside timelinetile work with the theme.
to customize the timeline component with a theme, do the following:
timelinetheme(
data: timelinethemedata(...),
child: dotindicator(...),
);
if you only want to change part of the parent theme, use timelinetheme.of(context)
:
timelinetheme(
data: timelinethemedata.of(context).copywith(...),
child: dotindicator(...),
);
if the component you want to customize is timeline
or fixedtimeline
, this is also possible:
fixedtimeline(
theme: timelinethemedata(...),
children: [...],
);
indicator
containerindicatordotindicatoroutlineddotindicator
containerindicator(
child: container(
width: 15.0,
height: 15.0,
color: colors.blue,
),
)
|
|
dotindicator()
|
|
outlineddotindicator()
|
connector
solidlineconnectordashedlineconnectordecoratedlineconnector
sizedbox(
height: 20.0,
child: solidlineconnector(),
)
|
|
sizedbox(
height: 20.0,
child: dashedlineconnector(),
)
|
|
sizedbox(
height: 20.0,
child: decoratedlineconnector(
decoration: boxdecoration(
gradient: lineargradient(
begin: alignment.topcenter,
end: alignment.bottomcenter,
colors: [colors.blue, colors.lightblueaccent[100]],
),
),
),
)
|
timelinenode
pure timeline ui component with no content.
the timelinenode contains an indicator and two connectors on both sides of the indicator:
simple timelinenodecomplex timelinenode
sizedbox(
height: 50.0,
child: timelinenode.simple(),
)
|
|
sizedbox(
height: 80.0,
child: timelinenode(
indicator: card(
margin: edgeinsets.zero,
child: padding(
padding: edgeinsets.all(8.0),
child: text('complex'),
),
),
startconnector: dashedlineconnector(),
endconnector: solidlineconnector(),
),
)
|
timelinetile
displays content on both sides of the node:
timelinetile
timelinetile(
oppositecontents: padding(
padding: const edgeinsets.all(8.0),
child: text('oppositencontents'),
),
contents: card(
child: container(
padding: edgeinsets.all(8.0),
child: text('contents'),
),
),
node: timelinenode(
indicator: dotindicator(),
startconnector: solidlineconnector(),
endconnector: solidlineconnector(),
),
)
|
timelinetilebuilder
timelinetilebuilder provides powerful build features.
connection
each tile draws only half of the line connecting the neighboring tiles.
using the connected
constructor, lines connecting adjacent tiles can build as one index.
connectiondirection.beforeconnectiondirection.after
fixedtimeline.tilebuilder(
builder: timelinetilebuilder.connectedfromstyle(
connectiondirection: connectiondirection.before,
connectorstylebuilder: (context, index) {
return (index == 1) ? connectorstyle.dashedline : connectorstyle.solidline;
},
indicatorstylebuilder: (context, index) => indicatorstyle.dot,
itemextent: 40.0,
itemcount: 3,
),
)
|
|
fixedtimeline.tilebuilder(
builder: timelinetilebuilder.connectedfromstyle(
connectiondirection: connectiondirection.after,
connectorstylebuilder: (context, index) {
return (index == 1) ? connectorstyle.dashedline : connectorstyle.solidline;
},
indicatorstylebuilder: (context, index) => indicatorstyle.dot,
itemextent: 40.0,
itemcount: 3,
),
)
|
contentsalign
this value determines how the contents of the timeline will be built:
contentsalign.basiccontentsalign.reversecontentsalign.alternating
fixedtimeline.tilebuilder(
builder: timelinetilebuilder.connectedfromstyle(
contentsalign: contentsalign.basic,
oppositecontentsbuilder: (context, index) => padding(
padding: const edgeinsets.all(8.0),
child: text('oppositencontents'),
),
contentsbuilder: (context, index) => card(
child: padding(
padding: const edgeinsets.all(8.0),
child: text('contents'),
),
),
connectorstylebuilder: (context, index) => connectorstyle.solidline,
indicatorstylebuilder: (context, index) => indicatorstyle.dot,
itemcount: 3,
),
)
|
|
fixedtimeline.tilebuilder(
builder: timelinetilebuilder.connectedfromstyle(
contentsalign: contentsalign.reverse,
oppositecontentsbuilder: (context, index) => padding(
padding: const edgeinsets.all(8.0),
child: text('oppositencontents'),
),
contentsbuilder: (context, index) => card(
child: padding(
padding: const edgeinsets.all(8.0),
child: text('contents'),
),
),
connectorstylebuilder: (context, index) => connectorstyle.solidline,
indicatorstylebuilder: (context, index) => indicatorstyle.dot,
itemcount: 3,
),
)
|
|
fixedtimeline.tilebuilder(
builder: timelinetilebuilder.connectedfromstyle(
contentsalign: contentsalign.alternating,
oppositecontentsbuilder: (context, index) => padding(
padding: const edgeinsets.all(8.0),
child: text('oppositencontents'),
),
contentsbuilder: (context, index) => card(
child: padding(
padding: const edgeinsets.all(8.0),
child: text('contents'),
),
),
connectorstylebuilder: (context, index) => connectorstyle.solidline,
indicatorstylebuilder: (context, index) => indicatorstyle.dot,
itemcount: 3,
),
)
|
timeline
the timeline component has two widgets, timeline
similar to scrollview and fixedtimeline
similar to flex.
also their constructors are similar to scrollview and flex.
the main difference is that they has timelinetheme as an ancestor.
the tilebuilder
constructor provides more powerful features using timelinetilebuilder.
if you don’t need timelinetilebuilder, you can use other flutter widgets like listview, column, row, etc.
even if you use the flutter widget, you can use timelinetheme.
Comments are closed.