No puede seleccionar más de 25 temas
Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
86 líneas
2.0 KiB
86 líneas
2.0 KiB
hace 4 años
|
import 'dart:async';
|
||
|
import 'package:flutter/material.dart';
|
||
|
|
||
|
/// 常规布局
|
||
|
class One extends StatefulWidget {
|
||
|
@override
|
||
|
State<StatefulWidget> createState() {
|
||
|
return _OneState();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
class _OneState extends State<One> {
|
||
|
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 MaterialApp(
|
||
|
home: Scaffold(
|
||
|
appBar: AppBar(
|
||
|
title: Text("性能测试1"),
|
||
|
),
|
||
|
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: Text(
|
||
|
_count.toString(),
|
||
|
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||
|
),
|
||
|
),
|
||
|
)
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
}
|