-
Notifications
You must be signed in to change notification settings - Fork 15
/
main.dart
59 lines (50 loc) · 1.47 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
import 'package:djangoflow_app_links/djangoflow_app_links.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
final appLinksRepository = AppLinksRepository();
final initialLink = await appLinksRepository.getInitialLink();
runApp(
BlocProvider(
create: (context) => AppLinksCubit(
initialLink,
appLinksRepository,
),
child: MaterialApp(
routes: {
'/': (context) => const _HomePage(),
'/primary': (context) => const _PrimaryPage(),
'/secondary': (context) => const _SecondaryPage(),
},
),
),
);
}
class _HomePage extends StatelessWidget {
const _HomePage();
@override
Widget build(BuildContext context) => AppLinksCubitListener(
listener: (context, state) {
if (state == null) return;
Navigator.of(context).pushNamed(state.path);
},
child: Scaffold(
appBar: AppBar(title: const Text('Home Page')),
),
);
}
class _PrimaryPage extends StatelessWidget {
const _PrimaryPage();
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(title: const Text('Primary Page')),
);
}
class _SecondaryPage extends StatelessWidget {
const _SecondaryPage();
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(title: const Text('Secondary Page')),
);
}