diff --git a/dev/snippets/config/README.md b/dev/snippets/config/README.md new file mode 100644 index 000000000000..1c305b77130e --- /dev/null +++ b/dev/snippets/config/README.md @@ -0,0 +1,7 @@ +# Dartdoc Samples and Snippets + +The [snippets] tool uses the files in the `skeletons` directory to inject code +blocks generated from `{@tool dartpad}`, `{@tool sample}`, and `{@tool snippet}` +sections found in doc comments into the API docs. + +[snippet]: https://github.com/flutter/assets-for-api-docs/tree/master/packages/snippets diff --git a/dev/snippets/config/templates/README.md b/dev/snippets/config/templates/README.md deleted file mode 100644 index d30e12e699af..000000000000 --- a/dev/snippets/config/templates/README.md +++ /dev/null @@ -1,173 +0,0 @@ -## Templates are only used for Engine code samples. - -They should not be used in the Framework, since the code samples should reside -in the [`examples/api`](../../../../examples/api) directory. - -If you are creating engine code samples, the following document may be of -interest. - -Eventually, Engine code samples will also be converted to point to separate -files as the framework does. - -## Creating Code Snippets - -In general, creating application snippets can be accomplished with the following -syntax inside the dartdoc comment for a Flutter class/variable/enum/etc.: - -```dart -/// {@tool snippet} -/// Any text outside of the code blocks will be accumulated and placed at the -/// top of the snippet box as a description. Don't try and say "see the code -/// above" or "see the code below", since the location of the description may -/// change in the future. You can use dartdoc [Linking] in the description, and -/// __Markdown__ too. -/// -/// ```dart preamble -/// class Foo extends StatelessWidget { -/// const Foo({this.value = ''}); -/// -/// String value; -/// -/// @override -/// Widget build(BuildContext context) { -/// return Text(value); -/// } -/// } -/// ``` -/// This will get tacked on to the end of the description above, and shown above -/// the snippet. These two code blocks will be separated by `///...` in the -/// short version of the snippet code sample. -/// ```dart -/// String myValue = 'Foo'; -/// -/// @override -/// Widget build(BuildContext) { -/// return const Foo(myValue); -/// } -/// ``` -/// {@end-tool} -``` - -This will result in the template having the section that's inside "```dart" -interpolated into the template's stateful widget's state object body. - -For other sections of the template, the interpolation occurs by appending the string -that comes after `code-` into the code block. For example, the -[`stateful_widget`](stateful_widget.tmpl) template contains -`{{code-imports}}`. To interpolate code into `{{code-imports}}`, you would -have to do add the following: - -```dart -/// ```dart imports -/// import 'package:flutter/rendering.dart'; -/// ``` -``` - -All code within a code block in a snippet needs to be able to be run through -dartfmt without errors, so it needs to be valid code (This shouldn't be an -additional burden, since all code will also be compiled to be sure it compiles). - -## Available Templates - -The templates available for use as an argument to the snippets tool are as -follows: - -- [`freeform`](freeform.tmpl) : - This is a simple template for which you provide everything. It has no code of - its own, just the sections for `imports`, `main`, and `preamble`. You must - provide the `main` section to have a `main()`. - -### WidgetsApp Templates - -These templates create a `WidgetsApp` that encloses the snippet widget. These templates import -the widgets library. - -- [`stateful_widget`](stateful_widget.tmpl) : - The default code block will be placed as the body of the `State` object of a - `StatefulWidget` subclass. Because the default code block is placed as the body - of a stateful widget, you will need to implement the `build()` method and any - state variables. It also has a `preamble` in addition to the default code - block, which will be placed at the top level of the Dart file, so bare - method calls are not allowed in the preamble. The default code block is - placed as the body of a stateful widget, so you will need to implement the - `build()` method, and any state variables. It also has an `imports` - section to import additional packages. Please only import things that are part - of Flutter or part of default dependencies for a `flutter create` project. - -- [`stateful_widget_ticker`](stateful_widget_ticker.tmpl) : Identical to the - `stateful_widget` template, with the addition of the `TickerProviderStateMixin` - class, enabling easy generation of animated samples. - -- [`stateful_widget_restoration`](stateful_widget_restoration.tmpl) : Similar to - the `stateful_widget` template, but the widget also imports `RestorationMixin` - and has a `restorationId` field which it uses to implement the `restorationId` - getter on the `State`. - -- [`stateless_widget`](stateless_widget.tmpl) : Identical to the - `stateful_widget` template, except that the default code block is - inserted as a method (which should be the `build` method) in a - `StatelessWidget`. The `@override` before the build method is added by - the template so must be omitted from the sample code. - -### MaterialApp Templates - -These templates follow the same conventions as the `WidgetsApp` templates above but use a -`MaterialApp` instead. These templates import the material library. - -- [`stateful_widget_material`](stateful_widget_material.tmpl) - -- [`stateful_widget_material_ticker`](stateful_widget_material_ticker.tmpl) - -- [`stateless_widget_material`](stateless_widget_material.tmpl) - -- [`stateful_widget_restoration_material`](stateful_widget_restoration_material.tmpl) : - Similar to the `stateful_widget_restoration` template, but for `MaterialApp`. - -- [`stateless_widget_restoration_material`](stateful_widget_restoration_material.tmpl) : - Similar to the `stateless_widget` template, but the `MaterialApp` has `restorationScopeId` - defined. - -- [`stateful_widget_scaffold`](stateful_widget_scaffold.tmpl) : Adds a `Scaffold` widget as the home - of the enclosing `MaterialApp` to wrap the stateful widget snippet. The `Scaffold` widget contains - an `AppBar`. - -- [`stateful_widget_scaffold_center`](stateful_widget_scaffold_center.tmpl) : Similar to - `stateful_widget_scaffold`, except that it wraps the stateful widget with a `Center`. - -- [`stateful_widget_scaffold_center_freeform_state`](stateful_widget_scaffold_center_freeform_state.tmpl) : - Similar to `stateful_widget_scaffold_center` except that the code block has - to contain the entire state class defined as: - `class _MyStatefulWidgetState extends State` - -- [`stateless_widget_scaffold`](stateless_widget_scaffold.tmpl) : Similar to - `stateless_widget_material`, except that it wraps the stateless widget with a - `Scaffold`. - -- [`stateless_widget_scaffold_center`](stateless_widget_scaffold_center.tmpl) : Similar to - `stateless_widget_scaffold`, except that it wraps the stateless widget with a `Center`. - -### CupertinoApp Templates - -These templates follow the same conventions as the `WidgetsApp` templates above but use a -`CupertinoApp` instead. These templates import the Cupertino library. - -- [`stateful_widget_cupertino`](stateful_widget_cupertino.tmpl) - -- [`stateful_widget_cupertino_ticker`](stateful_widget_cupertino_ticker.tmpl) - -- [`stateless_widget_cupertino`](stateless_widget_cupertino.tmpl) - -- [`stateful_widget_cupertinoPageScaffold`](stateful_widget_cupertino_page_scaffold.tmpl) : Similar to - `stateful_widget_cupertino`, except that it wraps the stateful widget with a - `CupertinoPageScaffold`. - -- [`stateless_widget_cupertinoPageScaffold`](stateless_widget_cupertino_page_scaffold.tmpl) : Similar to - `stateless_widget_cupertino`, except that it wraps the stateless widget with a - `CupertinoPageScaffold`. - -- [`stateless_widget_restoration_cupertino`](stateful_widget_restoration_material.tmpl) : - Similar to the `stateless_widget` template, but the `CupertinoApp` has `restorationScopeId` - defined. - -- [`stateful_widget_restoration_cupertino`](stateful_widget_restoration_material.tmpl) : - Similar to the `stateful_widget_restoration` template, but for `CupertinoApp`. diff --git a/dev/snippets/config/templates/freeform.tmpl b/dev/snippets/config/templates/freeform.tmpl deleted file mode 100644 index ea4f7f081808..000000000000 --- a/dev/snippets/config/templates/freeform.tmpl +++ /dev/null @@ -1,12 +0,0 @@ -// Flutter code sample for {{element}} -// -{{description}} - -{{code-dartImports}} -{{code-imports}} - -{{code-main}} - -{{code-preamble}} - -{{code}} diff --git a/dev/snippets/config/templates/stateful_widget.tmpl b/dev/snippets/config/templates/stateful_widget.tmpl deleted file mode 100644 index 014f618e6d16..000000000000 --- a/dev/snippets/config/templates/stateful_widget.tmpl +++ /dev/null @@ -1,39 +0,0 @@ -// Flutter code sample for {{element}} -// -{{description}} - -{{code-dartImports}} - -import 'package:flutter/widgets.dart'; -{{code-imports}} - -void main() => runApp(const MyApp()); - -/// This is the main application widget. -class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return const WidgetsApp( - title: 'Flutter Code Sample', - home: MyStatefulWidget(), - color: Color(0xffffffff), - ); - } -} - -{{code-preamble}} - -/// This is the stateful widget that the main application instantiates. -class MyStatefulWidget extends StatefulWidget { - const MyStatefulWidget({Key? key}) : super(key: key); - - @override - State createState() => _MyStatefulWidgetState(); -} - -/// This is the private State class that goes with MyStatefulWidget. -class _MyStatefulWidgetState extends State { -{{code}} -} diff --git a/dev/snippets/config/templates/stateful_widget_cupertino.tmpl b/dev/snippets/config/templates/stateful_widget_cupertino.tmpl deleted file mode 100644 index e424cddcb3c1..000000000000 --- a/dev/snippets/config/templates/stateful_widget_cupertino.tmpl +++ /dev/null @@ -1,40 +0,0 @@ -// Flutter code sample for {{element}} -// -{{description}} - -{{code-dartImports}} - -import 'package:flutter/cupertino.dart'; -{{code-imports}} - -void main() => runApp(const MyApp()); - -/// This is the main application widget. -class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); - - static const String _title = 'Flutter Code Sample'; - - @override - Widget build(BuildContext context) { - return const CupertinoApp( - title: _title, - home: MyStatefulWidget(), - ); - } -} - -{{code-preamble}} - -/// This is the stateful widget that the main application instantiates. -class MyStatefulWidget extends StatefulWidget { - const MyStatefulWidget({Key? key}) : super(key: key); - - @override - State createState() => _MyStatefulWidgetState(); -} - -/// This is the private State class that goes with MyStatefulWidget. -class _MyStatefulWidgetState extends State { -{{code}} -} diff --git a/dev/snippets/config/templates/stateful_widget_cupertino_page_scaffold.tmpl b/dev/snippets/config/templates/stateful_widget_cupertino_page_scaffold.tmpl deleted file mode 100644 index 905f4da4d5ca..000000000000 --- a/dev/snippets/config/templates/stateful_widget_cupertino_page_scaffold.tmpl +++ /dev/null @@ -1,43 +0,0 @@ -// Flutter code sample for {{element}} -// -{{description}} - -{{code-dartImports}} - -import 'package:flutter/cupertino.dart'; -{{code-imports}} - -void main() => runApp(const MyApp()); - -/// This is the main application widget. -class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); - - static const String _title = 'Flutter Code Sample'; - - @override - Widget build(BuildContext context) { - return const CupertinoApp( - title: _title, - home: CupertinoPageScaffold( - navigationBar: CupertinoNavigationBar(middle: const Text(_title)), - child: MyStatefulWidget(), - ), - ); - } -} - -{{code-preamble}} - -/// This is the stateful widget that the main application instantiates. -class MyStatefulWidget extends StatefulWidget { - const MyStatefulWidget({Key? key}) : super(key: key); - - @override - State createState() => _MyStatefulWidgetState(); -} - -/// This is the private State class that goes with MyStatefulWidget. -class _MyStatefulWidgetState extends State { -{{code}} -} diff --git a/dev/snippets/config/templates/stateful_widget_cupertino_ticker.tmpl b/dev/snippets/config/templates/stateful_widget_cupertino_ticker.tmpl deleted file mode 100644 index 38c754798314..000000000000 --- a/dev/snippets/config/templates/stateful_widget_cupertino_ticker.tmpl +++ /dev/null @@ -1,41 +0,0 @@ -// Flutter code sample for {{element}} -// -{{description}} - -{{code-dartImports}} - -import 'package:flutter/cupertino.dart'; -{{code-imports}} - -void main() => runApp(const MyApp()); - -/// This is the main application widget. -class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); - - static const String _title = 'Flutter Code Sample'; - - @override - Widget build(BuildContext context) { - return const CupertinoApp( - title: _title, - home: MyStatefulWidget(), - ); - } -} - -{{code-preamble}} - -/// This is the stateful widget that the main application instantiates. -class MyStatefulWidget extends StatefulWidget { - const MyStatefulWidget({Key? key}) : super(key: key); - - @override - State createState() => _MyStatefulWidgetState(); -} - -/// This is the private State class that goes with MyStatefulWidget. -/// AnimationControllers can be created with `vsync: this` because of TickerProviderStateMixin. -class _MyStatefulWidgetState extends State with TickerProviderStateMixin { -{{code}} -} diff --git a/dev/snippets/config/templates/stateful_widget_material.tmpl b/dev/snippets/config/templates/stateful_widget_material.tmpl deleted file mode 100644 index fe916062875f..000000000000 --- a/dev/snippets/config/templates/stateful_widget_material.tmpl +++ /dev/null @@ -1,40 +0,0 @@ -// Flutter code sample for {{element}} -// -{{description}} - -{{code-dartImports}} - -import 'package:flutter/material.dart'; -{{code-imports}} - -void main() => runApp(const MyApp()); - -/// This is the main application widget. -class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); - - static const String _title = 'Flutter Code Sample'; - - @override - Widget build(BuildContext context) { - return const MaterialApp( - title: _title, - home: MyStatefulWidget(), - ); - } -} - -{{code-preamble}} - -/// This is the stateful widget that the main application instantiates. -class MyStatefulWidget extends StatefulWidget { - const MyStatefulWidget({Key? key}) : super(key: key); - - @override - State createState() => _MyStatefulWidgetState(); -} - -/// This is the private State class that goes with MyStatefulWidget. -class _MyStatefulWidgetState extends State { -{{code}} -} diff --git a/dev/snippets/config/templates/stateful_widget_material_ticker.tmpl b/dev/snippets/config/templates/stateful_widget_material_ticker.tmpl deleted file mode 100644 index 0357ff41a8bd..000000000000 --- a/dev/snippets/config/templates/stateful_widget_material_ticker.tmpl +++ /dev/null @@ -1,41 +0,0 @@ -// Flutter code sample for {{element}} -// -{{description}} - -{{code-dartImports}} - -import 'package:flutter/material.dart'; -{{code-imports}} - -void main() => runApp(const MyApp()); - -/// This is the main application widget. -class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); - - static const String _title = 'Flutter Code Sample'; - - @override - Widget build(BuildContext context) { - return const MaterialApp( - title: _title, - home: MyStatefulWidget(), - ); - } -} - -{{code-preamble}} - -/// This is the stateful widget that the main application instantiates. -class MyStatefulWidget extends StatefulWidget { - const MyStatefulWidget({Key? key}) : super(key: key); - - @override - State createState() => _MyStatefulWidgetState(); -} - -/// This is the private State class that goes with MyStatefulWidget. -/// AnimationControllers can be created with `vsync: this` because of TickerProviderStateMixin. -class _MyStatefulWidgetState extends State with TickerProviderStateMixin { -{{code}} -} diff --git a/dev/snippets/config/templates/stateful_widget_restoration.tmpl b/dev/snippets/config/templates/stateful_widget_restoration.tmpl deleted file mode 100644 index 2e8aee009542..000000000000 --- a/dev/snippets/config/templates/stateful_widget_restoration.tmpl +++ /dev/null @@ -1,50 +0,0 @@ -// Flutter code sample for {{element}} -// -{{description}} - -{{code-dartImports}} - -import 'package:flutter/material.dart'; -{{code-imports}} - -void main() => runApp(const MyApp()); - -/// This is the main application widget. -class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return WidgetsApp( - title: 'Flutter Code Sample', - color: const Color(0xffffffff), - builder: (BuildContext context, Widget? child) { - return const Center( - child: MyStatefulWidget(restorationId: 'main'), - ); - }, - ); - } -} -{{code-preamble}} - -/// This is the stateful widget that the main application instantiates. -class MyStatefulWidget extends StatefulWidget { - const MyStatefulWidget({Key? key, this.restorationId}) : super(key: key); - - final String? restorationId; - - @override - State createState() => _MyStatefulWidgetState(); -} - -/// This is the private State class that goes with MyStatefulWidget. -/// RestorationProperty objects can be used because of RestorationMixin. -class _MyStatefulWidgetState extends State with RestorationMixin { - // In this example, the restoration ID for the mixin is passed in through - // the [StatefulWidget]'s constructor. - @override - String? get restorationId => widget.restorationId; - -{{code}} -} diff --git a/dev/snippets/config/templates/stateful_widget_restoration_cupertino.tmpl b/dev/snippets/config/templates/stateful_widget_restoration_cupertino.tmpl deleted file mode 100644 index 3435e8c2a00a..000000000000 --- a/dev/snippets/config/templates/stateful_widget_restoration_cupertino.tmpl +++ /dev/null @@ -1,49 +0,0 @@ -// Flutter code sample for {{element}} -// -{{description}} - -{{code-dartImports}} - -import 'package:flutter/cupertino.dart'; -{{code-imports}} - -void main() => runApp(const MyApp()); - -/// This is the main application widget. -class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); - - static const String _title = 'Flutter Code Sample'; - - @override - Widget build(BuildContext context) { - return const CupertinoApp( - restorationScopeId: 'app', - title: _title, - home: MyStatefulWidget(restorationId: 'main'), - ); - } -} - -{{code-preamble}} - -/// This is the stateful widget that the main application instantiates. -class MyStatefulWidget extends StatefulWidget { - const MyStatefulWidget({Key? key, this.restorationId}) : super(key: key); - - final String? restorationId; - - @override - State createState() => _MyStatefulWidgetState(); -} - -/// This is the private State class that goes with MyStatefulWidget. -/// RestorationProperty objects can be used because of RestorationMixin. -class _MyStatefulWidgetState extends State with RestorationMixin { - // In this example, the restoration ID for the mixin is passed in through - // the [StatefulWidget]'s constructor. - @override - String? get restorationId => widget.restorationId; - -{{code}} -} diff --git a/dev/snippets/config/templates/stateful_widget_restoration_material.tmpl b/dev/snippets/config/templates/stateful_widget_restoration_material.tmpl deleted file mode 100644 index 11045ab5926b..000000000000 --- a/dev/snippets/config/templates/stateful_widget_restoration_material.tmpl +++ /dev/null @@ -1,49 +0,0 @@ -// Flutter code sample for {{element}} -// -{{description}} - -{{code-dartImports}} - -import 'package:flutter/material.dart'; -{{code-imports}} - -void main() => runApp(const MyApp()); - -/// This is the main application widget. -class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); - - static const String _title = 'Flutter Code Sample'; - - @override - Widget build(BuildContext context) { - return const MaterialApp( - restorationScopeId: 'app', - title: _title, - home: MyStatefulWidget(restorationId: 'main'), - ); - } -} - -{{code-preamble}} - -/// This is the stateful widget that the main application instantiates. -class MyStatefulWidget extends StatefulWidget { - const MyStatefulWidget({Key? key, this.restorationId}) : super(key: key); - - final String? restorationId; - - @override - State createState() => _MyStatefulWidgetState(); -} - -/// This is the private State class that goes with MyStatefulWidget. -/// RestorationProperty objects can be used because of RestorationMixin. -class _MyStatefulWidgetState extends State with RestorationMixin { - // In this example, the restoration ID for the mixin is passed in through - // the [StatefulWidget]'s constructor. - @override - String? get restorationId => widget.restorationId; - -{{code}} -} diff --git a/dev/snippets/config/templates/stateful_widget_scaffold.tmpl b/dev/snippets/config/templates/stateful_widget_scaffold.tmpl deleted file mode 100644 index bfc77b006e7d..000000000000 --- a/dev/snippets/config/templates/stateful_widget_scaffold.tmpl +++ /dev/null @@ -1,43 +0,0 @@ -// Flutter code sample for {{element}} -// -{{description}} - -{{code-dartImports}} - -import 'package:flutter/material.dart'; -{{code-imports}} - -void main() => runApp(const MyApp()); - -/// This is the main application widget. -class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); - - static const String _title = 'Flutter Code Sample'; - - @override - Widget build(BuildContext context) { - return MaterialApp( - title: _title, - home: Scaffold( - appBar: AppBar(title: const Text(_title)), - body: const MyStatefulWidget(), - ), - ); - } -} - -{{code-preamble}} - -/// This is the stateful widget that the main application instantiates. -class MyStatefulWidget extends StatefulWidget { - const MyStatefulWidget({Key? key}) : super(key: key); - - @override - State createState() => _MyStatefulWidgetState(); -} - -/// This is the private State class that goes with MyStatefulWidget. -class _MyStatefulWidgetState extends State { -{{code}} -} diff --git a/dev/snippets/config/templates/stateful_widget_scaffold_center.tmpl b/dev/snippets/config/templates/stateful_widget_scaffold_center.tmpl deleted file mode 100644 index bd6bc66b5124..000000000000 --- a/dev/snippets/config/templates/stateful_widget_scaffold_center.tmpl +++ /dev/null @@ -1,45 +0,0 @@ -// Flutter code sample for {{element}} -// -{{description}} - -{{code-dartImports}} - -import 'package:flutter/material.dart'; -{{code-imports}} - -void main() => runApp(const MyApp()); - -/// This is the main application widget. -class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); - - static const String _title = 'Flutter Code Sample'; - - @override - Widget build(BuildContext context) { - return MaterialApp( - title: _title, - home: Scaffold( - appBar: AppBar(title: const Text(_title)), - body: const Center( - child: MyStatefulWidget(), - ), - ), - ); - } -} - -{{code-preamble}} - -/// This is the stateful widget that the main application instantiates. -class MyStatefulWidget extends StatefulWidget { - const MyStatefulWidget({Key? key}) : super(key: key); - - @override - State createState() => _MyStatefulWidgetState(); -} - -/// This is the private State class that goes with MyStatefulWidget. -class _MyStatefulWidgetState extends State { -{{code}} -} diff --git a/dev/snippets/config/templates/stateful_widget_scaffold_center_freeform_state.tmpl b/dev/snippets/config/templates/stateful_widget_scaffold_center_freeform_state.tmpl deleted file mode 100644 index 1659319c4f3c..000000000000 --- a/dev/snippets/config/templates/stateful_widget_scaffold_center_freeform_state.tmpl +++ /dev/null @@ -1,43 +0,0 @@ -// Flutter code sample for {{element}} -// -{{description}} - -{{code-dartImports}} - -import 'package:flutter/material.dart'; -{{code-imports}} - -void main() => runApp(const MyApp()); - -/// This is the main application widget. -class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); - - static const String _title = 'Flutter Code Sample'; - - @override - Widget build(BuildContext context) { - return MaterialApp( - title: _title, - home: Scaffold( - appBar: AppBar(title: const Text(_title)), - body: const Center( - child: MyStatefulWidget(), - ), - ), - ); - } -} - -{{code-preamble}} - -/// This is the stateful widget that the main application instantiates. -class MyStatefulWidget extends StatefulWidget { - const MyStatefulWidget({Key? key}) : super(key: key); - - @override - State createState() => _MyStatefulWidgetState(); -} - -/// This is the private State class that goes with MyStatefulWidget. -{{code}} diff --git a/dev/snippets/config/templates/stateful_widget_ticker.tmpl b/dev/snippets/config/templates/stateful_widget_ticker.tmpl deleted file mode 100644 index ced2116ed567..000000000000 --- a/dev/snippets/config/templates/stateful_widget_ticker.tmpl +++ /dev/null @@ -1,40 +0,0 @@ -// Flutter code sample for {{element}} -// -{{description}} - -{{code-dartImports}} - -import 'package:flutter/widgets.dart'; -{{code-imports}} - -void main() => runApp(const MyApp()); - -/// This is the main application widget. -class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return const WidgetsApp( - title: 'Flutter Code Sample', - home: MyStatefulWidget(), - color: Color(0xffffffff), - ); - } -} - -{{code-preamble}} - -/// This is the stateful widget that the main application instantiates. -class MyStatefulWidget extends StatefulWidget { - const MyStatefulWidget({Key? key}) : super(key: key); - - @override - State createState() => _MyStatefulWidgetState(); -} - -/// This is the private State class that goes with MyStatefulWidget. -/// AnimationControllers can be created with `vsync: this` because of TickerProviderStateMixin. -class _MyStatefulWidgetState extends State with TickerProviderStateMixin { -{{code}} -} diff --git a/dev/snippets/config/templates/stateless_widget.tmpl b/dev/snippets/config/templates/stateless_widget.tmpl deleted file mode 100644 index c04e577423ca..000000000000 --- a/dev/snippets/config/templates/stateless_widget.tmpl +++ /dev/null @@ -1,34 +0,0 @@ -// Flutter code sample for {{element}} -// -{{description}} - -{{code-dartImports}} - -import 'package:flutter/widgets.dart'; -{{code-imports}} - -void main() => runApp(const MyApp()); - -/// This is the main application widget. -class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return WidgetsApp( - title: 'Flutter Code Sample', - builder: (BuildContext context, Widget? navigator) => const MyStatelessWidget(), - color: const Color(0xffffffff), - ); - } -} - -{{code-preamble}} - -/// This is the stateless widget that the main application instantiates. -class MyStatelessWidget extends StatelessWidget { - const MyStatelessWidget({Key? key}) : super(key: key); - - @override -{{code}} -} diff --git a/dev/snippets/config/templates/stateless_widget_cupertino.tmpl b/dev/snippets/config/templates/stateless_widget_cupertino.tmpl deleted file mode 100644 index 9eec77674821..000000000000 --- a/dev/snippets/config/templates/stateless_widget_cupertino.tmpl +++ /dev/null @@ -1,36 +0,0 @@ -// Flutter code sample for {{element}} -// -{{description}} - -{{code-dartImports}} - -import 'package:flutter/cupertino.dart'; -{{code-imports}} - -void main() => runApp(const MyApp()); - -/// This is the main application widget. -class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); - - static const String _title = 'Flutter Code Sample'; - - @override - Widget build(BuildContext context) { - return const CupertinoApp( - title: _title, - home: MyStatelessWidget(), - ); - } -} - - -{{code-preamble}} - -/// This is the stateless widget that the main application instantiates. -class MyStatelessWidget extends StatelessWidget { - const MyStatelessWidget({Key? key}) : super(key: key); - - @override -{{code}} -} diff --git a/dev/snippets/config/templates/stateless_widget_cupertino_page_scaffold.tmpl b/dev/snippets/config/templates/stateless_widget_cupertino_page_scaffold.tmpl deleted file mode 100644 index dd4552a82a7a..000000000000 --- a/dev/snippets/config/templates/stateless_widget_cupertino_page_scaffold.tmpl +++ /dev/null @@ -1,39 +0,0 @@ -// Flutter code sample for {{element}} -// -{{description}} - -{{code-dartImports}} - -import 'package:flutter/cupertino.dart'; -{{code-imports}} - -void main() => runApp(const MyApp()); - -/// This is the main application widget. -class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); - - static const String _title = 'Flutter Code Sample'; - - @override - Widget build(BuildContext context) { - return const CupertinoApp( - title: _title, - home: CupertinoPageScaffold( - navigationBar: CupertinoNavigationBar(middle: const Text(_title)), - body: MyStatelessWidget(), - ), - ); - } -} - - -{{code-preamble}} - -/// This is the stateless widget that the main application instantiates. -class MyStatelessWidget extends StatelessWidget { - const MyStatelessWidget({Key? key}) : super(key: key); - - @override -{{code}} -} diff --git a/dev/snippets/config/templates/stateless_widget_material.tmpl b/dev/snippets/config/templates/stateless_widget_material.tmpl deleted file mode 100644 index dc5e7a3c6ddc..000000000000 --- a/dev/snippets/config/templates/stateless_widget_material.tmpl +++ /dev/null @@ -1,36 +0,0 @@ -// Flutter code sample for {{element}} -// -{{description}} - -{{code-dartImports}} - -import 'package:flutter/material.dart'; -{{code-imports}} - -void main() => runApp(const MyApp()); - -/// This is the main application widget. -class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); - - static const String _title = 'Flutter Code Sample'; - - @override - Widget build(BuildContext context) { - return const MaterialApp( - title: _title, - home: MyStatelessWidget(), - ); - } -} - - -{{code-preamble}} - -/// This is the stateless widget that the main application instantiates. -class MyStatelessWidget extends StatelessWidget { - const MyStatelessWidget({Key? key}) : super(key: key); - - @override -{{code}} -} diff --git a/dev/snippets/config/templates/stateless_widget_restoration_cupertino.tmpl b/dev/snippets/config/templates/stateless_widget_restoration_cupertino.tmpl deleted file mode 100644 index 975654ac96d3..000000000000 --- a/dev/snippets/config/templates/stateless_widget_restoration_cupertino.tmpl +++ /dev/null @@ -1,36 +0,0 @@ -// Flutter code sample for {{element}} -// -{{description}} - -{{code-dartImports}} - -import 'package:flutter/cupertino.dart'; -{{code-imports}} - -void main() => runApp(const MyApp()); - -/// This is the main application widget. -class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); - - static const String _title = 'Flutter Code Sample'; - - @override - Widget build(BuildContext context) { - return const CupertinoApp( - restorationScopeId: 'app', - title: _title, - home: MyStatelessWidget(), - ); - } -} - -{{code-preamble}} - -/// This is the stateless widget that the main application instantiates. -class MyStatelessWidget extends StatelessWidget { - const MyStatelessWidget({Key? key}) : super(key: key); - - @override -{{code}} -} diff --git a/dev/snippets/config/templates/stateless_widget_restoration_material.tmpl b/dev/snippets/config/templates/stateless_widget_restoration_material.tmpl deleted file mode 100644 index 5e34280dbd18..000000000000 --- a/dev/snippets/config/templates/stateless_widget_restoration_material.tmpl +++ /dev/null @@ -1,36 +0,0 @@ -// Flutter code sample for {{element}} -// -{{description}} - -{{code-dartImports}} - -import 'package:flutter/material.dart'; -{{code-imports}} - -void main() => runApp(const MyApp()); - -/// This is the main application widget. -class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); - - static const String _title = 'Flutter Code Sample'; - - @override - Widget build(BuildContext context) { - return const MaterialApp( - restorationScopeId: 'app', - title: _title, - home: MyStatelessWidget(), - ); - } -} - -{{code-preamble}} - -/// This is the stateless widget that the main application instantiates. -class MyStatelessWidget extends StatelessWidget { - const MyStatelessWidget({Key? key}) : super(key: key); - - @override -{{code}} -} diff --git a/dev/snippets/config/templates/stateless_widget_scaffold.tmpl b/dev/snippets/config/templates/stateless_widget_scaffold.tmpl deleted file mode 100644 index 834656e34877..000000000000 --- a/dev/snippets/config/templates/stateless_widget_scaffold.tmpl +++ /dev/null @@ -1,39 +0,0 @@ -// Flutter code sample for {{element}} -// -{{description}} - -{{code-dartImports}} - -import 'package:flutter/material.dart'; -{{code-imports}} - -void main() => runApp(const MyApp()); - -/// This is the main application widget. -class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); - - static const String _title = 'Flutter Code Sample'; - - @override - Widget build(BuildContext context) { - return MaterialApp( - title: _title, - home: Scaffold( - appBar: AppBar(title: const Text(_title)), - body: const MyStatelessWidget(), - ), - ); - } -} - - -{{code-preamble}} - -/// This is the stateless widget that the main application instantiates. -class MyStatelessWidget extends StatelessWidget { - const MyStatelessWidget({Key? key}) : super(key: key); - - @override -{{code}} -} diff --git a/dev/snippets/config/templates/stateless_widget_scaffold_center.tmpl b/dev/snippets/config/templates/stateless_widget_scaffold_center.tmpl deleted file mode 100644 index 85eb7a56ed17..000000000000 --- a/dev/snippets/config/templates/stateless_widget_scaffold_center.tmpl +++ /dev/null @@ -1,41 +0,0 @@ -// Flutter code sample for {{element}} -// -{{description}} - -{{code-dartImports}} - -import 'package:flutter/material.dart'; -{{code-imports}} - -void main() => runApp(const MyApp()); - -/// This is the main application widget. -class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); - - static const String _title = 'Flutter Code Sample'; - - @override - Widget build(BuildContext context) { - return MaterialApp( - title: _title, - home: Scaffold( - appBar: AppBar(title: const Text(_title)), - body: const Center( - child: MyStatelessWidget(), - ), - ), - ); - } -} - - -{{code-preamble}} - -/// This is the stateless widget that the main application instantiates. -class MyStatelessWidget extends StatelessWidget { - const MyStatelessWidget({Key? key}) : super(key: key); - - @override -{{code}} -}