Skip to content

Instantly share code, notes, and snippets.

@bltavares
Created July 4, 2022 18:52
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 bltavares/73ae65c341479ecb07f804709f53d035 to your computer and use it in GitHub Desktop.
Save bltavares/73ae65c341479ecb07f804709f53d035 to your computer and use it in GitHub Desktop.
silent-sunshine-7526

silent-sunshine-7526

Created with <3 with dartpad.dev.

import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
static const String _title = 'Flutter Code Sample';
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: _title,
home: MyStatelessWidget(),
);
}
}
class NoisyText extends StatelessWidget {
const NoisyText(this.text, {super.key });
final String text;
@override
Widget build(BuildContext context) {
print('RENDERED $text');
return Text(text);
}
}
class MyStatelessWidget extends StatelessWidget {
const MyStatelessWidget({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return DefaultTabController(
initialIndex: 1,
length: 3,
child: Scaffold(
appBar: AppBar(
title: const Text('TabBar Widget'),
bottom: const TabBar(
tabs: <Widget>[
Tab(
icon: Icon(Icons.cloud_outlined),
),
Tab(
icon: Icon(Icons.beach_access_sharp),
),
Tab(
icon: Icon(Icons.brightness_5_sharp),
),
],
),
),
body: const TabBarView(
children: <Widget>[
Center(
child: NoisyText("It's cloudy here"),
),
Center(
child: NoisyText("It's rainy here"),
),
Center(
child: NoisyText("It's sunny here"),
),
],
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment