-
Notifications
You must be signed in to change notification settings - Fork 4
/
AppConfigurator.dart
53 lines (45 loc) · 1.23 KB
/
AppConfigurator.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
//
// Created by dyf on 2018/9/7.
// Copyright (c) 2018 dyf.
//
import 'dart:io';
import 'package:flutter/material.dart';
class AppConfigurator {
final String name;
static final Map<String, AppConfigurator> _cache =
<String, AppConfigurator>{};
factory AppConfigurator(String name) {
if (_cache.containsKey(name)) {
return _cache[name];
} else {
final inst = AppConfigurator._internal(name);
_cache[name] = inst;
return inst;
}
}
AppConfigurator._internal(this.name);
TargetPlatform _getTargetPlatform() {
var targetPlatform = TargetPlatform.iOS;
if (Platform.isAndroid) {
targetPlatform = TargetPlatform.android;
}
return targetPlatform;
}
TextTheme _getBlackTextTheme() {
return Typography(platform: _getTargetPlatform()).black;
}
AppBar createAppBar({Widget title, bool autoImplyLeading: true, List<Widget> actions}) {
return new AppBar(
title: title,
backgroundColor: Colors.white,
iconTheme: IconThemeData(
color: Colors.black
),
textTheme: _getBlackTextTheme(),
elevation: 1.0,
brightness: Brightness.light,
automaticallyImplyLeading: autoImplyLeading,
actions: actions,
);
}
}