tabbed_view 1.19.1 tabbed_view: ^1.19.1 copied to clipboard
Flutter widget inspired by the classic Desktop-style tab component. Supports customizable themes.
import 'package:flutter/material.dart';
import 'package:tabbed_view/tabbed_view.dart';
void main() {
runApp(TabbedViewExample());
}
class TabbedViewExample extends StatelessWidget {
const TabbedViewExample({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false, home: TabbedViewExamplePage());
}
}
class TabbedViewExamplePage extends StatefulWidget {
const TabbedViewExamplePage({Key? key}) : super(key: key);
@override
TabbedViewExamplePageState createState() => TabbedViewExamplePageState();
}
class TabbedViewExamplePageState extends State<TabbedViewExamplePage> {
late TabbedViewController _controller;
@override
void initState() {
super.initState();
List<TabData> tabs = [];
tabs.add(TabData(
text: 'Tab 1',
leading: (context, status) => Icon(Icons.star, size: 16),
content: Padding(padding: EdgeInsets.all(8), child: Text('Hello'))));
tabs.add(TabData(
text: 'Tab 2',
content:
Padding(padding: EdgeInsets.all(8), child: Text('Hello again'))));
tabs.add(TabData(
closable: false,
text: 'TextField',
content: Padding(
padding: EdgeInsets.all(8),
child: TextField(
decoration: InputDecoration(
isDense: true, border: OutlineInputBorder()))),
keepAlive: true));
_controller = TabbedViewController(tabs);
}
@override
Widget build(BuildContext context) {
TabbedView tabbedView = TabbedView(controller: _controller);
Widget w =
TabbedViewTheme(data: TabbedViewThemeData.mobile(), child: tabbedView);
return Scaffold(body: Container(padding: EdgeInsets.all(32), child: w));
}
}