// Example: Stateless widget counter using MobX import 'package:flutter/material.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; import 'counter.dart'; // Import the Counter final counter = Counter(); // Instantiate the store class Example extends StatelessWidget { const Example({super.key}); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('MobX Stateless Widget Counter'), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'You have pushed the button this many times:', ), // Wrapping in the Observer will automatically re-render on changes to counter.value Observer( builder: (_) => Text( '${counter.value}', style: Theme.of(context).textTheme.headlineSmall, ), ), ], ), ), floatingActionButton: FloatingActionButton( onPressed: counter.increment, tooltip: 'Increment', child: Icon(Icons.add), ), ); } }