Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 18, 2025

The Serverpod template changed from a StatefulWidget-based MyHomePage to a StatelessWidget-based MyApp. The getting started guide assumed the StatefulWidget already existed, causing confusion for new users.

Changes

  • docs/01-get-started/01-creating-endpoints.md (current and v3.1.0)
    • Updated section introduction to clarify that users must introduce a StatefulWidget
    • Added complete MyHomePage widget declaration before MyHomePageState

Before

class MyHomePageState extends State<MyHomePage> {
  // ... implementation
}

After

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  MyHomePageState createState() => MyHomePageState();
}

class MyHomePageState extends State<MyHomePage> {
  // ... implementation
}

This aligns with the pattern already used in 02-models-and-data.md.

Original prompt

We recently updated out template to go from this:

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  MyHomePageState createState() => MyHomePageState();
}

class MyHomePageState extends State<MyHomePage> {
  bool _isSignedIn = false;

  @override
  void initState() {
    super.initState();
    client.auth.authInfoListenable.addListener(_updateSignedInState);
    _isSignedIn = client.auth.isAuthenticated;
  }

  @override
  void dispose() {
    client.auth.authInfoListenable.removeListener(_updateSignedInState);
    super.dispose();
  }

  void _updateSignedInState() {
    setState(() {
      _isSignedIn = client.auth.isAuthenticated;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text(widget.title)),
      body: _isSignedIn ? const ConnectedScreen() : const SignInScreen(),
    );
  }
}

to this:

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Serverpod Demo',
      theme: ThemeData(primarySwatch: Colors.blue),
      home: const MyHomePage(title: 'Serverpod Example'),
    );
  }
}

Now the get started guide needs to be updated to reflect this change in the Call the endpoint from client section: https://docs.serverpod.dev/get-started/creating-endpoints#call-the-endpoint-from-the-client

Could you create a PR to update the code example and the intial description there for version 3.1.x and current? Just so that the guide is connected. I think the statefull widget needs to be introduced now for the scenario mentioned.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…started guide

Co-authored-by: SandPod <137198655+SandPod@users.noreply.github.com>
Copilot AI changed the title [WIP] Update home page template structure Update getting started guide to include MyHomePage StatefulWidget declaration Dec 18, 2025
Copilot AI requested a review from SandPod December 18, 2025 15:01
@vlidholt vlidholt changed the title Update getting started guide to include MyHomePage StatefulWidget declaration fix: Update getting started guide to include MyHomePage StatefulWidget declaration Dec 18, 2025
@vlidholt vlidholt marked this pull request as ready for review December 18, 2025 15:09
Copy link
Contributor

@vlidholt vlidholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vlidholt vlidholt merged commit 494e641 into main Dec 18, 2025
4 of 8 checks passed
@vlidholt vlidholt deleted the copilot/update-home-page-template branch December 18, 2025 15:27
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