```dart
class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  StreamSubscription<QuerySnapshot<Post>>? _stream;

  // A reference to the retrieved post
  late Post _post;

  @override
  void initState() {
    super.initState();
    _configure();
  }
  
  // Initialize the Amplify libraries and call `observeQuery`
  Future<void> _configure() async {
    // ...
  }
  ...

  void observeQuery() {
    _stream = Amplify.DataStore.observeQuery(
      Post.classType,
      where: Post.ID.eq('123')
    ).listen((QuerySnapshot<Post> snapshot) {
      setState(() {
        _post = snapshot.items.first;
      });
    });
  }

  Future<void> updatePost(String newTitle) async {
      final updatedPost = _post.copyWith(title: newTitle);
      await Amplify.DataStore.save(updatedPost);

      // you do not need to explicitly set _post here; observeQuery will see
      // the update and set the variable.
  }

  // Build function and UI elements
  ...

  @override
  void dispose() {
    _stream?.cancel();
    super.dispose();
  }
}

```
