Unverified Commit fb28a0d3 authored by Greg Spencer's avatar Greg Spencer Committed by GitHub

Re-Land "Actually add example templates (#111531)" (#111666)

parent 2c1b32b8
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This is a template file for illustrating best practices when creating a
// Flutter API example that uses the Cupertino library. To use it, copy the file
// to your destination filename, search/replace 'Placeholder' with the name of
// the class this is an example for, delete this block, and implement your
// example.
//
// The name and location of this file should be:
//
// examples/api/lib/<library>/<filename_without_dart>/<lower_snake_symbol>.<index>.dart
//
// So, if your example is the third example of the Foo.bar function in the
// "baz.dart" file in the cupertino library, then the filename for your example
// should be:
//
// examples/api/lib/cupertino/baz/foo_bar.2.dart
//
// and its associated test should be in:
//
// examples/api/test/cupertino/baz/foo_bar.2_test.dart
//
// The following doc comment should remain, and be a doc comment so that the
// symbol will be linked in the IDE. Don't use the whole description of the
// example, since that should already be in the API docs where this example is
// referenced, and we don't want the two descriptions to diverge. If this sample
// is referenced more than once, link back to the instance the example file is
// named for.
/// Flutter code sample for [Placeholder].
import 'package:flutter/cupertino.dart';
void main() {
runApp(const SampleApp());
}
class SampleApp extends StatelessWidget {
const SampleApp({super.key});
@override
Widget build(BuildContext context) {
return const CupertinoApp(
home: PlaceholderExample(),
);
}
}
/// Include comments about each class, and make them dartdoc comments, so that
/// links (e.g. [Placeholder]) are active in IDEs.
///
/// Name the classes appropriately for the example (don't leave it as
/// "PlaceholderExample"!).
class PlaceholderExample extends StatelessWidget {
const PlaceholderExample({super.key});
@override
Widget build(BuildContext context) {
// Since this is an example, add plenty of comments, explaining things that
// both a newcomer and an experienced user might want to know.
//
// TRY THIS: Prefix things with "TRY THIS" in places in the example that
// might be interesting to modify when exploring what the code does.
return const Placeholder();
}
}
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This is a template file for illustrating best practices when creating a
// Flutter API example that uses the Material library. To use it, copy the file
// to your destination filename, search/replace 'Placeholder' with the name of
// the class this is an example for, delete this block, and implement your
// example.
//
// The name and location of this file should be:
//
// examples/api/lib/<library>/<filename_without_dart>/<lower_snake_symbol>.<index>.dart
//
// So, if your example is the third example of the Foo.bar function in the
// "baz.dart" file in the material library, then the filename for your example
// should be:
//
// examples/api/lib/material/baz/foo_bar.2.dart
//
// and its associated test should be in:
//
// examples/api/test/material/baz/foo_bar.2_test.dart
//
// The following doc comment should remain, and be a doc comment so that the
// symbol will be linked in the IDE. Don't use the whole description of the
// example, since that should already be in the API docs where this example is
// referenced, and we don't want the two descriptions to diverge. If this sample
// is referenced more than once, link back to the instance the example file is
// named for.
/// Flutter code sample for [Placeholder].
import 'package:flutter/material.dart';
void main() {
runApp(const SampleApp());
}
class SampleApp extends StatelessWidget {
const SampleApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: Scaffold(
body: PlaceholderExample(),
),
);
}
}
/// Include comments about each class, and make them dartdoc comments, so that
/// links (e.g. [Placeholder]) are active in IDEs.
///
/// Name the classes appropriately for the example (don't leave it as
/// "PlaceholderExample"!).
class PlaceholderExample extends StatelessWidget {
const PlaceholderExample({super.key});
@override
Widget build(BuildContext context) {
// Since this is an example, add plenty of comments, explaining things that
// both a newcomer and an experienced user might want to know.
//
// TRY THIS: Prefix things with "TRY THIS" in places in the example that
// might be interesting to modify when exploring what the code does.
return const Placeholder();
}
}
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This is a template file for illustrating best practices when creating a
// Flutter API example that uses the Widgets library. To use it, copy the file
// to your destination filename, search/replace 'Placeholder' with the name of
// the class this is an example for, delete this block, and implement your
// example.
//
// The name and location of this file should be:
//
// examples/api/lib/<library>/<filename_without_dart>/<lower_snake_symbol>.<index>.dart
//
// So, if your example is the third example of the Foo.bar function in the
// "baz.dart" file in the widgets library, then the filename for your example
// should be:
//
// examples/api/lib/widgets/baz/foo_bar.2.dart
//
// and its (required) associated test should be in:
//
// examples/api/test/widgets/baz/foo_bar.2_test.dart
//
// The following doc comment should remain, and be a doc comment so that the
// symbol will be linked in the IDE. Don't use the whole description of the
// example, since that should already be in the API docs where this example is
// referenced, and we don't want the two descriptions to diverge. If this sample
// is referenced more than once, link back to the instance the example file is
// named for.
/// Flutter code sample for [Placeholder].
import 'package:flutter/widgets.dart';
void main() {
runApp(const SampleApp());
}
class SampleApp extends StatelessWidget {
const SampleApp({super.key});
@override
Widget build(BuildContext context) {
return WidgetsApp(
color: const Color(0xffffffff),
builder: (BuildContext context, Widget? child) {
return const PlaceholderExample();
},
);
}
}
/// Include comments about each class, and make them dartdoc comments, so that
/// links (e.g. [Placeholder]) are active in IDEs.
///
/// Name the classes appropriately for the example (don't leave it as
/// "PlaceholderExample"!).
class PlaceholderExample extends StatelessWidget {
const PlaceholderExample({super.key});
@override
Widget build(BuildContext context) {
// Since this is an example, add plenty of comments, explaining things that
// both a newcomer and an experienced user might want to know.
//
// TRY THIS: Prefix things with "TRY THIS" in places in the example that
// might be interesting to modify when exploring what the code does.
return const Placeholder();
}
}
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/cupertino.dart';
import 'package:flutter_api_samples/sample_templates/cupertino.0.dart' as example;
import 'package:flutter_test/flutter_test.dart';
// This is an example of a test for API example code.
//
// It only tests that the example is presenting what it is supposed to, but you
// should also test the basic functionality of the example to make sure that it
// functions as expected.
void main() {
testWidgets('Example app has a placeholder', (WidgetTester tester) async {
await tester.pumpWidget(
const example.SampleApp(),
);
expect(find.byType(Placeholder), findsOneWidget);
});
}
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:flutter_api_samples/sample_templates/material.0.dart' as example;
import 'package:flutter_test/flutter_test.dart';
// This is an example of a test for API example code.
//
// It only tests that the example is presenting what it is supposed to, but you
// should also test the basic functionality of the example to make sure that it
// functions as expected.
void main() {
testWidgets('Example app has a placeholder', (WidgetTester tester) async {
await tester.pumpWidget(
const example.SampleApp(),
);
expect(find.byType(Scaffold), findsOneWidget);
expect(find.byType(Placeholder), findsOneWidget);
});
}
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/widgets.dart';
import 'package:flutter_api_samples/sample_templates/widgets.0.dart' as example;
import 'package:flutter_test/flutter_test.dart';
// This is an example of a test for API example code.
//
// It only tests that the example is presenting what it is supposed to, but you
// should also test the basic functionality of the example to make sure that it
// functions as expected.
void main() {
testWidgets('Example app has a placeholder', (WidgetTester tester) async {
await tester.pumpWidget(
const example.SampleApp(),
);
expect(find.byType(Placeholder), findsOneWidget);
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment