toggle_bar 1.0.0 copy "toggle_bar: ^1.0.0" to clipboard
toggle_bar: ^1.0.0 copied to clipboard

A horizontal bar of toggle tabs with customisable colors and labels.

example/lib/main.dart

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

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.deepPurple,
      ),
      debugShowCheckedModeBanner: false,
      home: MyHomePage(title: 'Toggle Bar Example'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  List<String> labels = ["Apples", "Bananas", "Oranges", "Papayas"];
  int currentIndex = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          children: <Widget>[
            ToggleBar(
              labels: labels,
              backgroundColor: Colors.grey[800],
              onSelectionUpdated: (index) =>
                  setState(() => currentIndex = index),
            ),
            SizedBox(
              height: 300,
            ),
            Text(
              labels[currentIndex],
              style: Theme.of(context).textTheme.display1,
            )
          ],
        ),
      ),
    );
  }
}
44
likes
40
pub points
72%
popularity

Publisher

unverified uploader

A horizontal bar of toggle tabs with customisable colors and labels.

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on toggle_bar