Last active
August 10, 2021 18:29
-
-
Save jonahwilliams/309637aabc559676c060d7a24acc1c6c to your computer and use it in GitHub Desktop.
tabs example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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