Last active
June 13, 2021 15:51
-
-
Save noga-dev/b7783d89db91091c96d623cce321f54c to your computer and use it in GitHub Desktop.
Container vs. SizedBox vs. DecoratedBox
This file contains 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/foundation.dart' show kIsWeb; | |
import 'package:flutter/material.dart'; | |
import 'package:statsfl/statsfl.dart'; | |
void main() { | |
runApp( | |
StatsFl( | |
isEnabled: true, | |
showText: true, | |
sampleTime: 0.05, | |
totalTime: 60, | |
height: 200, | |
width: double.infinity, | |
align: Alignment.topCenter, | |
child: MaterialApp( | |
title: 'Flutter Demo', | |
debugShowCheckedModeBanner: false, | |
theme: ThemeData.dark(), | |
home: DefaultTabController( | |
length: 4, | |
child: Scaffold( | |
bottomNavigationBar: TabBar( | |
overlayColor: | |
MaterialStateColor.resolveWith((_) => Colors.grey[800]!), | |
indicator: BoxDecoration( | |
border: Border( | |
top: BorderSide(color: Colors.amber, width: 2), | |
)), | |
tabs: [ | |
Tab(text: 'Control'), | |
Tab(text: 'Container'), | |
Tab(text: 'SizedBox'), | |
Tab(text: 'DecoratedBox') | |
], | |
), | |
body: TabBarView( | |
children: [ | |
Center(), | |
Screen(Container()), | |
Screen(SizedBox()), | |
Screen(DecoratedBox(decoration: BoxDecoration())), | |
], | |
), | |
), | |
), | |
), | |
), | |
); | |
} | |
class Screen extends StatelessWidget { | |
const Screen( | |
this.child, { | |
Key? key, | |
}) : super(key: key); | |
final Widget child; | |
@override | |
Widget build(BuildContext context) => | |
Wrap(children: List.generate(kIsWeb ? 4000 : 14000, (_) => child)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment