diff --git a/community/samples/serving/helloworld-dart/README.md b/community/samples/serving/helloworld-dart/README.md index a1a80a3fb..2311c1c03 100644 --- a/community/samples/serving/helloworld-dart/README.md +++ b/community/samples/serving/helloworld-dart/README.md @@ -24,13 +24,12 @@ be created using the following instructions. ```yaml name: hello_world_dart publish_to: none # let's not accidentally publish this to pub.dartlang.org - description: Hello world server example in Dart environment: - sdk: ">=2.1.0 <3.0.0" + sdk: ">=2.12.0 <3.0.0" dependencies: - shelf: ^0.7.3 + shelf: ^1.0.0 ``` 2. If you want to run locally, install dependencies. If you only want to run in @@ -50,16 +49,16 @@ be created using the following instructions. Future main() async { // Find port to listen on from environment variable. - var port = int.tryParse(Platform.environment['PORT'] ?? '8080'); + final port = int.parse(Platform.environment['PORT'] ?? '8080'); // Read $TARGET from environment variable. - var target = Platform.environment['TARGET'] ?? 'World'; + final target = Platform.environment['TARGET'] ?? 'World'; Response handler(Request request) => Response.ok('Hello $target'); // Serve handler on given port. - var server = await serve( - Pipeline().addMiddleware(logRequests()).addHandler(handler), + final server = await serve( + const Pipeline().addMiddleware(logRequests()).addHandler(handler), InternetAddress.anyIPv4, port, ); diff --git a/community/samples/serving/helloworld-dart/bin/server.dart b/community/samples/serving/helloworld-dart/bin/server.dart index 1b5ccf786..a2b61c08d 100644 --- a/community/samples/serving/helloworld-dart/bin/server.dart +++ b/community/samples/serving/helloworld-dart/bin/server.dart @@ -5,16 +5,16 @@ import 'package:shelf/shelf_io.dart'; Future main() async { // Find port to listen on from environment variable. - var port = int.tryParse(Platform.environment['PORT'] ?? '8080'); + final port = int.parse(Platform.environment['PORT'] ?? '8080'); // Read $TARGET from environment variable. - var target = Platform.environment['TARGET'] ?? 'World'; + final target = Platform.environment['TARGET'] ?? 'World'; Response handler(Request request) => Response.ok('Hello $target'); // Serve handler on given port. - var server = await serve( - Pipeline().addMiddleware(logRequests()).addHandler(handler), + final server = await serve( + const Pipeline().addMiddleware(logRequests()).addHandler(handler), InternetAddress.anyIPv4, port, ); diff --git a/community/samples/serving/helloworld-dart/pubspec.yaml b/community/samples/serving/helloworld-dart/pubspec.yaml index 9a2607769..6f8965d5f 100644 --- a/community/samples/serving/helloworld-dart/pubspec.yaml +++ b/community/samples/serving/helloworld-dart/pubspec.yaml @@ -2,7 +2,7 @@ name: hello_world_dart publish_to: none # let's not accidentally publish this to pub.dartlang.org environment: - sdk: '>=2.1.0 <3.0.0' + sdk: '>=2.12.0 <3.0.0' dependencies: - shelf: ^0.7.3 + shelf: ^1.0.0