Center and zoom out interactiveviewer after loading

Viewed 24

I have an interactiveviewer with about 70 stateful widgets inside of it. I am trying to load the screen with the interactive viewer centered and zoomed out for all of the information to be viewable on opening.

I believe the problem occurs while the widgets are loading information from firebase, I'm not sure how to await this properly to center the interactive viewer.

I've tried wrapping in centers, containers, and using a transformation controller. The transformation controller will save the last place you were viewing if you switch back from another page but it still opens at the top left of the interactive viewer the first time.

My interactive viewer screen code:

return Center(
      child: InteractiveViewer(
        transformationController: viewTransformationController,
        boundaryMargin: EdgeInsets.all(dwh * 300),
        maxScale: 2,
        minScale: .01,
        constrained: false,
        child: SingleChildScrollView(
          scrollDirection: Axis.vertical,
          child: Container(
            decoration: const BoxDecoration(
              color: Color(0xFF000000),
            ),
            child: Column(
              children: [
                SizedBox(
                  child: Column(
                    children: [
                      Row(children: [
                        Column(
                          children: [
                            Row(

and my widget's code:

return StreamBuilder<DocumentSnapshot>(
    stream: _warehouseStream,
    builder: (BuildContext context, snapshot) {
      if (snapshot.hasError) {
        return const Text('Something went wrong');
      }
      if (snapshot.connectionState == ConnectionState.waiting) {
        return const Center(
            child: Text(
          '.',
          style: TextStyle(color: buttonColor),
        ));
      }

      if (!snapshot.hasData) {
        return const Center(
            child: Text(
          '.',
          style: TextStyle(color: buttonColor),
        ));
      }

      return SizedBox(
0 Answers
Related