|
- import 'dart:async';
- import 'dart:io';
- import 'package:flutter/material.dart';
- import 'package:flutter/services.dart';
- import 'package:http/http.dart';
- import 'package:unitstocks/Util/Prefs.dart';
- import 'package:unitstocks/login_page.dart';
- import 'home_page.dart';
- import 'stocking.dart';
- import 'unit_details.dart';
- import 'package:shared_preferences/shared_preferences.dart';
- import 'package:location/location.dart';
- import 'Util/Util.dart';
-
-
- SharedPreferences prefs;
- Location location = Location();
- StreamSubscription locationStream;
- LocationData currentPosisiton;
- Util util = new Util();
- Client http = new Client();
- SecurityContext clientContext;
-
- registerCert()async{
- ByteData bytes = await rootBundle.load('cert/isrgrootx1.pem');
- clientContext = new SecurityContext()
- ..setTrustedCertificatesBytes(bytes.buffer.asUint8List());
- }
-
- void main() async{
- WidgetsFlutterBinding.ensureInitialized();
- prefs = await SharedPreferences.getInstance();
- await registerCert();
- if( prefs.getString(keyClass.hostAddress) ==null)await prefs.setString(keyClass.hostAddress, "https://tbg.thamringroup.web.id/ords/tbs/unit/v1");
- await prefs.setString(keyClass.restTokenAddress, "https://tbg.thamringroup.web.id/ords/tbs/oauth/token");
- SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp])
- .then((_) {
- runApp(new MyApp());
- });
- }
-
- class MyApp extends StatelessWidget {
- @override
- Widget build(BuildContext context) {
- return MaterialApp(
- title: 'Unit Stock',
- theme: ThemeData(
- pageTransitionsTheme: PageTransitionsTheme(
- builders: {
- TargetPlatform.iOS: CupertinoPageTransitionsBuilder(),
- }
- ),
- primarySwatch: Colors.indigo,
- ),
- debugShowCheckedModeBanner: false,
-
- home: (prefs.getBool(keyClass.logged_in)??false)?HomePage(title:'Home Page'):LoginPage(),
- routes: {
- '/home': (context) => new HomePage(title:'Home Page'),
- '/stocking' : (context) => new Stocking(),
- '/unitdetails' : (context) => new UnitDetails(),
- '/login' :(context) => new LoginPage(),
- },
- );
- }
- }
|