Open LWY6670 opened 3 years ago
I was using the official example in \bitsdojo_window\example\
Do you think you could record a video of this?
OK. But I don't know where can I put the video.
May be you could leave me a email address
Mine email is LWY6670@163.com, you can tell me yours, in an email to me.
Any file storage service like OneDrive or Google Drive that can create a public link would work for uploading the video.
It's not easy for me. I am in china.
Can you record a video and drag it on this page here when writing a reply?
OK. I will have a try.
Uploading BLACK BLOCK-issue.mp4…
Please try running the same tests (moving the window outside of the screen) using a normal Flutter app created using flutter create sample_app
and let me know if you see the black blocks.
For a official Flutter sample, the BLACK block INDEED appeared TOO, althought it would be automatically fixed in ONE sec. And when it was restored from minimized, it worked ok.
你好,我也遇到类似的问题,把窗口一部分拖到屏幕区域外后最大化,恢复窗口大小,再拖会屏幕区域内,会出现一大块黑色区域,这是flutter的bug吧?
Might not be the best solution, but this works for me: Define two variables in your main.dart and turn the main widget into a stateful widget (by default it is stateless):
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
_MyApp createState() => _MyApp();
}
class _MyApp extends State<MyApp> {
late Timer restoreTimerForRefresh;
bool _isMinimized = false;
...
Then implement this code in initState
and dispose
:
@override
void initState() {
super.initState();
restoreTimerForRefresh = Timer.periodic(const Duration(milliseconds: 100), (timer) {
if (appWindow.size < appWindowSize) {
_isMinimized = true;
}
if (appWindow.size >= appWindowSize) {
if (_isMinimized) {
setState(() {});
}
_isMinimized = false;
}
});
}
@override
void dispose() {
super.dispose();
restoreTimerForRefresh.cancel();
}
appWindowSize
is defined as the minimum size of the window:
Size appWindowSize = const Size(400, 700);
void main(List<String> args) {
WidgetsFlutterBinding.ensureInitialized();
runApp(const MyApp());
doWhenWindowReady(() {
final win = appWindow;
win.size = appWindowSize;
win.minSize = appWindowSize;
win.show();
});
}
The timer tracks the window size (which is smaller then minSize
if the window is minimized) and on restore (size
is greater or equal appWindowSize
), it calls setState
which forces a re-render and hence removes the "black canvas".
Hope, this helps someone. If we would have a onRestore listener like promised in #95, then setState
could be called in the callback. But at the moment, there is no listener.
On my Win10:
All app area will be BLACK after restored from minimized.
BLACK block appeared: after I adjusted the app border to make it larger when some part was off the screen, I drag it back to the center of the screen, the enlarged part of the off-screen part will not be rendered.
Still BLACK gap rendering issue when I am using 2 screens which have a gap in between: after restored from maximized, the app will span over 2 screens, move the position of the app, you will find the BLACK gap.