1
0
mirror of https://github.com/nisrulz/flutter-examples.git synced 2026-08-25 01:05:36 +00:00

refactor: split app wrapper from focused example code (multi-file apps)

Convert 17 multi-file apps to the validated pattern: lib/main.dart keeps
only the MaterialApp bootstrap; a new lib/example.dart holds the full entry
screen and focused example code, importing existing supporting files
(screens/, tabs/, services/, models/, widgets/, utils/).

Apps: analytics_integration, animation_example, biometrics, bottom_sheet,
custom_home_drawer, google_signin, grid_layout, handling_routes,
image_editor, scan_qr_code, statless_counter_app, using_bottom_nav_bar,
using_custom_fonts, using_listview, using_listwheelscrollview,
using_platform_adaptive, view_pdf_file
This commit is contained in:
Nishant Srivastava
2026-08-18 00:48:50 +02:00
parent 780c0f1dbb
commit 6e3ff94bfe
34 changed files with 1002 additions and 766 deletions

View File

@@ -0,0 +1,42 @@
// 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: <Widget>[
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),
),
);
}
}

View File

@@ -1,11 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'counter.dart'; // Import the Counter
import 'example.dart';
final counter = Counter(); // Instantiate the store
void main() => runApp(MyApp());
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@@ -19,42 +16,7 @@ class MyApp extends StatelessWidget {
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(),
home: const Example(),
);
}
}
class MyHomePage extends StatelessWidget {
const MyHomePage({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: <Widget>[
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),
),
);
}
}