Main Screen
(Main.dart):
Screen Description:
Man hours:15 mins
Code:
import ‘package:flutter/material.dart’;
import ‘package:firebase_core/firebase_core.dart’;
import ‘package:tis_root01/Screens/Login.dart’;
import ‘package:tis_root01/Screens/add_member.dart’;
import ‘package:tis_root01/dash.dart’;
import ‘package:tis_root01/common/CommonFooter.dart’;
import ‘package:tis_root01/common/CommonHeader.dart’;
import ‘package:tis_root01/otp.dart’;
import ‘package:tis_root01/Screens/Login.dart’;
void main() async {
// Ensure Flutter is initialized for the app.
WidgetsFlutterBinding.ensureInitialized();
// Initialize Firebase with project configuration.
await Firebase.initializeApp(
options: FirebaseOptions(
apiKey: “<YOUR_API_KEY>”,
authDomain: “<YOUR_AUTH_DOMAIN>”,
projectId: “<YOUR_PROJECT_ID>”,
storageBucket: “<YOUR_STORAGE_BUCKET>”,
messagingSenderId: “<YOUR_MESSAGING_SENDER_ID>”,
appId: “<YOUR_APP_ID>”,
measurementId: “<YOUR_MEASUREMENT_ID>”,
),
);
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: ‘TIS_ROOT’,
// Define the app’s theme.
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const LoginScreen(),
);
}
}
Code Description:
- Import statements to include the necessary Flutter and Firebase libraries and custom widget imports.The firebase_auth library is used for Firebase Authentication.The cloud_firestore library is used for Firestore database interactions.Widgets like Footer and FooterView are used for creating a footer section.
- main Function:
This is the entry point of the Flutter application.
WidgetsFlutterBinding.ensureInitialized(); ensures that Flutter is initialized before the app starts.
- Firebase Initialization:
await Firebase.initializeApp(…) initializes Firebase using the provided configuration options.
Replace the placeholder values (“<YOUR_API_KEY>”, “<YOUR_AUTH_DOMAIN>”, etc.) with the actual Firebase project configuration values.
- MyApp Class:
This is the root of the Flutter app and extends StatelessWidget.
The build method configures the overall appearance and behavior of the app.
The app’s title and theme are set in the MaterialApp widget.
- MaterialApp Widget:
This widget represents the root of your app’s widget tree.
The app’s title is set to ‘TIS_ROOT’.
The theme is configured with a primary color swatch (blue in this case).
- home Property:
Specifies the initial route or screen of the app, in this case, the LoginScreen
Audit :