-
Notifications
You must be signed in to change notification settings - Fork 122
/
text_field_overlay.dart
54 lines (49 loc) · 1.41 KB
/
text_field_overlay.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:flutter_overlay_window/flutter_overlay_window.dart';
class TextFieldOverlay extends StatefulWidget {
const TextFieldOverlay({Key? key}) : super(key: key);
@override
State<TextFieldOverlay> createState() => _TextFieldOverlayState();
}
class _TextFieldOverlayState extends State<TextFieldOverlay> {
@override
void initState() {
super.initState();
FlutterOverlayWindow.overlayListener.listen((event) {
log("$event");
});
}
@override
Widget build(BuildContext context) {
return Focus(
onFocusChange: (hasFocus) async {
if (hasFocus) {
await FlutterOverlayWindow.updateFlag(OverlayFlag.focusPointer);
} else {
await FlutterOverlayWindow.updateFlag(OverlayFlag.defaultFlag);
}
},
child: Scaffold(
body: SafeArea(
child: Center(
child: Column(
children: [
const TextField(
decoration: InputDecoration(hintText: "Write anything"),
),
const SizedBox(height: 50.0),
TextButton(
onPressed: () {
FlutterOverlayWindow.closeOverlay();
},
child: const Text("Close Overlay"),
)
],
),
),
),
),
);
}
}