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 (complex apps)
Convert the final 12 multi-screen apps to the validated pattern: lib/main.dart keeps only the MaterialApp bootstrap (plus firebase init where that is genuine bootstrap), and a new lib/example.dart holds the entry screen and focused example code, importing existing supporting files. firebase_crash keeps its runZonedGuarded bootstrap in main.dart and extracts only CrashApp. Apps: bmi_calculator, covid19_mobile_app, expense_planner, firebase_crash_reporting, firebase_google_authentication, lunch_app, navigation_drawer, news_memes_app, save_data_locally_with_sqlite, todo_list_using_provider, unit_testing, using_firebase_db
This commit is contained in:
13
navigation_drawer/lib/example.dart
Normal file
13
navigation_drawer/lib/example.dart
Normal file
@@ -0,0 +1,13 @@
|
||||
// Example: A home screen with a navigation drawer to switch between settings and account screens.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:navigation_drawer/screens/home.dart';
|
||||
|
||||
class Example extends StatelessWidget {
|
||||
const Example({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const HomeScreen();
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,25 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:navigation_drawer/example.dart';
|
||||
import 'package:navigation_drawer/screens/account.dart';
|
||||
import 'package:navigation_drawer/screens/home.dart';
|
||||
import 'package:navigation_drawer/screens/settings.dart';
|
||||
|
||||
void main() {
|
||||
runApp(MaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
home: HomeScreen(), // route for home is '/' implicitly
|
||||
routes: <String, WidgetBuilder>{
|
||||
// define the routes
|
||||
SettingsScreen.routeName: (BuildContext context) => SettingsScreen(),
|
||||
AccountScreen.routeName: (BuildContext context) => AccountScreen(),
|
||||
},
|
||||
));
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
home: const Example(), // route for home is '/' implicitly
|
||||
routes: <String, WidgetBuilder>{
|
||||
// define the routes
|
||||
SettingsScreen.routeName: (BuildContext context) => SettingsScreen(),
|
||||
AccountScreen.routeName: (BuildContext context) => AccountScreen(),
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user