[Docs] Create 'center' snippets template (#40367)
* Create 'center' template
This commit is contained in:
@@ -97,6 +97,15 @@ follows:
|
||||
`stateful_widget_material`, except that it wraps the stateful widget with a
|
||||
`Scaffold`.
|
||||
|
||||
- [`stateful_widget_scaffold_center`](stateful_widget_scaffold_center.tmpl) : Similar to
|
||||
`stateful_widget_scaffold`, except that it wraps the stateful widget with a
|
||||
`Scaffold` _and_ a `Center`.
|
||||
|
||||
- [`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
|
||||
`Scaffold` _and_ a `Center`.
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
// Flutter code sample for {{id}}
|
||||
|
||||
{{description}}
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
{{code-imports}}
|
||||
|
||||
void main() => runApp(new MyApp());
|
||||
|
||||
/// This Widget is the main application widget.
|
||||
class MyApp extends StatelessWidget {
|
||||
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: Center(
|
||||
child: MyStatefulWidget(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
{{code-preamble}}
|
||||
|
||||
class MyStatefulWidget extends StatefulWidget {
|
||||
MyStatefulWidget({Key key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
|
||||
}
|
||||
|
||||
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
{{code}}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
// Flutter code sample for {{id}}
|
||||
|
||||
{{description}}
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
{{code-imports}}
|
||||
|
||||
void main() => runApp(new MyApp());
|
||||
|
||||
/// This Widget is the main application widget.
|
||||
class MyApp extends StatelessWidget {
|
||||
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: Center(
|
||||
child: MyStatelessWidget(),
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{{code-preamble}}
|
||||
|
||||
/// This is the stateless widget that the main application instantiates.
|
||||
class MyStatelessWidget extends StatelessWidget {
|
||||
MyStatelessWidget({Key key}) : super(key: key);
|
||||
|
||||
@override
|
||||
{{code}}
|
||||
}
|
||||
Reference in New Issue
Block a user