This repository has been archived by the owner on Jan 1, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0f8580b
commit cce63e8
Showing
9 changed files
with
494 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import 'package:flutter/scheduler.dart'; | ||
import 'package:libtokyo_flutter/libtokyo.dart' hide ColorScheme; | ||
import 'package:libtokyo/libtokyo.dart' hide TokyoApp; | ||
import 'package:provider/provider.dart'; | ||
|
||
import '../logic/display.dart'; | ||
|
||
class Toplevel extends StatefulWidget { | ||
const Toplevel({ | ||
super.key, | ||
required this.toplevel, | ||
}); | ||
|
||
final DisplayServerToplevel toplevel; | ||
|
||
@override | ||
State<Toplevel> createState() => _ToplevelState(); | ||
} | ||
|
||
class _ToplevelState extends State<Toplevel> { | ||
GlobalKey key = GlobalKey(); | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
|
||
SchedulerBinding.instance.addPostFrameCallback((_) { | ||
if (key.currentContext != null && widget.toplevel.texture != null) { | ||
final box = key.currentContext!.findRenderObject() as RenderBox; | ||
widget.toplevel.setSize(box.size.width.toInt(), box.size.height.toInt()); | ||
} | ||
}); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) => | ||
ChangeNotifierProvider( | ||
key: key, | ||
create: (_) => widget.toplevel, | ||
child: Consumer<DisplayServerToplevel>( | ||
builder: (context, toplevel, _) => | ||
toplevel.texture == null | ||
? SizedBox() : Texture( | ||
textureId: toplevel.texture!, | ||
), | ||
), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.