flat_segmented_control 0.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 84

flat_segmented_control #

Segemented Control with TabView for Flutter. Inspired by SegmentedControl (iOS) and Material Design.

Gif Example

How to use #

  1. Add flat_segmented_control to your package's pubspec.yaml, then intall it.

  2. Import package.

import 'package:flat_segmented_control/flat_segmented_control.dart';
  1. Add this to your child Widget.
FlatSegmentedControl(
    tabChildren: <Widget>[
        Container(
        height: 50.0,
        child: Center(child: Text("Tab 1")),
        ),
        Container(
        height: 50.0,
        child: Center(child: Text("Tab 2")),
        ),
        Container(
        height: 50.0,
        child: Center(child: Text("Tab 3")),
        ),
    ],
    childrenHeight: 150.0,
    children: <Widget>[
        Center(child: Text("View 1")),
        Center(child: Text("View 2")),
        Center(child: Text("View 3")),
    ],
),

Check #

  1. Make sure length of children same as navChildren.
  2. Change childrenHeight or childrenWidth if you desire.

[0.0.1] - 2019-07-20 #

  • Initial Release.

[0.0.2] - 2019-07-20 #

  • Now required to insert height of children.

[0.1.0] - 2019-08-26 #

  • Now based on TabBar and TabBarView. Constructor has also been changed. Read README.md for more info.

example/lib/main.dart

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Segmented Control Demo',
      home: MyHomePage(title: 'Segmented Control Demo'),
    );
  }
}

class MyHomePage extends StatelessWidget {
  final String title;

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(title),
      ),
      body: ListView(
        children: <Widget>[
          Center(
            child: FlutterLogo(
              size: 150.0,
            ),
          ),
          SizedBox(height: 20.0),
          FlatSegmentedControl(
            tabChildren: <Widget>[
              Container(
                height: 50.0,
                child: Center(child: Text("Tab 1")),
              ),
              Container(
                height: 50.0,
                child: Center(child: Text("Tab 2")),
              ),
              Container(
                height: 50.0,
                child: Center(child: Text("Tab 3")),
              ),
            ],
            childrenHeight: 150.0,
            children: <Widget>[
              Center(child: Text("View 1")),
              Center(child: Text("View 2")),
              Center(child: Text("View 3")),
            ],
          ),
          SizedBox(height: 20.0),
          Text(
            "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",
          ),
        ],
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flat_segmented_control: ^0.1.0

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:flat_segmented_control/flat_segmented_control.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
68
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
84
Learn more about scoring.

We analyzed this package on Apr 8, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test