Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

232: migrate example to null safety #236

Merged
merged 3 commits into from
Jun 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: build

on:
push:
branches: [ master ]
branches: [ main ]
pull_request:
branches: [ master ]
branches: [ main ]

jobs:
test:
Expand All @@ -17,6 +17,5 @@ jobs:
java-version: '12.x'
- uses: subosito/flutter-action@v1
with:
channel: beta
- run: flutter pub get
- run: flutter test
channel: stable
- run: make clean test
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.PHONY: setup clean format test distribute

setup:
flutter channel stable
flutter upgrade

clean:
flutter clean
flutter pub get
cd example && flutter clean
cd example && flutter pub get

test:
flutter test
flutter analyze
flutter format --dry-run --set-exit-if-changed lib test
cd example && flutter analyze
cd example && flutter format --dry-run --set-exit-if-changed lib

distribute: setup clean test
flutter pub publish
2 changes: 1 addition & 1 deletion example/lib/components/demo/demo_message_component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'package:flutter/material.dart';

class DemoMessageComponent extends StatelessWidget {
DemoMessageComponent(
{@required this.message, this.color = const Color(0xFFFFFFFF)});
{required this.message, this.color = const Color(0xFFFFFFFF)});

final String message;
final Color color;
Expand Down
4 changes: 2 additions & 2 deletions example/lib/components/demo/demo_simple_component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ class DemoSimpleComponent extends StatelessWidget {
DemoSimpleComponent(
{String message = "Testing",
Color color = const Color(0xFFFFFFFF),
String result})
String? result})
: this.message = message,
this.color = color,
this.result = result;

final String message;
final Color color;
final String result;
final String? result;

@override
Widget build(BuildContext context) {
Expand Down
2 changes: 1 addition & 1 deletion example/lib/components/home/home_component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class HomeComponentState extends State<HomeComponent> {
void tappedMenuButton(BuildContext context, String key) {
String message = "";
String hexCode = "#FFFFFF";
String result;
String? result;
TransitionType transitionType = TransitionType.native;
if (key != "custom" && key != "function-call" && key != "fixed-trans") {
if (key == "native") {
Expand Down
2 changes: 1 addition & 1 deletion example/lib/config/application.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
import 'package:fluro/fluro.dart';

class Application {
static FluroRouter router;
static late final FluroRouter router;
}
25 changes: 13 additions & 12 deletions example/lib/config/route_handlers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,29 @@ import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';

var rootHandler = Handler(
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
return HomeComponent();
});

var demoRouteHandler = 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;
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
String? message = params["message"]?.first;
String? colorHex = params["color_hex"]?.first;
String? result = params["result"]?.first;
Color color = Color(0xFFFFFFFF);
if (colorHex != null && colorHex.length > 0) {
color = Color(ColorHelpers.fromHexString(colorHex));
}
return DemoSimpleComponent(message: message, color: color, result: result);
return DemoSimpleComponent(
message: message ?? 'Testing', color: color, result: result);
});

var demoFunctionHandler = Handler(
type: HandlerType.function,
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
String message = params["message"]?.first;
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
String? message = params["message"]?.first;
showDialog(
context: context,
context: context!,
builder: (context) {
return AlertDialog(
title: Text(
Expand Down Expand Up @@ -69,9 +70,9 @@ var demoFunctionHandler = Handler(
///
/// `adb shell am start -W -a android.intent.action.VIEW -d "fluro://deeplink?path=/message&mesage=fluro%20rocks%21%21" com.theyakka.fluro`
var deepLinkHandler = Handler(
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
String colorHex = params["color_hex"]?.first;
String result = params["result"]?.first;
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
String? colorHex = params["color_hex"]?.first;
String? result = params["result"]?.first;
Color color = Color(0xFFFFFFFF);
if (colorHex != null && colorHex.length > 0) {
color = Color(ColorHelpers.fromHexString(colorHex));
Expand Down
2 changes: 1 addition & 1 deletion example/lib/config/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Routes {

static void configureRoutes(FluroRouter router) {
router.notFoundHandler = Handler(
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
print("ROUTE WAS NOT FOUND !!!");
return;
});
Expand Down
8 changes: 4 additions & 4 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.0"
version: "2.6.1"
boolean_selector:
dependency: transitive
description:
Expand Down Expand Up @@ -106,7 +106,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
version: "1.8.1"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -141,7 +141,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.19"
version: "0.3.0"
typed_data:
dependency: transitive
description:
Expand All @@ -157,5 +157,5 @@ packages:
source: hosted
version: "2.1.0"
sdks:
dart: ">=2.12.0-0.0 <3.0.0"
dart: ">=2.12.0 <3.0.0"
flutter: ">=1.17.0"
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ publish_to: "none"
version: 1.0.0+1

environment:
sdk: ">=2.7.0 <3.0.0"
sdk: ">=2.12.0 <3.0.0"

dependencies:
flutter:
Expand Down
8 changes: 4 additions & 4 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.0"
version: "2.6.1"
boolean_selector:
dependency: transitive
description:
Expand Down Expand Up @@ -92,7 +92,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
version: "1.8.1"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -127,7 +127,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.19"
version: "0.3.0"
typed_data:
dependency: transitive
description:
Expand All @@ -143,5 +143,5 @@ packages:
source: hosted
version: "2.1.0"
sdks:
dart: ">=2.12.0-0.0 <3.0.0"
dart: ">=2.12.0 <3.0.0"
flutter: ">=1.17.0"