-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.dart
73 lines (67 loc) · 2.11 KB
/
main.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:device_preview/device_preview.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:cinemate/views/theme/theme.dart';
import 'package:cinemate/constants/strings.dart';
import 'package:cinemate/services/shared_preferences.dart';
import 'package:cinemate/views/screens/home_screen/home_screen.dart';
import 'package:cinemate/views/screens/on_boarding_screens/on_boarding_screen.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// ByteData data =
// await PlatformAssetBundle().load('assets/ca/lets-encrypt-r3.pem');
// SecurityContext.defaultContext
// .setTrustedCertificatesBytes(data.buffer.asUint8List());
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
]).then((value) =>runApp(
DevicePreview(
enabled: false,
builder: (context) => const ProviderScope(
child: MyApp(),
), // Wrap your app
),
),
);
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
Future<Widget> checkIfOpenedBefore() async {
bool openedBefore = await SharedPreferenceServiceImpl().ifOpenedBefore();
if (openedBefore) {
return const HomeScreen();
} else {
return const OnBoardingPage();
}
}
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
// ignore: deprecated_member_use
useInheritedMediaQuery: true,
locale: DevicePreview.locale(context),
builder: DevicePreview.appBuilder,
title: appName,
theme: theme(),
home: FutureBuilder(
future: checkIfOpenedBefore(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return snapshot.data as Widget;
} else {
return const Center(
child: CircularProgressIndicator(
color: darkAccent,
),
);
}
},
),
);
}
}