pirooz_timeline 0.0.1 copy "pirooz_timeline: ^0.0.1" to clipboard
pirooz_timeline: ^0.0.1 copied to clipboard

Customizable Timeline

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:pirooz_timeline/pirooz_timeline.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: 'Flutter Demo',
        theme: ThemeData(
          // This is the theme of your application.
          //
          // Try running your application with "flutter run". You'll see the
          // application has a blue toolbar. Then, without quitting the app, try
          // changing the primarySwatch below to Colors.green and then invoke
          // "hot reload" (press "r" in the console where you ran "flutter run",
          // or simply save your changes to "hot reload" in a Flutter IDE).
          // Notice that the counter didn't reset back to zero; the application
          // is not restarted.
          primarySwatch: Colors.blue,
        ),
        home: Scaffold(
          body: Center(
              child: PiroozTimeline(
            flex: 5,
            indicatorAlignment: IndicatorAlignment.top,
            indicatorBuilder: (model, index) {
              if (model is A) {
                return Container(
                  padding: const EdgeInsets.all(20),
                  decoration: const BoxDecoration(
                      color: Colors.redAccent, shape: BoxShape.circle),
                  child: Text(index.toString()),
                );
              } else if (model is C) {
                return Container();
              } else {
                return Container(
                  height: 10,
                  decoration: const BoxDecoration(
                      color: Colors.redAccent, shape: BoxShape.circle),
                );
              }
            },
            connectorStyle: const ConnectorStyle(
              color: Colors.amber,
              dashSpace: 4,
              dashHeight: 5,
            ),
            models: const [],
            widgetBuilder: (PiroozModel model, int index) {
              if (model is A) {
                return Container(
                  decoration: BoxDecoration(color: Colors.red),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Text(model.value),
                    ],
                  ),
                );
              } else if (model is C) {
                return const Divider(
                  thickness: 2,
                );
              } else {
                return Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: Text((model as B).valaue),
                );
              }
            },
          )),
        ));
  }
}

class A extends PiroozModel {
  final String value;

  const A({required this.value});
}

class B extends PiroozModel {
  final String valaue;

  const B({required this.valaue});
}

class C extends PiroozModel {
  const C();
}
0
likes
0
pub points
0%
popularity

Publisher

unverified uploader

Customizable Timeline

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on pirooz_timeline