This commit is contained in:
sanfan.hx
2019-02-01 12:49:12 +08:00
parent f55a285cb5
commit 54c884cbd8
5 changed files with 136 additions and 10 deletions

View File

@ -11,6 +11,7 @@
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
333E5DAE7FC10AC69FEC26C0 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DDA792F029EDD7A11295D192 /* libPods-Runner.a */; }; 333E5DAE7FC10AC69FEC26C0 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DDA792F029EDD7A11295D192 /* libPods-Runner.a */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; };
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; }; 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; }; 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; };
@ -42,6 +43,7 @@
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; }; 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; };
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; }; 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; }; 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
@ -92,6 +94,7 @@
children = ( children = (
3B80C3931E831B6300D905FE /* App.framework */, 3B80C3931E831B6300D905FE /* App.framework */,
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
2D5378251FAA1A9400D5DBA9 /* flutter_assets */,
9740EEBA1CF902C7004384FC /* Flutter.framework */, 9740EEBA1CF902C7004384FC /* Flutter.framework */,
9740EEB21CF90195004384FC /* Debug.xcconfig */, 9740EEB21CF90195004384FC /* Debug.xcconfig */,
7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
@ -209,6 +212,7 @@
files = ( files = (
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */,
084A20882202E4FD00428FF5 /* flutter go.png in Resources */, 084A20882202E4FD00428FF5 /* flutter go.png in Resources */,
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,

View File

@ -4,7 +4,7 @@ import 'package:flutter/rendering.dart';
import 'routers/routers.dart'; import 'routers/routers.dart';
import 'routers/application.dart'; import 'routers/application.dart';
import 'package:flutter_go/utils/provider.dart'; import 'package:flutter_go/utils/provider.dart';
import 'package:flutter_go/utils/shared_preferences.dart';
import 'views/welcome_page/index.dart'; import 'views/welcome_page/index.dart';
const int ThemeColor = 0xFFC91B3A; const int ThemeColor = 0xFFC91B3A;
@ -46,6 +46,7 @@ var db;
void main() async { void main() async {
final provider = new Provider(); final provider = new Provider();
await provider.init(true); await provider.init(true);
Application.sharePeferences = await SpUtil.instance;
db = Provider.db; db = Provider.db;
runApp(new MyApp()); runApp(new MyApp());
} }

View File

@ -7,15 +7,22 @@
* tartget: xxx * tartget: xxx
*/ */
import 'package:flutter/material.dart'; enum DateType {
Int,
class Demo extends StatefulWidget { Double,
_Demo createState() => _Demo(); Bool,
String,
Dynamic
} }
class _Demo extends State<Demo> { class spKey {
String name;
DateType type;
Widget build(BuildContext context) { spKey({this.name, this.type});
return Container();
} }
class sharedPreferencesKeys {
static spKey loginWelcome = spKey(name: 'loginWelcone', type: DateType.Bool);
} }

View File

@ -1,8 +1,11 @@
import 'package:fluro/fluro.dart'; import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_go/utils/shared_preferences.dart';
class Application { class Application {
static Router router; static Router router;
static TabController controller; static TabController controller;
static SpUtil sharePeferences;
static Map<String, String> github = { static Map<String, String> github = {
'widgetsURL':'https://github.com/alibaba-paimai-frontend/flutter-common-widgets-app/tree/develop/lib/widgets/', 'widgetsURL':'https://github.com/alibaba-paimai-frontend/flutter-common-widgets-app/tree/develop/lib/widgets/',
//'develop':'https://github.com/alibaba-paimai-frontend/flutter-common-widgets-app/tree/develop/lib/widgets/', //'develop':'https://github.com/alibaba-paimai-frontend/flutter-common-widgets-app/tree/develop/lib/widgets/',

View File

@ -0,0 +1,111 @@
import 'dart:async';
import 'package:shared_preferences/shared_preferences.dart';
///
/// 用来做shared_preferences的存储
class SpUtil {
static SpUtil _instance;
static Future<SpUtil> get instance async {
return await _getInstance();
}
static SharedPreferences _spf;
SpUtil._();
Future _init() async {
_spf = await SharedPreferences.getInstance();
}
static Future<SpUtil> _getInstance() async {
if (_instance == null) {
_instance = new SpUtil._();
await _instance._init();
}
return _instance;
}
static bool _beforCheck() {
String a;
if (_spf == null) {
return throw new StateError("SharedPreferences must be initialized first, but the insurance is null;");
}
}
static Set<String> getKeys() {
if (_beforCheck()) return null;
return _spf.getKeys();
}
dynamic get(String key) {
if (_beforCheck()) return null;
return _spf.getKeys();
}
static String getString(String key) {
if (_beforCheck()) return null;
return _spf.getString(key);
}
static Future<bool> putString(String key, String value) {
if (_beforCheck()) return null;
return _spf.setString(key, value);
}
static bool getBool(String key) {
if (_beforCheck()) return null;
return _spf.getBool(key);
}
static Future<bool> putBool(String key, bool value) {
if (_beforCheck()) return null;
return _spf.setBool(key, value);
}
static int getInt(String key) {
if (_beforCheck()) return null;
return _spf.getInt(key);
}
static Future<bool> putInt(String key, int value) {
if (_beforCheck()) return null;
return _spf.setInt(key, value);
}
static double getDouble(String key) {
if (_beforCheck()) return null;
return _spf.getDouble(key);
}
static Future<bool> putDouble(String key, double value) {
if (_beforCheck()) return null;
return _spf.setDouble(key, value);
}
static List<String> getStringList(String key) {
return _spf.getStringList(key);
}
static Future<bool> putStringList(String key, List<String> value) {
if (_beforCheck()) return null;
return _spf.setStringList(key, value);
}
static dynamic getDynamic(String key) {
if (_beforCheck()) return null;
return _spf.get(key);
}
static Future<bool> remove(String key) {
if (_beforCheck()) return null;
return _spf.remove(key);
}
static Future<bool> clear() {
if (_beforCheck()) return null;
return _spf.clear();
}
}