remove debug mode delay on Android
This commit is contained in:
@@ -95,7 +95,7 @@ abstract class FilamentController {
|
|||||||
/// 5) The FilamentWidget will replace the empty Container with a Texture widget
|
/// 5) The FilamentWidget will replace the empty Container with a Texture widget
|
||||||
/// If you need to wait until a FilamentViewer has been created, listen to the [viewer] stream.
|
/// If you need to wait until a FilamentViewer has been created, listen to the [viewer] stream.
|
||||||
///
|
///
|
||||||
void createViewer(int width, int height);
|
Future createViewer(int width, int height);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Resize the viewport & backing texture.
|
/// Resize the viewport & backing texture.
|
||||||
|
|||||||
@@ -112,7 +112,8 @@ class FilamentControllerFFI extends FilamentController {
|
|||||||
///
|
///
|
||||||
/// Called by `FilamentWidget`. You do not need to call this yourself.
|
/// Called by `FilamentWidget`. You do not need to call this yourself.
|
||||||
///
|
///
|
||||||
void createViewer(int width, int height) async {
|
@override
|
||||||
|
Future createViewer(int width, int height) async {
|
||||||
if (_viewer != null) {
|
if (_viewer != null) {
|
||||||
throw Exception(
|
throw Exception(
|
||||||
"Viewer already exists, make sure you call destroyViewer first");
|
"Viewer already exists, make sure you call destroyViewer first");
|
||||||
|
|||||||
@@ -71,12 +71,6 @@ class _FilamentWidgetState extends State<FilamentWidget> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
||||||
// when attaching a debugger via Android Studio on startup, this can delay presentation of the widget
|
|
||||||
// (meaning the widget may attempt to create a viewer with size 0x0).
|
|
||||||
// we just add a small delay here which should avoid this
|
|
||||||
if (!kReleaseMode) {
|
|
||||||
await Future.delayed(Duration(seconds: 2));
|
|
||||||
}
|
|
||||||
var size = ((context.findRenderObject()) as RenderBox).size;
|
var size = ((context.findRenderObject()) as RenderBox).size;
|
||||||
_width = size.width.ceil();
|
_width = size.width.ceil();
|
||||||
_height = size.height.ceil();
|
_height = size.height.ceil();
|
||||||
@@ -139,14 +133,11 @@ class _SizedFilamentWidgetState extends State<_SizedFilamentWidget> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
||||||
// when attaching a debugger via Android Studio on startup, this can delay presentation of the widget
|
|
||||||
// (meaning the widget may attempt to create a viewer with size 0x0).
|
|
||||||
// we just add a small delay here which should avoid this
|
|
||||||
if (!kReleaseMode) {
|
if (!kReleaseMode) {
|
||||||
await Future.delayed(Duration(seconds: 2));
|
await Future.delayed(Duration(seconds: 2));
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
widget.controller.createViewer(widget.width, widget.height);
|
await widget.controller.createViewer(widget.width, widget.height);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
_error = err.toString();
|
_error = err.toString();
|
||||||
}
|
}
|
||||||
@@ -264,7 +255,9 @@ class _SizedFilamentWidgetState extends State<_SizedFilamentWidget> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (widget.controller.textureDetails == null || _resizeTimer != null) {
|
if (widget.controller.textureDetails == null || _resizeTimer != null) {
|
||||||
return widget.initial ?? Container(color: Colors.red);
|
return Stack(children: [
|
||||||
|
Positioned.fill(child: widget.initial ?? Container(color: Colors.red))
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
// see [FilamentControllerFFI.resize] for an explanation of how we deal with resizing
|
// see [FilamentControllerFFI.resize] for an explanation of how we deal with resizing
|
||||||
var texture = Texture(
|
var texture = Texture(
|
||||||
|
|||||||
Reference in New Issue
Block a user