Non puoi selezionare più di 25 argomenti
Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
97 righe
2.2 KiB
97 righe
2.2 KiB
import 'dart:async';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
class Two extends StatefulWidget {
|
|
@override
|
|
State<StatefulWidget> createState() {
|
|
return _TwoState();
|
|
}
|
|
}
|
|
|
|
class CountText extends StatefulWidget {
|
|
@override
|
|
State<StatefulWidget> createState() {
|
|
return _CountTextState();
|
|
}
|
|
}
|
|
|
|
class _CountTextState extends State<CountText> {
|
|
int _count = 0;
|
|
Timer _timer;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
Timer.periodic(Duration(milliseconds: 1000), (t) {
|
|
setState(() {
|
|
_count++;
|
|
});
|
|
});
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
if (_timer != null && _timer.isActive) {
|
|
_timer.cancel();
|
|
}
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Text(
|
|
_count.toString(),
|
|
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _TwoState extends State<Two> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
home: Scaffold(
|
|
appBar: AppBar(
|
|
title: Text("性能测试2"),
|
|
),
|
|
body: Column(
|
|
children: <Widget>[
|
|
Container(
|
|
margin: EdgeInsets.fromLTRB(10, 10, 10, 5),
|
|
height: 100,
|
|
color: Colors.amberAccent,
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.fromLTRB(10, 10, 10, 5),
|
|
height: 100,
|
|
color: Colors.blue,
|
|
),
|
|
Container(
|
|
height: 100,
|
|
child: ListView.builder(
|
|
scrollDirection: Axis.horizontal,
|
|
itemCount: 12,
|
|
itemBuilder: (context, index) {
|
|
return Container(
|
|
width: 70,
|
|
height: 70,
|
|
child: Image.asset(
|
|
"assets/2.png",
|
|
width: 50,
|
|
height: 50,
|
|
));
|
|
}),
|
|
),
|
|
Container(
|
|
height: 100,
|
|
margin: EdgeInsets.fromLTRB(10, 10, 10, 5),
|
|
color: Colors.yellow,
|
|
child: Center(child: CountText()),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|