2023-11-24 20:35:29 +08:00
|
|
|
import 'dart:async';
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
2023-11-26 15:36:01 +08:00
|
|
|
|
2023-11-24 20:35:29 +08:00
|
|
|
class MyHomePage extends StatefulWidget {
|
|
|
|
const MyHomePage({super.key, required this.title});
|
|
|
|
|
|
|
|
final String title;
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<MyHomePage> createState() => _MyHomePageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
int _counter = 0;
|
|
|
|
Timer? timer;
|
|
|
|
|
|
|
|
void _incrementCounter() {
|
|
|
|
setState(() {
|
|
|
|
_counter++;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
appBar: AppBar(
|
|
|
|
toolbarHeight: 35,
|
|
|
|
title: Text(widget.title),
|
|
|
|
backgroundColor: Theme.of(context).colorScheme.primary,
|
|
|
|
),
|
|
|
|
body: Center(
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
|
|
children: <Widget>[
|
|
|
|
const SizedBox(
|
|
|
|
height: 150,
|
|
|
|
child: Text(
|
|
|
|
'You have pushed the button this many times:',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
'$_counter',
|
|
|
|
style: Theme.of(context).textTheme.headlineMedium,
|
|
|
|
),
|
|
|
|
TextButton(
|
|
|
|
onPressed: () {
|
|
|
|
Navigator.pushNamed(context,"/media");
|
|
|
|
},
|
|
|
|
child: const Text("to media"),
|
|
|
|
),
|
|
|
|
|
|
|
|
TextButton(
|
|
|
|
onPressed: () {
|
|
|
|
Navigator.pushNamed(context,"/video");
|
|
|
|
},
|
|
|
|
child: const Text("to video"),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
|
|
|
|
floatingActionButton: FloatingActionButton(
|
|
|
|
tooltip: 'Increment',
|
|
|
|
onPressed: () {},
|
|
|
|
child: GestureDetector(
|
|
|
|
onLongPressStart: (_) {
|
|
|
|
timer?.cancel();
|
|
|
|
Timer.periodic(const Duration(milliseconds: 10), (timer) {
|
|
|
|
this.timer = timer;
|
|
|
|
_incrementCounter();
|
|
|
|
});
|
|
|
|
debugPrint("onLongPressStart");
|
|
|
|
},
|
|
|
|
onLongPressEnd: (_) {
|
|
|
|
timer?.cancel();
|
|
|
|
debugPrint("onLongPressEnd");
|
|
|
|
},
|
|
|
|
onLongPress: () {
|
|
|
|
debugPrint("onLongPress");
|
|
|
|
},
|
|
|
|
onTap: () {
|
|
|
|
_incrementCounter();
|
|
|
|
debugPrint("onTap");
|
|
|
|
},
|
|
|
|
child: const Icon(Icons.add),
|
|
|
|
),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|