[Docs] Create 'center' snippets template (#40367)

* Create 'center' template
This commit is contained in:
MH Johnson
2019-09-15 20:38:44 -04:00
committed by GitHub
parent 0ef89bb969
commit 0d3bb515f3
12 changed files with 277 additions and 228 deletions

View File

@@ -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`.

View File

@@ -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}}
}

View File

@@ -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}}
}