Skip to content

Instantly share code, notes, and snippets.

@Abhilash-Chandran
Created June 17, 2021 07:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Abhilash-Chandran/42f3abf37c19fe2c1ad22cc85197f8ee to your computer and use it in GitHub Desktop.
Save Abhilash-Chandran/42f3abf37c19fe2c1ad22cc85197f8ee to your computer and use it in GitHub Desktop.
Customized tab indicator with gradients.
import 'package:flutter/material.dart';
void main() {
runApp(TabBarDemo());
}
class TabBarDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: DefaultTabController(
length: 3,
child: Scaffold(
appBar: AppBar(
backgroundColor: Colors.black,
bottom: TabBar(
indicator: BoxDecoration(
gradient: LinearGradient(
colors: [
Colors.green,
Colors.blue,
Colors.red,
],
),
borderRadius: BorderRadius.all(
Radius.circular(5),
),
),
indicatorWeight: 5,
indicatorPadding: EdgeInsets.only(top:40),
tabs: [
Tab(icon: Icon(Icons.directions_car)),
Tab(icon: Icon(Icons.directions_transit)),
Tab(icon: Icon(Icons.directions_bike)),
],
),
title: Text('Tabs Demo'),
),
body: TabBarView(
children: [
Icon(Icons.directions_car),
Icon(Icons.directions_transit),
Icon(Icons.directions_bike),
],
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment