timeframe_selector 0.1.0 copy "timeframe_selector: ^0.1.0" to clipboard
timeframe_selector: ^0.1.0 copied to clipboard

A widget for simple timeframe selection similar to calenders

example/main.dart

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

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

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

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: Scaffold(
        body: TimeFrameExample(),
      ),
    );
  }
}

class TimeFrameExample extends StatefulWidget {
  const TimeFrameExample({super.key});

  @override
  State<TimeFrameExample> createState() => _TimeFrameExampleState();
}

class _TimeFrameExampleState extends State<TimeFrameExample> {
  DateTimeRange? selectedTimeframe;

  @override
  Widget build(BuildContext context) {
    return SingleChildScrollView(
      child: TimeframeSelector(
        baseTimeframe: DateTimeRange(
          start: DateTime(0, 1, 1, 10),
          end: DateTime(0, 1, 1, 24),
        ),
        noSelectionText: "No selection",
        timeSegmentLength: const Duration(minutes: 30),
        minTimeframeSegments: 4,
        selectedTimeframe: selectedTimeframe,
        overlayDatas: [
          OverlayData(
            timeframes: [
              DateTimeRange(
                start: DateTime(0, 1, 1, 15),
                end: DateTime(0, 1, 1, 17),
              ),
            ],
          ),
          OverlayData(
            timeframes: [
              DateTimeRange(
                start: DateTime(0, 1, 1, 20),
                end: DateTime(0, 1, 1, 22),
              ),
            ],
            color: Colors.green.withOpacity(0.2),
            borderColor: Colors.green.withOpacity(0.4),
            blockSelection: false,
            child: const Text("Hello world!"),
          ),
        ],
        onTimeframeChange: (newTimeframe) => setState(
          () {
            selectedTimeframe = newTimeframe;
          },
        ),
      ),
    );
  }
}
1
likes
0
points
2
downloads

Publisher

verified publisherfirebon.de

Weekly Downloads

A widget for simple timeframe selection similar to calenders

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

collection, flutter, intl

More

Packages that depend on timeframe_selector