```dart
void main() {
  runApp(MyApp());
}

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;

  // Initialize a list for storing posts
  List<Post> _posts = [];

  // Initialize a boolean indicating if the sync process has completed
  bool _isSynced = false;

  // Initialize the libraries
  ...

  void observeQuery() {
    _stream = Amplify.DataStore.observeQuery(
      Post.classType,
      where: Post.TITLE.beginsWith('post') & (Post.RATING > 10),
      sortBy: [Post.RATING.ascending()],
    ).listen((QuerySnapshot<Post> snapshot) {
      setState(() {
        _posts = snapshot.items;
        _isSynced = snapshot.isSynced;
      });
    });
  }

  // Build function and UI elements
  ...

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

```