РА
Включите performance overlay
Size: a a a
РА
РА
ND
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Scaffold(
backgroundColor: Colors.blue,
body: Test(),
),
);
}
}
class Test extends StatelessWidget {
DateTime lastRender;
get _duration {
var now = DateTime.now();
var defaultDelay = Duration(milliseconds: 100);
Duration delay;
if (lastRender == null) {
lastRender = now;
delay = defaultDelay;
} else {
var difference = now.difference(lastRender);
if (difference > defaultDelay) {
lastRender = now;
delay = defaultDelay;
} else {
var durationOffcet = difference - defaultDelay;
delay = defaultDelay + (-durationOffcet);
lastRender = now.add(-durationOffcet);
}
return delay;
}
return defaultDelay;
}
@override
Widget build(BuildContext context) {
return ListView(
children: List.generate(
100,
(index) => Item('item $index', _duration),
),
);
}
}
class Item extends StatefulWidget {
const Item(this.text, this.duration);
final Duration duration;
final String text;
@override
_ItemState createState() => _ItemState();
}
mixin AfterLayoutMixin<T extends StatefulWidget> on State<T> {
@override
void initState() {
super.initState();
WidgetsBinding.instance
.addPostFrameCallback((_) => afterFirstLayout(context));
}
void afterFirstLayout(BuildContext context);
}
class _ItemState extends State<Item> with AfterLayoutMixin<Item> {
bool _visible = false;
@override
Widget build(BuildContext context) {
return AnimatedOpacity(
duration: widget.duration,
opacity: _visible ? 1 : 0,
child: Container(
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(
width: 4,
color: Colors.blueAccent,
),
),
height: 80,
child: Text(widget.text, style: TextStyle(fontSize: 20.0)),
),
);
}
@override
void afterFirstLayout(BuildContext context) {
setState(() {
_visible = true;
});
}
}
M
K
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Scaffold(
backgroundColor: Colors.blue,
body: Test(),
),
);
}
}
class Test extends StatelessWidget {
DateTime lastRender;
get _duration {
var now = DateTime.now();
var defaultDelay = Duration(milliseconds: 100);
Duration delay;
if (lastRender == null) {
lastRender = now;
delay = defaultDelay;
} else {
var difference = now.difference(lastRender);
if (difference > defaultDelay) {
lastRender = now;
delay = defaultDelay;
} else {
var durationOffcet = difference - defaultDelay;
delay = defaultDelay + (-durationOffcet);
lastRender = now.add(-durationOffcet);
}
return delay;
}
return defaultDelay;
}
@override
Widget build(BuildContext context) {
return ListView(
children: List.generate(
100,
(index) => Item('item $index', _duration),
),
);
}
}
class Item extends StatefulWidget {
const Item(this.text, this.duration);
final Duration duration;
final String text;
@override
_ItemState createState() => _ItemState();
}
mixin AfterLayoutMixin<T extends StatefulWidget> on State<T> {
@override
void initState() {
super.initState();
WidgetsBinding.instance
.addPostFrameCallback((_) => afterFirstLayout(context));
}
void afterFirstLayout(BuildContext context);
}
class _ItemState extends State<Item> with AfterLayoutMixin<Item> {
bool _visible = false;
@override
Widget build(BuildContext context) {
return AnimatedOpacity(
duration: widget.duration,
opacity: _visible ? 1 : 0,
child: Container(
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(
width: 4,
color: Colors.blueAccent,
),
),
height: 80,
child: Text(widget.text, style: TextStyle(fontSize: 20.0)),
),
);
}
@override
void afterFirstLayout(BuildContext context) {
setState(() {
_visible = true;
});
}
}
K
K
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Scaffold(
backgroundColor: Colors.blue,
body: Test(),
),
);
}
}
class Test extends StatelessWidget {
DateTime lastRender;
get _duration {
var now = DateTime.now();
var defaultDelay = Duration(milliseconds: 100);
Duration delay;
if (lastRender == null) {
lastRender = now;
delay = defaultDelay;
} else {
var difference = now.difference(lastRender);
if (difference > defaultDelay) {
lastRender = now;
delay = defaultDelay;
} else {
var durationOffcet = difference - defaultDelay;
delay = defaultDelay + (-durationOffcet);
lastRender = now.add(-durationOffcet);
}
return delay;
}
return defaultDelay;
}
@override
Widget build(BuildContext context) {
return ListView(
children: List.generate(
100,
(index) => Item('item $index', _duration),
),
);
}
}
class Item extends StatefulWidget {
const Item(this.text, this.duration);
final Duration duration;
final String text;
@override
_ItemState createState() => _ItemState();
}
mixin AfterLayoutMixin<T extends StatefulWidget> on State<T> {
@override
void initState() {
super.initState();
WidgetsBinding.instance
.addPostFrameCallback((_) => afterFirstLayout(context));
}
void afterFirstLayout(BuildContext context);
}
class _ItemState extends State<Item> with AfterLayoutMixin<Item> {
bool _visible = false;
@override
Widget build(BuildContext context) {
return AnimatedOpacity(
duration: widget.duration,
opacity: _visible ? 1 : 0,
child: Container(
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(
width: 4,
color: Colors.blueAccent,
),
),
height: 80,
child: Text(widget.text, style: TextStyle(fontSize: 20.0)),
),
);
}
@override
void afterFirstLayout(BuildContext context) {
setState(() {
_visible = true;
});
}
}
ND
ND
K
ND
T
ND
T
T
T
ND