aagnia_base_package 0.0.45 aagnia_base_package: ^0.0.45 copied to clipboard
Flutter base component. Which is include all the basic screen and the details. If the user import the package they will use all the basic needs.
import 'dart:async';
import 'package:example/Constants/AppStrings.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'Constants/AppColors.dart';
import 'Screen/SplashScreen.dart';
import 'package:example/Screen/SignUpScreen.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runZoned<Future<void>>(() async {
runApp(new MyApp());
});
}
class MyApp extends StatelessWidget {
//var fsconnect = FirebaseFirestore.instance;
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: AppStrings.APP_NAME,
theme: ThemeData(
primarySwatch: Colors.deepPurple,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: SplashScreen(),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
MyHomePageState createState() => MyHomePageState();
}
class MyHomePageState extends State<MyHomePage> {
static String user_name = "";
static String user_email = "";
static bool user_emailVerified = false;
static String user_imageUrl = "";
static String user_token = "";
static String user_uid = "";
Future<String> isLoggedIn() async {
await getPrefs();
}
final routes = <String, WidgetBuilder>{
/* SignUpScreen.tag: (BuildContext context) => SignUpScreen(),
DashBoardScreen.tag: (BuildContext context) => DashBoardScreen(),*/
};
static Future getPrefs() async {
//Store the shared pref value here
user_name = SignUpScreenState.user_name;
if (user_name != null) {
}
}
@override
Widget build(BuildContext context) {
return new FutureBuilder(
future: isLoggedIn(),
builder: (BuildContext context, AsyncSnapshot<String> snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.waiting:
return Center(child: new Container());
default:
if (snapshot.hasError)
return new Text('Error: ${snapshot.error}');
else {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData.light().copyWith(
primaryColor: AppColors.APP_COLOR_PRIMARY,
primaryColorDark: AppColors.APP_COLOR_PRIMARY,
textTheme: Theme.of(context)
.textTheme
.apply(fontFamily: 'NotoSans')),
home: getHomeWidget(),
routes: routes,
);
}
}
});
}
Widget getHomeWidget() {
return SplashScreen();
}
}