When you switch back to a tab you get a black screen, does anyone know why?
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 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: TabBarView(
children: <Widget>[
StreamBuilder(
stream: Stream.value(true),
builder: (context, snapshot) {
return const Center(child: Text("It's cloudy here"));
},
),
StreamBuilder(
stream: Stream.value(true),
builder: (context, snapshot) {
return const Center(child: Text("It's rainy here"));
},
),
StreamBuilder(
stream: Stream.value(true),
builder: (context, snapshot) {
return const Center(child: Text("It's sunny here"));
},
),
],
),
),
);
}
}