Skip to content

Commit

Permalink
remove unnecessary new from samples (flutter#818)
Browse files Browse the repository at this point in the history
  • Loading branch information
a14n authored and mit-mit committed Oct 16, 2018
1 parent e3afc1f commit 60eeff0
Show file tree
Hide file tree
Showing 23 changed files with 77 additions and 78 deletions.
2 changes: 1 addition & 1 deletion packages/android_alarm_manager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Then in Dart code add:
import 'package:android_alarm_manager/android_alarm_manager.dart';
void printHello() {
final DateTime now = new DateTime.now();
final DateTime now = DateTime.now();
final int isolateId = Isolate.current.hashCode;
print("[$now] Hello, world! isolate=${isolateId} function='$printHello'");
}
Expand Down
4 changes: 2 additions & 2 deletions packages/android_intent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ mode, we assert that the platform should be Android.
Use it by specifying action, category, data and extra arguments for the intent.
It does not support returning the result of the launched activity. Sample usage:

```
```dart
if (platform.isAndroid) {
AndroidIntent intent = new AndroidIntent(
AndroidIntent intent = AndroidIntent(
action: 'action_view',
data: 'https://play.google.com/store/apps/details?'
'id=com.google.android.apps.myapp',
Expand Down
2 changes: 1 addition & 1 deletion packages/battery/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ To use this plugin, add `battery` as a [dependency in your pubspec.yaml file](ht
import 'package:battery/battery.dart';
// Instantiate it
var battery = new Battery();
var battery = Battery();
// Access current battery level
print(battery.batteryLevel);
Expand Down
12 changes: 6 additions & 6 deletions packages/camera/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ List<CameraDescription> cameras;
Future<Null> main() async {
cameras = await availableCameras();
runApp(new CameraApp());
runApp(CameraApp());
}
class CameraApp extends StatefulWidget {
@override
_CameraAppState createState() => new _CameraAppState();
_CameraAppState createState() => _CameraAppState();
}
class _CameraAppState extends State<CameraApp> {
Expand All @@ -64,7 +64,7 @@ class _CameraAppState extends State<CameraApp> {
@override
void initState() {
super.initState();
controller = new CameraController(cameras[0], ResolutionPreset.medium);
controller = CameraController(cameras[0], ResolutionPreset.medium);
controller.initialize().then((_) {
if (!mounted) {
return;
Expand All @@ -82,12 +82,12 @@ class _CameraAppState extends State<CameraApp> {
@override
Widget build(BuildContext context) {
if (!controller.value.isInitialized) {
return new Container();
return Container();
}
return new AspectRatio(
return AspectRatio(
aspectRatio:
controller.value.aspectRatio,
child: new CameraPreview(controller));
child: CameraPreview(controller));
}
}
```
Expand Down
12 changes: 6 additions & 6 deletions packages/cloud_firestore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ Binding a `CollectionReference` to a `ListView`:
class BookList extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new StreamBuilder<QuerySnapshot>(
return StreamBuilder<QuerySnapshot>(
stream: Firestore.instance.collection('books').snapshots(),
builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
if (!snapshot.hasData) return new Text('Loading...');
return new ListView(
if (!snapshot.hasData) return Text('Loading...');
return ListView(
children: snapshot.data.documents.map((DocumentSnapshot document) {
return new ListTile(
title: new Text(document['title']),
subtitle: new Text(document['author']),
return ListTile(
title: Text(document['title']),
subtitle: Text(document['author']),
);
}).toList(),
);
Expand Down
4 changes: 2 additions & 2 deletions packages/connectivity/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Sample usage to check current status:
```dart
import 'package:connectivity/connectivity.dart';
var connectivityResult = await (new Connectivity().checkConnectivity());
var connectivityResult = await (Connectivity().checkConnectivity());
if (connectivityResult == ConnectivityResult.mobile) {
// I am connected to a mobile network.
} else if (connectivityResult == ConnectivityResult.wifi) {
Expand All @@ -31,7 +31,7 @@ exposed by connectivity plugin:
import 'package:connectivity/connectivity.dart';
initState() {
subscription = new Connectivity().onConnectivityChanged.listen((ConnectivityResult result) {
subscription = Connectivity().onConnectivityChanged.listen((ConnectivityResult result) {
// Got a new connectivity status!
})
}
Expand Down
2 changes: 1 addition & 1 deletion packages/device_info/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Example:
```dart
import 'package:device_info/device_info.dart';
DeviceInfoPlugin deviceInfo = new DeviceInfoPlugin();
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
print('Running on ${androidInfo.model}'); // e.g. "Moto G (4)"
Expand Down
12 changes: 6 additions & 6 deletions packages/firebase_admob/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ FirebaseAdMob.instance.initialize(appId: appId);
```

## Using banners and interstitials
Banner and interstitial ads can be configured with target information.
Banner and interstitial ads can be configured with target information.
And in the example below, the ads are given test ad unit IDs for a quick start.

```
MobileAdTargetingInfo targetingInfo = new MobileAdTargetingInfo(
```dart
MobileAdTargetingInfo targetingInfo = MobileAdTargetingInfo(
keywords: <String>['flutterio', 'beautiful apps'],
contentUrl: 'https://flutter.io',
birthday: new DateTime.now(),
birthday: DateTime.now(),
childDirected: false,
designedForFamilies: false,
gender: MobileAdGender.male, // or MobileAdGender.female, MobileAdGender.unknown
testDevices: <String>[], // Android emulators are considered test devices
);
BannerAd myBanner = new BannerAd(
BannerAd myBanner = BannerAd(
// Replace the testAdUnitId with an ad unit id from the AdMob dash.
// https://developers.google.com/admob/android/test-ads
// https://developers.google.com/admob/ios/test-ads
Expand All @@ -42,7 +42,7 @@ BannerAd myBanner = new BannerAd(
},
);
InterstitialAd myInterstitial = new InterstitialAd(
InterstitialAd myInterstitial = InterstitialAd(
// Replace the testAdUnitId with an ad unit id from the AdMob dash.
// https://developers.google.com/admob/android/test-ads
// https://developers.google.com/admob/ios/test-ads
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase_admob/lib/firebase_admob.dart
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ class RewardedVideoAd {
///
/// Apps can create, load, and show mobile ads. For example:
/// ```
/// BannerAd myBanner = new BannerAd(unitId: myBannerAdUnitId)
/// BannerAd myBanner = BannerAd(unitId: myBannerAdUnitId)
/// ..load()
/// ..show();
/// ```
Expand Down
6 changes: 3 additions & 3 deletions packages/firebase_analytics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ To track `PageRoute` transitions, add a `FirebaseAnalyticsObserver` to the list

```dart
FirebaseAnalytics analytics = new FirebaseAnalytics();
FirebaseAnalytics analytics = FirebaseAnalytics();
MaterialApp(
home: new MyAppHome(),
home: MyAppHome(),
navigatorObservers: [
new FirebaseAnalyticsObserver(analytics: analytics),
FirebaseAnalyticsObserver(analytics: analytics),
],
);
```
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase_analytics/lib/firebase_analytics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class FirebaseAnalytics {
///
/// Example:
///
/// FirebaseAnalytics analytics = new FirebaseAnalytics();
/// FirebaseAnalytics analytics = FirebaseAnalytics();
/// analytics.android?.setMinimumSessionDuration(200000);
final FirebaseAnalyticsAndroid android;

Expand Down
10 changes: 5 additions & 5 deletions packages/firebase_analytics/lib/observer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ String defaultNameExtractor(RouteSettings settings) => settings.name;
/// ```dart
/// Navigator.pushNamed(context, '/contact/123');
///
/// Navigator.push(context, new MaterialPageRoute(
/// settings: new RouteSettings(name: '/contact/123',
/// builder: new ContactDetail(123)))),
/// Navigator.push(context, MaterialPageRoute(
/// settings: RouteSettings(name: '/contact/123',
/// builder: ContactDetail(123)))),
///
/// Navigator.pop(context);
/// ```
Expand All @@ -38,9 +38,9 @@ String defaultNameExtractor(RouteSettings settings) => settings.name;
/// you're using a [MaterialApp]:
/// ```dart
/// MaterialApp(
/// home: new MyAppHome(),
/// home: MyAppHome(),
/// navigatorObservers: [
/// new FirebaseAnalyticsObserver(analytics: service.analytics),
/// FirebaseAnalyticsObserver(analytics: service.analytics),
/// ],
/// );
/// ```
Expand Down
20 changes: 10 additions & 10 deletions packages/firebase_dynamic_links/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,28 @@ https://example.page.link/WXYZ
You can create a Dynamic Link programmatically by setting the following parameters and using the `DynamicLinkParameters.buildUrl()` method.

```dart
final DynamicLinkParameters parameters = new DynamicLinkParameters(
final DynamicLinkParameters parameters = DynamicLinkParameters(
domain: 'abc123.app.goo.gl',
link: Uri.parse('https://example.com/'),
androidParameters: new AndroidParameters(
androidParameters: AndroidParameters(
packageName: 'com.example.android',
minimumVersion: 125,
),
iosParameters: new IosParameters(
iosParameters: IosParameters(
bundleId: 'com.example.ios',
minimumVersion: '1.0.1',
appStoreId: '123456789',
),
googleAnalyticsParameters: new GoogleAnalyticsParameters(
googleAnalyticsParameters: GoogleAnalyticsParameters(
campaign: 'example-promo',
medium: 'social',
source: 'orkut',
),
itunesConnectAnalyticsParameters: new ItunesConnectAnalyticsParameters(
itunesConnectAnalyticsParameters: ItunesConnectAnalyticsParameters(
providerToken: '123456',
campaignToken: 'example-promo',
),
socialMetaTagParameters: new SocialMetaTagParameters(
socialMetaTagParameters: SocialMetaTagParameters(
title: 'Example of a Dynamic Link',
description: 'This link works whether app is installed or not!',
),
Expand All @@ -71,7 +71,7 @@ To shorten a long Dynamic Link, use the DynamicLinkParameters.shortenUrl method.
```dart
final ShortDynamicLink shortenedLink = await DynamicLinkParameters.shortenUrl(
Uri.parse('https://example.page.link/?link=https://example.com/&apn=com.example.android&ibn=com.example.ios'),
new DynamicLinkParametersOptions(ShortDynamicLinkPathLength.unguessable),
DynamicLinkParametersOptions(ShortDynamicLinkPathLength.unguessable),
);
final Uri shortUrl = shortenedLink.shortUrl;
Expand Down Expand Up @@ -101,11 +101,11 @@ applinks:YOUR_SUBDOMAIN.page.link

```dart
void main() {
runApp(new MaterialApp(
runApp(MaterialApp(
title: 'Dynamic Links Example',
routes: <String, WidgetBuilder>{
'/': (BuildContext context) => new MyHomeWidget(), // Default home route
'/helloworld': (BuildContext context) => new MyHelloWorldWidget(),
'/': (BuildContext context) => MyHomeWidget(), // Default home route
'/helloworld': (BuildContext context) => MyHelloWorldWidget(),
},
));
}
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase_messaging/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ From your Dart code, you need to import the plugin and instantiate it:
```dart
import 'package:firebase_messaging/firebase_messaging.dart';

final FirebaseMessaging _firebaseMessaging = new FirebaseMessaging();
final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
```

Next, you should probably request permissions for receiving Push Notifications. For this, call `_firebaseMessaging.requestNotificationPermissions()`. This will bring up a permissions dialog for the user to confirm on iOS. It's a no-op on Android. Last, but not least, register `onMessage`, `onResume`, and `onLaunch` callbacks via `_firebaseMessaging.configure()` to listen for incoming messages (see table below for more information).
Expand Down
5 changes: 2 additions & 3 deletions packages/firebase_performance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,10 @@ class _MyAppState extends State<MyApp> {
.
.
Future<void> testHttpMetric() async {
final _MetricHttpClient metricHttpClient =
new _MetricHttpClient(new Client());
final _MetricHttpClient metricHttpClient = _MetricHttpClient(Client());
final Request request =
new Request("SEND", Uri.parse("https://www.google.com"));
Request("SEND", Uri.parse("https://www.google.com"));
metricHttpClient.send(request);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/google_maps_flutter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import 'package:google_maps_flutter/google_maps_flutter.dart';
void main() {
runApp(MaterialApp(
home: new Scaffold(
home: Scaffold(
appBar: AppBar(title: const Text('Google Maps demo')),
body: MapsDemo(),
),
Expand Down
8 changes: 4 additions & 4 deletions packages/google_sign_in/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ enable the [Google People API](https://developers.google.com/people/).
1. [First register your application](https://developers.google.com/mobile/add?platform=ios).
2. Open Xcode. You'll have to paste this into Xcode to properly register `GoogleServices-Info.plist`.
3. Select `GoogleServices-Info.plist` from the file manager and drag that file into the `Runner` directory, `[my_project]/ios/Runner/GoogleServices-Info.plist`.
4. A dialog will show up and ask you to select the targets, select the `Runner` target.
5. Then add the `CFBundleURLTypes` attributes below into the `[my_project]/ios/Runner/Info.plist` file.
4. A dialog will show up and ask you to select the targets, select the `Runner` target.
5. Then add the `CFBundleURLTypes` attributes below into the `[my_project]/ios/Runner/Info.plist` file.

```
<!-- Put me in the [my_project]/ios/Runner/Info.plist file -->
Expand Down Expand Up @@ -59,8 +59,8 @@ import 'package:google_sign_in/google_sign_in.dart';

Initialize GoogleSignIn with the scopes you want:

```
GoogleSignIn _googleSignIn = new GoogleSignIn(
```dart
GoogleSignIn _googleSignIn = GoogleSignIn(
scopes: [
'email',
'https://www.googleapis.com/auth/contacts.readonly',
Expand Down
6 changes: 3 additions & 3 deletions packages/google_sign_in/lib/testing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import 'package:flutter/services.dart' show MethodCall;
/// FakeSignInBackend fakeSignInBackend;
///
/// setUp(() {
/// googleSignIn = new GoogleSignIn();
/// fakeSignInBackend = new FakeSignInBackend();
/// fakeSignInBackend.user = new FakeUser(
/// googleSignIn = GoogleSignIn();
/// fakeSignInBackend = FakeSignInBackend();
/// fakeSignInBackend.user = FakeUser(
/// id: 123,
/// email: 'jdoe@example.org',
/// );
Expand Down
18 changes: 9 additions & 9 deletions packages/image_picker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import 'package:image_picker/image_picker.dart';
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => new _MyHomePageState();
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
Expand All @@ -46,19 +46,19 @@ class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('Image Picker Example'),
return Scaffold(
appBar: AppBar(
title: Text('Image Picker Example'),
),
body: new Center(
body: Center(
child: _image == null
? new Text('No image selected.')
: new Image.file(_image),
? Text('No image selected.')
: Image.file(_image),
),
floatingActionButton: new FloatingActionButton(
floatingActionButton: FloatingActionButton(
onPressed: getImage,
tooltip: 'Pick Image',
child: new Icon(Icons.add_a_photo),
child: Icon(Icons.add_a_photo),
),
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/local_auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ instructions will pop up to let the user set up fingerprint. If the user clicks
Use the exported APIs to trigger local authentication with default dialogs:

```dart
var localAuth = new LocalAuthentication();
var localAuth = LocalAuthentication();
bool didAuthenticate =
await localAuth.authenticateWithBiometrics(
localizedReason: 'Please authenticate to show account balance');
Expand Down
4 changes: 2 additions & 2 deletions packages/quick_actions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ Finally, manage the app's quick actions, for instance:

```dart
quickActions.setShortcutItems(<ShortcutItem>[
new quickActions.ShortcutItem(type: 'action_main', localizedTitle: 'Main view', icon: 'icon_main'),
new quickActions.ShortcutItem(type: 'action_help', localizedTitle: 'Help', icon: 'icon_help')
quickActions.ShortcutItem(type: 'action_main', localizedTitle: 'Main view', icon: 'icon_main'),
quickActions.ShortcutItem(type: 'action_help', localizedTitle: 'Help', icon: 'icon_help')
]);
```

Expand Down
Loading

0 comments on commit 60eeff0

Please sign in to comment.