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

Adjustment in the sample code in the readme of all languages #820

Merged

Conversation

eduardoflorence
Copy link
Collaborator

  • Change to the readme sample code, in the "Counter App with GetX" section

Before:

class Home extends StatelessWidget {
  final Controller c = Get.put(Controller());
  @override
  Widget build(context) => Scaffold(
      ...  

After:

class Home extends StatelessWidget {
  @override
  Widget build(context) {
    final Controller c = Get.put(Controller());
    return Scaffold(
        ...
  • Motivation: Avoid issues of beginners who do not use named routes. If Get.put is placed before the build method, onInit/onReady/onClose are not called and when navigating to another route the controller is not removed from memory

  • Referência: Why Controller can't close #384 (comment)

@jonataslaw
Copy link
Owner

Thank you, you're right
LGTM

@jonataslaw jonataslaw merged commit c296f4e into jonataslaw:master Nov 26, 2020
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

Successfully merging this pull request may close these issues.

3 participants