Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[documentation] [url_launcher] fix for readme code sample #3308

Merged
merged 3 commits into from
Dec 11, 2020
Merged

[documentation] [url_launcher] fix for readme code sample #3308

merged 3 commits into from
Dec 11, 2020

Conversation

iapicca
Copy link
Contributor

@iapicca iapicca commented Dec 8, 2020

Description

the code sample at this link and reported below is clearly broken

import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';

void main() {
  runApp(Scaffold(
    body: Center(
      child: RaisedButton(
        onPressed: _launchURL,
        child: Text('Show Flutter homepage'),
      ),
    ),
  ));
}

_launchURL() async {
  const url = 'https://flutter.dev';
  if (await canLaunch(url)) {
    await launch(url);
  } else {
    throw 'Could not launch $url';
  }
}

please consider replacing it with the following

import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';

const _url = 'https://flutter.dev';

void main() => runApp(
      const MaterialApp(
        home: Material(
          child: Center(
            child: RaisedButton(
              onPressed: _launchURL,
              child: Text('Show Flutter homepage'),
            ),
          ),
        ),
      ),
    );

void _launchURL() async =>
    await canLaunch(_url) ? await launch(_url) : throw 'Could not launch $_url';

Related Issues

flutter/flutter#71923

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See [Contributor Guide]).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze) does not report any problems on my PR.
  • I read and followed the [Flutter Style Guide].
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I updated pubspec.yaml with an appropriate new version according to the [pub versioning philosophy].
  • I updated CHANGELOG.md to add a description of the change.
  • I signed the [CLA].
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate a breaking change in CHANGELOG.md and increment major revision).
  • No, this is not a breaking change.

@iapicca iapicca requested a review from mklim as a code owner December 8, 2020 17:38
@google-cla google-cla bot added the cla: yes label Dec 8, 2020
@iapicca iapicca changed the title code sample fixed [documentation] [url_launcher] fix for readme code sample Dec 8, 2020
@hamdikahloun
Copy link
Member

Please update CHANGELOG.md & pubspec.yaml

@iapicca
Copy link
Contributor Author

iapicca commented Dec 8, 2020

@hamdikahloun

Please update CHANGELOG.md & pubspec.yaml

bumped version: 5.7.12 in pubspec.yaml

and updated CHANGELOG.md

## 5.7.12

* Updated code sample in `README.md`

Copy link
Member

@hamdikahloun hamdikahloun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hamdikahloun
Copy link
Member

Can you merge this up to head to re-run CI in current state?

@hamdikahloun hamdikahloun merged commit 298fb23 into flutter:master Dec 11, 2020
NickalasB added a commit to NickalasB/plugins that referenced this pull request Dec 12, 2020
* master:
  [q-w] Update Flutter SDK constraint (flutter#3323)
  [i-p] Update Flutter SDK constraint (flutter#3322)
  [d-g] Update Flutter SDK constraint (flutter#3321)
  [a-c] Update Flutter SDK constraint (flutter#3320)
  [image_picker_platform_interface] Pass Uri to package:http APIs (flutter#3309)
  Exclude null-safe plugins from testing on stable (flutter#3318)
  [documentation] [url_launcher] fix for readme code sample (flutter#3308)

# Conflicts:
#	packages/webview_flutter/CHANGELOG.md
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 14, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 14, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 15, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 15, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 15, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 15, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 16, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 16, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 16, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 16, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 17, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 18, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 18, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 18, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 18, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 18, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 19, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 19, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 19, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 20, 2020
amantoux pushed a commit to amantoux/plugins that referenced this pull request Feb 8, 2021
* code sample fixed

* updated CHANGELOG.md and pubspec.yaml
adsonpleal pushed a commit to nubank/plugins that referenced this pull request Feb 26, 2021
* code sample fixed

* updated CHANGELOG.md and pubspec.yaml
samandmoore added a commit to Betterment/plugins that referenced this pull request Apr 21, 2021
…m-changes

* upstream-share-final-null-release: (233 commits)
  [q-w] Update Flutter SDK constraint (flutter#3323)
  [i-p] Update Flutter SDK constraint (flutter#3322)
  [d-g] Update Flutter SDK constraint (flutter#3321)
  [a-c] Update Flutter SDK constraint (flutter#3320)
  [image_picker_platform_interface] Pass Uri to package:http APIs (flutter#3309)
  Exclude null-safe plugins from testing on stable (flutter#3318)
  [documentation] [url_launcher] fix for readme code sample (flutter#3308)
  [camera] Add zoom support to platform interface (flutter#3312)
  update analysis options for nnbd (flutter#3319)
  [camera] Suppress unchecked cast warning in java test (flutter#3316)
  [image_picker] [integration_test] Fixes to make the tree green (flutter#3317)
  [camera] Expanded platform interface to support setting flash mode (flutter#3313)
  [Espresso] Android Code Inspection and Clean up (flutter#3111)
  [camera] Add `camera_platform_interface` package (flutter#3253)
  [camera] Support Android 30 (flutter#3299)
  bump integration test to 1.0.0 (flutter#3295)
  [android_alarm_manager] fix AndroidManifest.xml for android lint issue "XML tag has empty body" (flutter#3288)
  Use testWidgets instead of test to fix failures not surfacing on CI (flutter#3279)
  [file_selector_platform_interface] Migrate to cross_file package (flutter#3286)
  Fix broken link (flutter#3280)
  ...
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants