navigationBarWithScreenshot method Null safety

dynamic navigationBarWithScreenshot(
  1. String title,
  2. bool goBack,
  3. bool screenshot,
  4. BuildContext context,
  5. ScreenshotController screenshotController,
  6. ScreenshotController screenshotControllerr
)

Creates a navigation bar that contains a title, if there should be a goBack button or not and if there should be a screenshot button or not.

Returns a Center widget.

Implementation

static navigationBarWithScreenshot(String title, bool goBack, bool screenshot, BuildContext context, ScreenshotController screenshotController, ScreenshotController screenshotControllerr) {
  SizedBox logoutButton = SizedBox(
    width: Sizes.getPixelSizeWidth(0.2430724356, context),
  );
  SizedBox goBackButton = SizedBox(
    width: Sizes.getPixelSizeWidth(0.2430724356, context),
  );
  if(screenshot){
    logoutButton = SizedBox(
        height: Sizes.getPixelSize(0.0576435324, context),
        width: Sizes.getPixelSizeWidth(0.2430724356, context),
        child: GestureDetector(
          onTap: () async {
            final image = await screenshotControllerr.capture();
            if(image == null)return;
            await saveImage(image);
            saveAndShare(image);
          },
          child: Image(image: const AssetImage('assets/icons/screenshotIcon.png'), width: Sizes.getPixelSizeWidth(0.2430724356, context), height: Sizes.getPixelSize(0.0576435324, context)),
        )
    );
  }

  if(goBack){
    goBackButton = SizedBox(
        height: Sizes.getPixelSize(0.0576435324, context),
        width: Sizes.getPixelSizeWidth(0.2430724356, context),
        child: GestureDetector(
          onTap: () {Navigator.push(context, MaterialPageRoute(builder: (context) {
            return const MainMenuPage(title: 'MainMenu');
          }));},
          child: Image(image: const AssetImage('assets/icons/goBackIcon.png'), width: Sizes.getPixelSizeWidth(0.1215362178, context), height: Sizes.getPixelSize(0.0576435324, context)),
        )
    );
  }


  return Center(
    child: Column(
        children: [
          SizedBox(
            height: Sizes.getPixelSize(0.0576435324, context),
          ),
          Row(
            children: [
              goBackButton,
              Expanded(child: Center(child: SizedBox(
                height: Sizes.getPixelSize(0.0576435324, context),
                child: Text(title, style: (Sizes.getScreenSize(context).width > 400) ? Theme.of(context).textTheme.headline6: Theme.of(context).textTheme.headline6),
              ))),
              logoutButton
            ],
          ),
          SizedBox(
            height: Sizes.getPixelSize(0.02305741296, context),
          ),
          SizedBox(
            height: 1,
            width: Sizes.getScreenSize(context).width * 0.8,
            child: const DecoratedBox(
              decoration: BoxDecoration(
                  color: Colors.white
              ),
            ),
          )
        ]
    ),
  );
}