Просмотр исходного кода

fix analyzer issues. update pubspec

Luke Freeman 7 лет назад
Родитель
Сommit
d19e689356

+ 5 - 0
CHANGELOG.md

@@ -1,3 +1,8 @@
+# 1.3.3
+- Fix analyzer issues
+- Remove deprecations in example code
+- Fix pubspec analysis issue
+
 # 1.3.2
 - Dart 2 package (pubspec) compliance changes ONLY
 - **Note**: No functional changes

+ 3 - 3
README.md

@@ -3,7 +3,7 @@
 
 The brightest, hippest, coolest router for Flutter.
 
-[![Version](https://img.shields.io/badge/version-1.3.2-blue.svg)](https://pub.dartlang.org/packages/fluro)
+[![Version](https://img.shields.io/badge/version-1.3.3-blue.svg)](https://pub.dartlang.org/packages/fluro)
 [![Build Status](https://travis-ci.org/theyakka/fluro.svg?branch=master)](https://travis-ci.org/theyakka/fluro)
 [![Coverage](https://codecov.io/gh/theyakka/fluro/branch/master/graph/badge.svg)](https://codecov.io/gh/theyakka/fluro)
 
@@ -25,7 +25,7 @@ See CHANGELOG for all breaking (and non-breaking) changes.
 You should ensure that you add the router as a dependency in your flutter project.
 ```yaml
 dependencies:
- fluro: "^1.3.2"
+ fluro: "^1.3.3"
 ```
 
 You can also reference the git repo directly if you want:
@@ -80,7 +80,7 @@ You can also manually push to a route yourself. To do so:
 ```dart
 router.navigateTo(context, "/users/1234", transition: TransitionType.fadeIn);
 ```
-<br/>
+
 <hr/>
 Fluro is a Yakka original.
 <br/>

+ 0 - 5
example/lib/components/app/app_component.dart

@@ -9,10 +9,8 @@ import '../../config/application.dart';
 import 'package:flutter/material.dart';
 import 'package:fluro/fluro.dart';
 import '../../config/routes.dart';
-import '../home/home_component.dart';
 
 class AppComponent extends StatefulWidget {
-
   @override
   State createState() {
     return new AppComponentState();
@@ -20,14 +18,12 @@ class AppComponent extends StatefulWidget {
 }
 
 class AppComponentState extends State<AppComponent> {
-
   AppComponentState() {
     final router = new Router();
     Routes.configureRoutes(router);
     Application.router = router;
   }
 
-
   @override
   Widget build(BuildContext context) {
     final app = new MaterialApp(
@@ -41,4 +37,3 @@ class AppComponentState extends State<AppComponent> {
     return app;
   }
 }
-

+ 9 - 11
example/lib/components/demo/demo_message_component.dart

@@ -5,12 +5,11 @@
  * Copyright (c) 2018 Posse Productions LLC. All rights reserved.
  * See LICENSE for distribution and usage details.
  */
-import 'package:flutter/foundation.dart';
 import 'package:flutter/material.dart';
 
 class DemoMessageComponent extends StatelessWidget {
-
-  DemoMessageComponent({@required this.message, this.color = const Color(0xFFFFFFFF)});
+  DemoMessageComponent(
+      {@required this.message, this.color = const Color(0xFFFFFFFF)});
 
   final String message;
   final Color color;
@@ -20,13 +19,12 @@ class DemoMessageComponent extends StatelessWidget {
     return new Material(
       color: this.color,
       child: new Center(
-        child: new Text(
-          message,
-          style: new TextStyle(
-            fontFamily: "Lazer84",
-          ),
-        )
-      ),
+          child: new Text(
+        message,
+        style: new TextStyle(
+          fontFamily: "Lazer84",
+        ),
+      )),
     );
   }
-}
+}

+ 2 - 4
example/lib/components/demo/demo_result_component.dart

@@ -8,8 +8,6 @@ class DemoResultComponent extends StatefulWidget {
 class _DemoResultComponentState extends State<DemoResultComponent> {
   @override
   Widget build(BuildContext context) {
-    return new Container(
-      
-    );
+    return new Container();
   }
-}
+}

+ 9 - 5
example/lib/components/demo/demo_simple_component.dart

@@ -9,8 +9,10 @@ import '../../helpers/color_helpers.dart';
 import 'package:flutter/material.dart';
 
 class DemoSimpleComponent extends StatelessWidget {
-
-  DemoSimpleComponent({String message = "Testing", Color color = const Color(0xFFFFFFFF), String result})
+  DemoSimpleComponent(
+      {String message = "Testing",
+      Color color = const Color(0xFFFFFFFF),
+      String result})
       : this.message = message,
         this.color = color,
         this.result = result;
@@ -47,8 +49,10 @@ class DemoSimpleComponent extends StatelessWidget {
             child: new ConstrainedBox(
               constraints: new BoxConstraints(minHeight: 42.0),
               child: new FlatButton(
-                highlightColor: ColorHelpers.blackOrWhiteContrastColor(color).withAlpha(17),
-                splashColor: ColorHelpers.blackOrWhiteContrastColor(color).withAlpha(34),
+                highlightColor:
+                    ColorHelpers.blackOrWhiteContrastColor(color).withAlpha(17),
+                splashColor:
+                    ColorHelpers.blackOrWhiteContrastColor(color).withAlpha(34),
                 onPressed: () {
                   if (result == null) {
                     Navigator.pop(context);
@@ -70,4 +74,4 @@ class DemoSimpleComponent extends StatelessWidget {
       ),
     );
   }
-}
+}

+ 28 - 18
example/lib/components/home/home_component.dart

@@ -13,17 +13,22 @@ import 'package:flutter/material.dart';
 import 'package:flutter/services.dart';
 
 class HomeComponent extends StatefulWidget {
-
   @override
   State createState() => new HomeComponentState();
 }
 
 class HomeComponentState extends State<HomeComponent> {
-
   var _deepLinkOpacity = 1.0;
-  final _deepLinkURL = "fluro://deeplink?path=/message&mesage=fluro%20rocks%21%21";
+  final _deepLinkURL =
+      "fluro://deeplink?path=/message&mesage=fluro%20rocks%21%21";
   final _daysOfWeek = const [
-    "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"
+    "Monday",
+    "Tuesday",
+    "Wednesday",
+    "Thursday",
+    "Friday",
+    "Saturday",
+    "Sunday"
   ];
 
   Widget deepLinkWidget(BuildContext context) {
@@ -89,7 +94,9 @@ class HomeComponentState extends State<HomeComponent> {
     var menuWidgets = <Widget>[
       new Padding(
         padding: new EdgeInsets.only(bottom: 35.0),
-        child: new Image(image: new AssetImage("assets/images/logo_fluro.png"), width: 200.0),
+        child: new Image(
+            image: new AssetImage("assets/images/logo_fluro.png"),
+            width: 200.0),
       ),
       menuButton(context, "Native Animation", "native"),
       menuButton(context, "Preset (In from Left)", "preset-from-left"),
@@ -149,10 +156,12 @@ class HomeComponentState extends State<HomeComponent> {
     if (key != "custom" && key != "function-call") {
       if (key == "native") {
         hexCode = "#F76F00";
-        message = "This screen should have appeared using the default flutter animation for the current OS";
+        message =
+            "This screen should have appeared using the default flutter animation for the current OS";
       } else if (key == "preset-from-left") {
         hexCode = "#5BF700";
-        message = "This screen should have appeared with a slide in from left transition";
+        message =
+            "This screen should have appeared with a slide in from left transition";
         transitionType = TransitionType.inFromLeft;
       } else if (key == "preset-fade") {
         hexCode = "#F700D2";
@@ -161,7 +170,8 @@ class HomeComponentState extends State<HomeComponent> {
       } else if (key == "pop-result") {
         transitionType = TransitionType.native;
         hexCode = "#7d41f4";
-        message = "When you close this screen you should see the current day of the week";
+        message =
+            "When you close this screen you should see the current day of the week";
         result = "Today is ${_daysOfWeek[new DateTime.now().weekday - 1]}!";
       }
 
@@ -171,18 +181,18 @@ class HomeComponentState extends State<HomeComponent> {
         route = "$route&result=$result";
       }
 
-      Application.router.navigateTo(
-          context, route,
-          transition: transitionType).then((result) {
-            if (key == "pop-result") {
-              Application.router.navigateTo(context, "/demo/func?message=$result");
-            }
-          });
+      Application.router
+          .navigateTo(context, route, transition: transitionType)
+          .then((result) {
+        if (key == "pop-result") {
+          Application.router.navigateTo(context, "/demo/func?message=$result");
+        }
+      });
     } else if (key == "custom") {
       hexCode = "#DFF700";
-      message = "This screen should have appeared with a crazy custom transition";
-      var transition =
-          (BuildContext context, Animation<double> animation,
+      message =
+          "This screen should have appeared with a crazy custom transition";
+      var transition = (BuildContext context, Animation<double> animation,
           Animation<double> secondaryAnimation, Widget child) {
         return new ScaleTransition(
           scale: animation,

+ 1 - 1
example/lib/config/application.dart

@@ -9,4 +9,4 @@ import 'package:fluro/fluro.dart';
 
 class Application {
   static Router router;
-}
+}

+ 33 - 27
example/lib/config/route_handlers.dart

@@ -12,11 +12,13 @@ import 'package:flutter/painting.dart';
 import 'package:fluro/fluro.dart';
 import 'package:flutter/material.dart';
 
-var rootHandler = new Handler(handlerFunc: (BuildContext context, Map<String, List<String>> params) {
+var rootHandler = new Handler(
+    handlerFunc: (BuildContext context, Map<String, List<String>> params) {
   return new HomeComponent();
 });
 
-var demoRouteHandler = new Handler(handlerFunc: (BuildContext context, Map<String, List<String>> params) {
+var demoRouteHandler = new Handler(
+    handlerFunc: (BuildContext context, Map<String, List<String>> params) {
   String message = params["message"]?.first;
   String colorHex = params["color_hex"]?.first;
   String result = params["result"]?.first;
@@ -24,7 +26,8 @@ var demoRouteHandler = new Handler(handlerFunc: (BuildContext context, Map<Strin
   if (colorHex != null && colorHex.length > 0) {
     color = new Color(ColorHelpers.fromHexString(colorHex));
   }
-  return new DemoSimpleComponent(message: message, color: color, result: result);
+  return new DemoSimpleComponent(
+      message: message, color: color, result: result);
 });
 
 var demoFunctionHandler = new Handler(
@@ -33,42 +36,45 @@ var demoFunctionHandler = new Handler(
       String message = params["message"]?.first;
       showDialog(
         context: context,
-        child: new AlertDialog(
-          title: new Text(
-            "Hey Hey!",
-            style: new TextStyle(
-              color: const Color(0xFF00D6F7),
-              fontFamily: "Lazer84",
-              fontSize: 22.0,
-            ),
-          ),
-          content: new Text("$message"),
-          actions: <Widget>[
-            new Padding(
-              padding: new EdgeInsets.only(bottom: 8.0, right: 8.0),
-              child: new FlatButton(
-                onPressed: () {
-                  Navigator.of(context).pop(true);
-                },
-                child: new Text("OK"),
+        builder: (context) {
+          return new AlertDialog(
+            title: new Text(
+              "Hey Hey!",
+              style: new TextStyle(
+                color: const Color(0xFF00D6F7),
+                fontFamily: "Lazer84",
+                fontSize: 22.0,
               ),
             ),
-          ],
-        ),
+            content: new Text("$message"),
+            actions: <Widget>[
+              new Padding(
+                padding: new EdgeInsets.only(bottom: 8.0, right: 8.0),
+                child: new FlatButton(
+                  onPressed: () {
+                    Navigator.of(context).pop(true);
+                  },
+                  child: new Text("OK"),
+                ),
+              ),
+            ],
+          );
+        },
       );
     });
 
 /// Handles deep links into the app
 /// To test on Android:
-/// 
+///
 /// `adb shell am start -W -a android.intent.action.VIEW -d "fluro://deeplink?path=/message&mesage=fluro%20rocks%21%21" com.goposse.fluro`
-var deepLinkHandler = new Handler(handlerFunc: (BuildContext context, Map<String, List<String>> params) {
-  String message = params["message"]?.first;
+var deepLinkHandler = new Handler(
+    handlerFunc: (BuildContext context, Map<String, List<String>> params) {
   String colorHex = params["color_hex"]?.first;
   String result = params["result"]?.first;
   Color color = new Color(0xFFFFFFFF);
   if (colorHex != null && colorHex.length > 0) {
     color = new Color(ColorHelpers.fromHexString(colorHex));
   }
-  return new DemoSimpleComponent(message: "DEEEEEP LINK!!!", color: color, result: result);  
+  return new DemoSimpleComponent(
+      message: "DEEEEEP LINK!!!", color: color, result: result);
 });

+ 3 - 4
example/lib/config/routes.dart

@@ -10,14 +10,14 @@ import 'package:flutter/material.dart';
 import './route_handlers.dart';
 
 class Routes {
-
   static String root = "/";
   static String demoSimple = "/demo";
   static String demoFunc = "/demo/func";
   static String deepLink = "/message";
 
   static void configureRoutes(Router router) {
-    router.notFoundHandler = new Handler(handlerFunc: (BuildContext context, Map<String, List<String>> params) {
+    router.notFoundHandler = new Handler(
+        handlerFunc: (BuildContext context, Map<String, List<String>> params) {
       print("ROUTE WAS NOT FOUND !!!");
     });
     router.define(root, handler: rootHandler);
@@ -25,5 +25,4 @@ class Routes {
     router.define(demoFunc, handler: demoFunctionHandler);
     router.define(deepLink, handler: deepLinkHandler);
   }
-
-}
+}

+ 13 - 8
example/lib/helpers/color_helpers.dart

@@ -14,7 +14,6 @@ enum ContrastPreference {
 }
 
 class ColorHelpers {
-
   static int fromHexString(String argbHexString) {
     String useString = argbHexString;
     if (useString.startsWith("#")) {
@@ -36,16 +35,22 @@ class ColorHelpers {
   /// or lighter. If darker, will return white. If lighter, will return
   /// black. If the color is within 35-65% of the spectrum and a prefer
   /// value is specified, then white or black will be preferred.
-  static Color blackOrWhiteContrastColor(Color sourceColor, {ContrastPreference prefer = ContrastPreference.none}) {
+  static Color blackOrWhiteContrastColor(Color sourceColor,
+      {ContrastPreference prefer = ContrastPreference.none}) {
     // Will return a value between 0.0 (black) and 1.0 (white)
-    double value = (((sourceColor.red * 299.0) + (sourceColor.green * 587.0) +
-        (sourceColor.blue * 114.0)) / 1000.0) / 255.0;
+    double value = (((sourceColor.red * 299.0) +
+                (sourceColor.green * 587.0) +
+                (sourceColor.blue * 114.0)) /
+            1000.0) /
+        255.0;
     if (prefer != ContrastPreference.none) {
-      if (value >= _kMinContrastModifierRange && value <= _kMaxContrastModifierRange) {
-        return prefer == ContrastPreference.light ? new Color(0xFFFFFFFF) : new Color(0xFF000000);
+      if (value >= _kMinContrastModifierRange &&
+          value <= _kMaxContrastModifierRange) {
+        return prefer == ContrastPreference.light
+            ? new Color(0xFFFFFFFF)
+            : new Color(0xFF000000);
       }
     }
     return value > 0.6 ? new Color(0xFF000000) : new Color(0xFFFFFFFF);
   }
-
-}
+}

+ 1 - 1
example/lib/main.dart

@@ -10,4 +10,4 @@ import 'package:flutter/material.dart';
 
 void main() {
   runApp(new AppComponent());
-}
+}

+ 3 - 8
lib/fluro.dart

@@ -7,11 +7,6 @@
  */
 library fluro;
 
-import 'dart:async';
-import 'package:flutter/foundation.dart';
-import 'package:flutter/material.dart';
-import 'package:flutter/widgets.dart';
-
-part 'src/common.dart';
-part 'src/router.dart';
-part 'src/tree.dart';
+export 'src/common.dart';
+export 'src/router.dart';
+export 'src/tree.dart';

+ 2 - 1
lib/src/common.dart

@@ -5,7 +5,8 @@
  * Copyright (c) 2018 Posse Productions LLC. All rights reserved.
  * See LICENSE for distribution and usage details.
  */
-part of fluro;
+
+import 'package:flutter/widgets.dart';
 
 ///
 enum HandlerType {

+ 6 - 1
lib/src/router.dart

@@ -5,7 +5,12 @@
  * Copyright (c) 2018 Posse Productions LLC. All rights reserved.
  * See LICENSE for distribution and usage details.
  */
-part of fluro;
+
+import 'dart:async';
+
+import 'package:fluro/fluro.dart';
+import 'package:fluro/src/common.dart';
+import 'package:flutter/material.dart';
 
 enum TransitionType {
   native,

+ 3 - 1
lib/src/tree.dart

@@ -5,7 +5,9 @@
  * Copyright (c) 2018 Posse Productions LLC. All rights reserved.
  * See LICENSE for distribution and usage details.
  */
-part of fluro;
+
+import 'package:fluro/src/common.dart';
+import 'package:flutter/widgets.dart';
 
 enum RouteTreeNodeType {
   component,

+ 4 - 4
pubspec.yaml

@@ -1,9 +1,9 @@
 name: fluro
 description: >
-  The brightest, hippest, coolest router for Flutter. Fluro is a companion to the Flutter routing mechanism
-  which adds flexible routing options like wildcards, named parameters and clearer route definitions.
-version: 1.3.2
-author: Yakka, LLC <code@theyakka.com>
+  Fluro is a Flutter routing library that adds flexible routing options like wildcards, named
+  parameters and clear route definitions.
+version: 1.3.3
+author: Yakka, LLC <flutter@theyakka.com>
 homepage: https://github.com/theyakka/fluro
 
 environment:

+ 37 - 25
test/parser_test.dart

@@ -5,58 +5,70 @@
  * Copyright (c) 2018 Posse Productions LLC. All rights reserved.
  * See LICENSE for distribution and usage details.
  */
+
 import 'package:flutter_test/flutter_test.dart';
 import 'package:fluro/fluro.dart';
 
 void main() {
-
-  testWidgets("Router correctly parses named parameters", (WidgetTester tester) async {
+  testWidgets("Router correctly parses named parameters",
+      (WidgetTester tester) async {
     String path = "/users/1234";
     String route = "/users/:id";
     Router router = new Router();
     router.define(route, handler: null);
     AppRouteMatch match = router.match(path);
-    expect(match?.parameters, equals(<String, List<String>>{
-      "id" : ["1234"],
-    }));
+    expect(
+        match?.parameters,
+        equals(<String, List<String>>{
+          "id": ["1234"],
+        }));
   });
 
-  testWidgets("Router correctly parses named parameters with query", (WidgetTester tester) async {
+  testWidgets("Router correctly parses named parameters with query",
+      (WidgetTester tester) async {
     String path = "/users/1234?name=luke";
     String route = "/users/:id";
     Router router = new Router();
     router.define(route, handler: null);
     AppRouteMatch match = router.match(path);
-    expect(match?.parameters, equals(<String, List<String>>{
-      "id" : ["1234"],
-      "name" : ["luke"],
-    }));
+    expect(
+        match?.parameters,
+        equals(<String, List<String>>{
+          "id": ["1234"],
+          "name": ["luke"],
+        }));
   });
 
-  testWidgets("Router correctly parses query parameters", (WidgetTester tester) async {
+  testWidgets("Router correctly parses query parameters",
+      (WidgetTester tester) async {
     String path = "/users/create?name=luke&phrase=hello%20world&number=7";
     String route = "/users/create";
     Router router = new Router();
     router.define(route, handler: null);
     AppRouteMatch match = router.match(path);
-    expect(match?.parameters, equals(<String, List<String>>{
-      "name" : ["luke"],
-      "phrase" : ["hello world"],
-      "number" : ["7"],
-    }));
+    expect(
+        match?.parameters,
+        equals(<String, List<String>>{
+          "name": ["luke"],
+          "phrase": ["hello world"],
+          "number": ["7"],
+        }));
   });
 
-  testWidgets("Router correctly parses array parameters", (WidgetTester tester) async {
-    String path = "/users/create?name=luke&phrase=hello%20world&number=7&number=10&number=13";
+  testWidgets("Router correctly parses array parameters",
+      (WidgetTester tester) async {
+    String path =
+        "/users/create?name=luke&phrase=hello%20world&number=7&number=10&number=13";
     String route = "/users/create";
     Router router = new Router();
     router.define(route, handler: null);
     AppRouteMatch match = router.match(path);
-    expect(match?.parameters, equals(<String, List<String>>{
-      "name" : ["luke"],
-      "phrase" : ["hello world"],
-      "number" : ["7", "10", "13"],
-    }));
+    expect(
+        match?.parameters,
+        equals(<String, List<String>>{
+          "name": ["luke"],
+          "phrase": ["hello world"],
+          "number": ["7", "10", "13"],
+        }));
   });
-
-}
+}