Coder Social home page Coder Social logo

Comments (19)

SankethBK avatar SankethBK commented on July 1, 2024 2

If you don't use GetMaterialApp this isn't a problem for me.

Cool, I'll raise the fix in 1-2 hours you can test if it solves your issue

from local_session_timeout.

SankethBK avatar SankethBK commented on July 1, 2024 2

Cool, I have released the next version 2.3.2 with this bug fix

from local_session_timeout.

SankethBK avatar SankethBK commented on July 1, 2024 1

Fyi to reference package from github, add this in your pubspec.yaml

 local_session_timeout:
    git:
      url: https://github.com/SankethBK/local_session_timeout.git
      ref: 44d876f19667100e552a65ee672694939b7ed298 

and run flutter pub get

from local_session_timeout.

FullstackWEB-developer avatar FullstackWEB-developer commented on July 1, 2024 1

Brilliant!
It's working well now.
Thank you for your help.

from local_session_timeout.

SankethBK avatar SankethBK commented on July 1, 2024

When I call this code sessionStateStream.add(SessionState.startListening) my app refreshes and redirects to the first page.

Is it because of userInactivityTimeout or appFocusTimeout? you can print the timeoutEvent here

     if (timeoutEvent == SessionTimeoutState.userInactivityTimeout) {
        // logout logic
      } else if (timeoutEvent == SessionTimeoutState.appFocusTimeout) {
        // logout logic
      }

where are you calling startListening defined in SessionStateController?

from local_session_timeout.

FullstackWEB-developer avatar FullstackWEB-developer commented on July 1, 2024

Hi @SankethBK
Thank you for your reply.

Is it because of userInactivityTimeout or appFocusTimeout? you can print the timeoutEvent here

No, it's only for the sessionStateController.startListening();.

where are you calling startListening defined in SessionStateController?

After logging in to My Project, the dashboard page opens.
So I tried adding it to this part of the dashboard page, but the project structure is completely redrawn and it returns to the initial state when I started the app.

class _DashboardScreenState extends State<DashboardScreen> {
  @override
  void initState() {
    final sessionStateController = Get.put(SessionStateController());
    WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
      sessionStateController.startListening();
    });

    SystemChrome.setPreferredOrientations([
      DeviceOrientation.portraitUp,
    ]);
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
     ...
  }

from local_session_timeout.

FullstackWEB-developer avatar FullstackWEB-developer commented on July 1, 2024

image
When I debug, it goes to this part and then redraws, so I don't think this is because of Getx.
I am new to this package, are there any other use cases using this package and Getx?

from local_session_timeout.

SankethBK avatar SankethBK commented on July 1, 2024

Hi @FullstackWEB-developer , ideally calling setState in the package should not cause rebuilds in child. But I think since you're using GetX for MaterialApp, the child widget is no longer treated as a const widget and rebuilds the entire widget tree

from local_session_timeout.

SankethBK avatar SankethBK commented on July 1, 2024

Can you try replacing GetMaterialApp with MaterialApp widget to confirm if this is the issue

from local_session_timeout.

FullstackWEB-developer avatar FullstackWEB-developer commented on July 1, 2024

Hi @FullstackWEB-developer , ideally calling setState in the package should not cause rebuilds in child. But I think since you're using GetX for MaterialApp, the child widget is no longer treated as a const widget and rebuilds the entire widget tree

So how can I fix this?
Shouldn't I use Getx?

Can you try replacing GetMaterialApp with MaterialApp widget to confirm if this is the issue

Let me try but in my project I need to use GetMaterialApp

from local_session_timeout.

SankethBK avatar SankethBK commented on July 1, 2024

So how can I fix this?
Shouldn't I use Getx?

I mean just to confirm if this is the bug. If using MaterialApp directly solves this issue, I'll raise the fix for this, instead of calling setState in my package, I'll handle it inside _recordPointerEvents function without calling setState

from local_session_timeout.

FullstackWEB-developer avatar FullstackWEB-developer commented on July 1, 2024

If I don't use GetMaterialApp this isn't a problem.
But I am not sure how to integrate with Getx without using GetMaterialApp.

from local_session_timeout.

FullstackWEB-developer avatar FullstackWEB-developer commented on July 1, 2024

Thanks

from local_session_timeout.

SankethBK avatar SankethBK commented on July 1, 2024

Try using this commit of the package 44d876f19667100e552a65ee672694939b7ed298, I have removed the setState that fires immediately after calling startListening. If it works I'll remove all setStates they aren't necessary anyway

from local_session_timeout.

FullstackWEB-developer avatar FullstackWEB-developer commented on July 1, 2024

Ok
Let me check soon

from local_session_timeout.

SankethBK avatar SankethBK commented on July 1, 2024

I assume other setStates might be still causing same issue, can you confirm once

from local_session_timeout.

FullstackWEB-developer avatar FullstackWEB-developer commented on July 1, 2024

Yes
I checked it
image
When debugging, these setStates were called, but re-rendering did not occur.
It's currently working well.
Nothing has changed on my end.

from local_session_timeout.

SankethBK avatar SankethBK commented on July 1, 2024

Great! can you check if it works with this commit as well 9bf30e872b3f8c1a7e662307a3ebbbf2f0598b86, i have removed all setStates none of the expected functionality seems to break, if it works well in your case also I'll make a new release with these changes

from local_session_timeout.

FullstackWEB-developer avatar FullstackWEB-developer commented on July 1, 2024

I tested it and it also working now

from local_session_timeout.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.