main.dart 1.86 KB
Newer Older
1
import 'package:flutter/cupertino.dart';
2
3
import 'package:flutter/material.dart';
import 'package:device_preview/device_preview.dart';
4
import 'package:flutter_localizations/flutter_localizations.dart';
5
import 'package:logair_application/controllers/map_display_controller.dart';
6
7
8
9
import 'package:logair_application/handlers/data_handler.dart';
import 'package:logair_application/handlers/network_handler.dart';
import 'package:logair_application/handlers/position_handler.dart';
import 'package:logair_application/handlers/preference_handler.dart';
10
import 'package:logair_application/localization/localization_delegate.dart';
11
import 'package:logair_application/handlers/bluetooth_le_handler.dart';
12
import 'package:logair_application/routes/home.dart';
13

14
// TODO Lang service, initialized with the right locale, where accessible from entire program
15
16

// TODO USED FOR DEBUGGING
17
18
final bool displayMode = false;

19
20
21
22
void main() {
  //debugPrintGestureArenaDiagnostics = true;
  runApp(displayMode ? DevicePreview(child: LogAirApplication()) : LogAirApplication());
}
23

24
class LogAirApplication extends StatelessWidget {
25
26
27
28
29
30
  void _startHandlers() {
    BTLEHandler();
    NetworkHandler();
    DataHandler();
    PreferencesHandler();
    PositionHandler();
31
    MapDisplayController();
32
33
  }

34
  static const String _title = 'LogAir Connector';
35
36
37

  @override
  Widget build(BuildContext context) {
38
    this._startHandlers();
39
    return MaterialApp(
40
      localizationsDelegates: [
41
        const AppLocalizationDelegate(),
42
43
44
45
46
47
48
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
      ],
      supportedLocales: [
        const Locale('en', ''),
        const Locale('fr', ''),
      ],
49
50
51
52
53
54
      builder: displayMode ? DevicePreview.appBuilder : ((_, child) { return child; }),
      title: _title,
      home: HomeView(),
    );
  }
}