Skip to content

Instantly share code, notes, and snippets.

@noga-dev
Last active June 13, 2021 15:51
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 noga-dev/b7783d89db91091c96d623cce321f54c to your computer and use it in GitHub Desktop.
Save noga-dev/b7783d89db91091c96d623cce321f54c to your computer and use it in GitHub Desktop.
Container vs. SizedBox vs. DecoratedBox
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