seems timer not work well, will try https://github.com/hanxu317317/flutter_plan_demo/blob/master/lib/src/enter.dart
This commit is contained in:
parent
190dc6006c
commit
cc0139a85c
@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'common.dart';
|
import 'common.dart';
|
||||||
import 'home_page.dart';
|
import 'home_page.dart';
|
||||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
runApp(App());
|
runApp(App());
|
||||||
@ -20,7 +19,7 @@ class App extends StatelessWidget {
|
|||||||
primarySwatch: Colors.blue,
|
primarySwatch: Colors.blue,
|
||||||
visualDensity: VisualDensity.adaptivePlatformDensity,
|
visualDensity: VisualDensity.adaptivePlatformDensity,
|
||||||
),
|
),
|
||||||
home: FlutterEasyLoading(child: HomePage(title: 'RustDesk')),
|
home: HomePage(title: 'RustDesk'),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,8 @@ import 'package:flutter/material.dart';
|
|||||||
import 'common.dart';
|
import 'common.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'dart:ui' as ui;
|
import 'dart:ui' as ui;
|
||||||
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
class RemotePage extends StatefulWidget {
|
class RemotePage extends StatefulWidget {
|
||||||
RemotePage({Key key, this.id}) : super(key: key);
|
RemotePage({Key key, this.id}) : super(key: key);
|
||||||
@ -12,20 +14,42 @@ class RemotePage extends StatefulWidget {
|
|||||||
_RemotePageState createState() => _RemotePageState();
|
_RemotePageState createState() => _RemotePageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/hanxu317317/flutter_plan_demo/blob/master/lib/src/enter.dart
|
||||||
class _RemotePageState extends State<RemotePage> {
|
class _RemotePageState extends State<RemotePage> {
|
||||||
|
Timer _interval;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
FFI.connect(widget.id);
|
FFI.connect(widget.id);
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
showLoading("Connecting...");
|
||||||
|
_interval =
|
||||||
|
Timer.periodic(Duration(milliseconds: 30), (timer) => interval());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
_interval.cancel();
|
||||||
|
dismissLoading();
|
||||||
|
FFI.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void interval() {
|
||||||
|
print(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
// Size size = MediaQueryData.fromWindow(ui.window).size;
|
||||||
// https://stackoverflow.com/questions/46640116/make-flutter-application-fullscreen
|
// https://stackoverflow.com/questions/46640116/make-flutter-application-fullscreen
|
||||||
SystemChrome.setEnabledSystemUIOverlays([]);
|
SystemChrome.setEnabledSystemUIOverlays([]);
|
||||||
return CustomPaint(
|
return FlutterEasyLoading(
|
||||||
|
child: CustomPaint(
|
||||||
painter: new ImageEditor(image: null),
|
painter: new ImageEditor(image: null),
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,12 +62,12 @@ class ImageEditor extends CustomPainter {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void paint(Canvas canvas, Size size) {
|
void paint(Canvas canvas, Size size) {
|
||||||
if (image = null) return;
|
if (image == null) return;
|
||||||
canvas.drawImage(image, new Offset(0.0, 0.0), new Paint());
|
canvas.drawImage(image, new Offset(0.0, 0.0), new Paint());
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool shouldRepaint(CustomPainter oldDelegate) {
|
bool shouldRepaint(CustomPainter oldDelegate) {
|
||||||
return false;
|
return oldDelegate != this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user