Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can we use the new version with GetX package? #162

Closed
BenCherif opened this issue Nov 7, 2023 · 3 comments
Closed

Can we use the new version with GetX package? #162

BenCherif opened this issue Nov 7, 2023 · 3 comments

Comments

@BenCherif
Copy link

Hi,
i want to migrate to the new version but i don't know how to migrate to be compatible with GetX package.
can you provide an example to use it with GetX package.

@BenCherif
Copy link
Author

any updates?

@BenCherif
Copy link
Author

any updates?

@BenCherif BenCherif reopened this Aug 2, 2024
@Trefa1998
Copy link
Contributor

I've been using it with GetX @BenCherif . What exactly are you concerned about/need clarification with?

If you're using it at the root-level, assuming you're using GetMaterialApp then the example is exactly the same, you just get the builder property to match the example, same as if it were MaterialApp. That appears to work exactly the same for me.

Example:

    GetMaterialApp(
        // ...
        builder: (context, child) => ResponsiveBreakpoints(
          breakpoints: const [
            Breakpoint(start: 0, end: 450, name: MOBILE),
            Breakpoint(start: 451, end: 800, name: TABLET),
            Breakpoint(start: 801, end: 1920, name: DESKTOP),
            Breakpoint(start: 1921, end: double.infinity, name: '4K'),
          ],
          child: Builder(builder: (BuildContext context) {
            child ??= const SizedBox();
            return MaxWidthBox(
              maxWidth: 1200,
              child: ResponsiveScaledBox(
                width: ResponsiveValue<double?>(
                  context,
                  conditionalValues: const [
                    Condition.equals(name: MOBILE, value: 450),
                    Condition.between(start: 800, end: 1100, value: 800),
                    Condition.between(start: 1000, end: 1200, value: 1000),
                    // There are no conditions for width over 1200
                    // because the `maxWidth` is set to 1200 via the MaxWidthBox.
                  ],
                ).value,
                child: BouncingScrollWrapper.builder(
                  context,
                  child!,
                  dragWithMouse: true, // NOTE: This will disable trackpad scrolling on desktop as of v 1.4.0 on pub.dev
                ),
              ),
            );
          }),
        ),
        // ...
      );

And you can use the other GetX stuff like state management and routing like normal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants