Skip to content

Instantly share code, notes, and snippets.

@jonahwilliams
Last active August 10, 2021 18:29
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 jonahwilliams/309637aabc559676c060d7a24acc1c6c to your computer and use it in GitHub Desktop.
Save jonahwilliams/309637aabc559676c060d7a24acc1c6c to your computer and use it in GitHub Desktop.
tabs example
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
void main() {
runApp(MaterialApp(home: Example()));
}
class Example extends StatefulWidget {
const Example({Key? key}) : super(key: key);
@override
_ExampleState createState() => _ExampleState();
}
class _ExampleState extends State<Example> {
@override
Widget build(BuildContext context) {
return const DefaultTabController(
length: 2,
child: Scaffold(
appBar: TabBar(
tabs: <Tab>[
Tab(text: 'SVG'),
Tab(text: 'Blank'),
],
),
body: TabBarView(children: <Widget>[
SvgTab(),
Blank(),
]),
),
);
}
}
class Blank extends StatelessWidget {
const Blank({ Key? key }) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
);
}
}
class SvgTab extends StatelessWidget {
const SvgTab({ Key? key }) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
child: SvgPicture.asset('assets/wikimedia/Ghostscript_Tiger.svg'),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment