remove flutter specific code
diff --git a/.analysis_options b/.analysis_options
index 19c7129..a10d4c5 100644
--- a/.analysis_options
+++ b/.analysis_options
@@ -1,4 +1,2 @@
analyzer:
strong-mode: true
- exclude:
- - lib/src/usage_impl_flutter.dart
diff --git a/changelog.md b/changelog.md
index 597ab61..f62e4dd 100644
--- a/changelog.md
+++ b/changelog.md
@@ -2,6 +2,8 @@
## 3.0.0
- removed the use of configurable imports
+- removed the Flutter specific entry-point; Flutter apps can now use the
+ regular `dart:io` entrypoint (AnalyticsIO)
## 2.2.2
- adjust the Flutter usage client to Flutter API changes
diff --git a/example/flutter_example/.gitignore b/example/flutter_example/.gitignore
deleted file mode 100644
index 14c7d4c..0000000
--- a/example/flutter_example/.gitignore
+++ /dev/null
@@ -1,9 +0,0 @@
-.DS_Store
-.atom/
-.idea
-.packages
-.pub/
-build/
-ios/.generated/
-packages
-pubspec.lock
diff --git a/example/flutter_example/README.md b/example/flutter_example/README.md
deleted file mode 100644
index 7608a60..0000000
--- a/example/flutter_example/README.md
+++ /dev/null
@@ -1,9 +0,0 @@
-# Example of usage package with Flutter
-
-To run the Flutter example, ensure that the pubspec.yaml points to your Flutter
-path. Then run:
-
-```
-pub get
-flutter run
-```
diff --git a/example/flutter_example/android/AndroidManifest.xml b/example/flutter_example/android/AndroidManifest.xml
deleted file mode 100644
index 2e28bb3..0000000
--- a/example/flutter_example/android/AndroidManifest.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.yourcompany.flutterExample"
- android:versionCode="1"
- android:versionName="0.0.1">
-
- <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="21" />
- <uses-permission android:name="android.permission.INTERNET"/>
-
- <application android:name="org.domokit.sky.shell.SkyApplication" android:label="flutter_example" android:icon="@mipmap/ic_launcher">
- <activity android:name="org.domokit.sky.shell.SkyActivity"
- android:launchMode="singleTask"
- android:theme="@android:style/Theme.Black.NoTitleBar"
- android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection"
- android:hardwareAccelerated="true"
- android:windowSoftInputMode="adjustResize">
- <intent-filter>
- <action android:name="android.intent.action.MAIN"/>
- <category android:name="android.intent.category.LAUNCHER"/>
- </intent-filter>
- </activity>
- </application>
-</manifest>
diff --git a/example/flutter_example/android/res/mipmap-hdpi/ic_launcher.png b/example/flutter_example/android/res/mipmap-hdpi/ic_launcher.png
deleted file mode 100644
index f0a55cd..0000000
--- a/example/flutter_example/android/res/mipmap-hdpi/ic_launcher.png
+++ /dev/null
Binary files differ
diff --git a/example/flutter_example/android/res/mipmap-mdpi/ic_launcher.png b/example/flutter_example/android/res/mipmap-mdpi/ic_launcher.png
deleted file mode 100644
index eb98dc4..0000000
--- a/example/flutter_example/android/res/mipmap-mdpi/ic_launcher.png
+++ /dev/null
Binary files differ
diff --git a/example/flutter_example/android/res/mipmap-xhdpi/ic_launcher.png b/example/flutter_example/android/res/mipmap-xhdpi/ic_launcher.png
deleted file mode 100644
index f1783db..0000000
--- a/example/flutter_example/android/res/mipmap-xhdpi/ic_launcher.png
+++ /dev/null
Binary files differ
diff --git a/example/flutter_example/android/res/mipmap-xxhdpi/ic_launcher.png b/example/flutter_example/android/res/mipmap-xxhdpi/ic_launcher.png
deleted file mode 100644
index 46828a2..0000000
--- a/example/flutter_example/android/res/mipmap-xxhdpi/ic_launcher.png
+++ /dev/null
Binary files differ
diff --git a/example/flutter_example/android/res/mipmap-xxxhdpi/ic_launcher.png b/example/flutter_example/android/res/mipmap-xxxhdpi/ic_launcher.png
deleted file mode 100644
index a527671..0000000
--- a/example/flutter_example/android/res/mipmap-xxxhdpi/ic_launcher.png
+++ /dev/null
Binary files differ
diff --git a/example/flutter_example/flutter.yaml b/example/flutter_example/flutter.yaml
deleted file mode 100644
index 2f6cd44..0000000
--- a/example/flutter_example/flutter.yaml
+++ /dev/null
@@ -1,2 +0,0 @@
-name: flutter_example
-uses-material-design: true
diff --git a/example/flutter_example/lib/main.dart b/example/flutter_example/lib/main.dart
deleted file mode 100644
index eceae54..0000000
--- a/example/flutter_example/lib/main.dart
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright 2016, the Flutter project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import 'dart:async';
-
-import 'package:flutter/material.dart';
-import 'package:usage/usage.dart';
-
-Future main() async {
- runApp(new Container());
- Analytics ga = await Analytics.create('UA-67589403-4', 'ga_test', '1.0');
- runApp(new MaterialApp(
- title: 'Usage Example',
- theme: new ThemeData.dark(),
- routes: <String, WidgetBuilder>{
- '/': (BuildContext context) => new FlutterDemo(ga)
- },
- ));
-}
-
-class FlutterDemo extends StatefulWidget {
- FlutterDemo(this.ga);
- Analytics ga;
- @override
- State createState() => new _FlutterDemoState();
-}
-
-class _FlutterDemoState extends State<FlutterDemo> {
- int _times = 0;
-
- void _handleButtonPressed() {
- config.ga.sendEvent('button', 'pressed');
- setState(() {
- _times++;
- });
- }
-
- void _handleOptIn(bool value) {
- setState(() {
- config.ga.enabled = value;
- });
- }
-
- @override
- Widget build(BuildContext context) {
- return new Scaffold(
- appBar: new AppBar(
- title: new Text('Usage Example'),
- ),
- body: new Column(
- children: <Widget>[
- new Center(
- child: new Text("Button pressed $_times times."),
- ),
- new ListItem(
- onTap: () => _handleOptIn(!config.ga.enabled),
- leading: new Checkbox(
- value: config.ga.enabled,
- onChanged: _handleOptIn,
- ),
- title: new Text("Opt in to analytics"),
- ),
- ],
- mainAxisAlignment: MainAxisAlignment.spaceAround,
- ),
- floatingActionButton: new FloatingActionButton(
- child: new Icon(Icons.add),
- onPressed: _handleButtonPressed,
- ),
- );
- }
-}
diff --git a/example/flutter_example/pubspec.yaml b/example/flutter_example/pubspec.yaml
deleted file mode 100644
index 52d5cb7..0000000
--- a/example/flutter_example/pubspec.yaml
+++ /dev/null
@@ -1,12 +0,0 @@
-name: flutter_example
-description: Create a new Flutter project.
-
-environment:
- sdk: ">=1.19.0 <2.0.0"
- flutter: ^0.0.1
-
-dependencies:
- usage:
- path: ../..
- flutter:
- sdk: flutter
diff --git a/lib/src/usage_impl_flutter.dart b/lib/src/usage_impl_flutter.dart
deleted file mode 100644
index d6b7a05..0000000
--- a/lib/src/usage_impl_flutter.dart
+++ /dev/null
@@ -1,88 +0,0 @@
-// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import 'dart:async';
-import 'dart:convert' show JSON;
-import 'dart:io';
-
-import 'package:flutter/http.dart' as http;
-import 'package:flutter/services.dart';
-import 'package:path/path.dart' as path;
-
-import '../usage.dart';
-import 'usage_impl.dart';
-import 'usage_impl_io.dart';
-
-Future<Analytics> createAnalytics(
- String trackingId,
- String applicationName,
- String applicationVersion, {
- String analyticsUrl
-}) async {
- Directory dataDirectory = await PathProvider.getTemporaryDirectory();
-
- String fileName = '.${applicationName.replaceAll(' ', '_')}';
- File file = new File(path.join(dataDirectory.path, fileName));
- await file.create();
- String contents = await file.readAsString();
- if (contents.isEmpty) contents = '{}';
- Map map = JSON.decode(contents);
-
- return new AnalyticsImpl(
- trackingId,
- new FlutterPersistentProperties(applicationName, file, map),
- new FlutterPostHandler(),
- applicationName: applicationName,
- applicationVersion: applicationVersion,
- analyticsUrl: analyticsUrl
- );
-}
-
-String _createUserAgent() {
- final String locale = getPlatformLocale() ?? '';
-
- if (Platform.isAndroid) {
- return 'Mozilla/5.0 (Android; Mobile; ${locale})';
- } else if (Platform.isIOS) {
- return 'Mozilla/5.0 (iPhone; U; CPU iPhone OS like Mac OS X; ${locale})';
- } else {
- // Dart/1.8.0 (macos; macos; macos; en_US)
- final String os = Platform.operatingSystem;
- return "Dart/${getDartVersion()} (${os}; ${os}; ${os}; ${locale})";
- }
-}
-
-class FlutterPostHandler extends PostHandler {
- final String _userAgent;
- final HttpClient mockClient;
-
- FlutterPostHandler({HttpClient this.mockClient}) : _userAgent = _createUserAgent();
-
- Future sendPost(String url, Map<String, dynamic> parameters) {
- String data = postEncode(parameters);
-
- Map<String, String> headers = <String, String>{ 'User-Agent': _userAgent };
-
- return http.post(url, body: data, headers: headers);
- }
-}
-
-class FlutterPersistentProperties extends PersistentProperties {
- File _file;
- Map _map;
-
- FlutterPersistentProperties(String name, this._file, this._map) : super(name);
-
- dynamic operator[](String key) => _map[key];
-
- void operator[]=(String key, dynamic value) {
- if (value == null) {
- _map.remove(key);
- } else {
- _map[key] = value;
- }
-
- _file.writeAsString(JSON.encode(_map) + '\n');
- }
-}
diff --git a/readme.md b/readme.md
index dae7812..9b2331f 100644
--- a/readme.md
+++ b/readme.md
@@ -17,7 +17,22 @@
## For Flutter apps
-TODO:
+Flutter applications can use the `AnalyticsIO` version of this library. They will need
+to specify the documents directory in the constructor, in order to tell the library where
+to save the analytics preferences:
+
+```dart
+import 'package:flutter/services.dart';
+import 'package:usage/usage_io.dart';
+
+void main() {
+ final String UA = ...;
+
+ Analytics ga = new AnalyticsIO(UA, 'ga_test', '3.0',
+ documentsDirectory: PathProvider.getApplicationDocumentsDirectory());
+ ...
+}
+```
## For command-line apps
@@ -56,7 +71,7 @@
```dart
final String UA = ...;
-Analytics ga = new AnalyticsIO(UA, 'ga_test', '1.0');
+Analytics ga = new AnalyticsIO(UA, 'ga_test', '3.0');
ga.optIn = true;
ga.sendScreenView('home');