Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
f89814b0
Unverified
Commit
f89814b0
authored
Jul 09, 2020
by
Kate Lovett
Committed by
GitHub
Jul 09, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding CupertinoApp Sample templates (#60929)
parent
d4589e0c
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
296 additions
and
37 deletions
+296
-37
README.md
dev/snippets/config/templates/README.md
+42
-15
freeform.tmpl
dev/snippets/config/templates/freeform.tmpl
+1
-1
stateful_widget.tmpl
dev/snippets/config/templates/stateful_widget.tmpl
+3
-3
stateful_widget_cupertino.tmpl
dev/snippets/config/templates/stateful_widget_cupertino.tmpl
+37
-0
stateful_widget_cupertino_page_scaffold.tmpl
...ig/templates/stateful_widget_cupertino_page_scaffold.tmpl
+40
-0
stateful_widget_cupertino_ticker.tmpl
...ts/config/templates/stateful_widget_cupertino_ticker.tmpl
+38
-0
stateful_widget_material.tmpl
dev/snippets/config/templates/stateful_widget_material.tmpl
+4
-2
stateful_widget_material_ticker.tmpl
...ets/config/templates/stateful_widget_material_ticker.tmpl
+5
-2
stateful_widget_scaffold.tmpl
dev/snippets/config/templates/stateful_widget_scaffold.tmpl
+4
-2
stateful_widget_scaffold_center.tmpl
...ets/config/templates/stateful_widget_scaffold_center.tmpl
+4
-2
stateful_widget_scaffold_center_freeform_state.tmpl
...lates/stateful_widget_scaffold_center_freeform_state.tmpl
+4
-2
stateful_widget_ticker.tmpl
dev/snippets/config/templates/stateful_widget_ticker.tmpl
+37
-0
stateless_widget.tmpl
dev/snippets/config/templates/stateless_widget.tmpl
+2
-2
stateless_widget_cupertino.tmpl
...snippets/config/templates/stateless_widget_cupertino.tmpl
+33
-0
stateless_widget_cupertino_page_scaffold.tmpl
...g/templates/stateless_widget_cupertino_page_scaffold.tmpl
+36
-0
stateless_widget_material.tmpl
dev/snippets/config/templates/stateless_widget_material.tmpl
+2
-2
stateless_widget_scaffold.tmpl
dev/snippets/config/templates/stateless_widget_scaffold.tmpl
+2
-2
stateless_widget_scaffold_center.tmpl
...ts/config/templates/stateless_widget_scaffold_center.tmpl
+2
-2
No files found.
dev/snippets/config/templates/README.md
View file @
f89814b0
...
...
@@ -65,6 +65,11 @@ follows:
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 in order 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
...
...
@@ -77,7 +82,10 @@ follows:
`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.
It creates a
`WidgetsApp`
around the child stateful widget.
-
[
`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.
-
[
`stateless_widget`
](
stateless_widget.tmpl
)
: Identical to the
`stateful_widget`
template, except that the default code block is
...
...
@@ -85,21 +93,23 @@ follows:
`StatelessWidget`
. The
`@override`
before the build method is added by
the template, so must be omitted from the sample code.
-
[
`stateful_widget_material`
](
stateful_widget_material.tmpl
)
: Similar to
`stateful_widget`
, except that it imports the material library, and uses
a
`MaterialApp`
instead of
`WidgetsApp`
.
### MaterialApp Templates
-
[
`stateless_widget_material`
](
stateless_widget_material.tmpl
)
: Similar to
`stateless_widget`
, except that it imports the material library, and uses
a
`MaterialApp`
instead of
`WidgetsApp`
.
These templates follow the same conventions as the
`WidgetsApp`
templates above, but use a
`MaterialApp`
instead. These templates import the material library.
-
[
`stateful_widget_scaffold`
](
stateful_widget_scaffold.tmpl
)
: Similar to
`stateful_widget_material`
, except that it wraps the stateful widget with a
`Scaffold`
.
-
[
`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_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
`Scaffold`
_and_ a
`Center`
.
`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
...
...
@@ -111,6 +121,23 @@ follows:
`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`
.
`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`
.
dev/snippets/config/templates/freeform.tmpl
View file @
f89814b0
// Flutter code sample for {{element}}
//
/
Flutter code sample for {{element}}
{{description}}
...
...
dev/snippets/config/templates/stateful_widget.tmpl
View file @
f89814b0
// Flutter code sample for {{element}}
//
/
Flutter code sample for {{element}}
{{description}}
...
...
@@ -8,7 +8,7 @@ import 'package:flutter/widgets.dart';
void main() => runApp(new MyApp());
/// This
Widget
is the main application widget.
/// This is the main application widget.
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
...
...
@@ -30,7 +30,7 @@ class MyStatefulWidget extends StatefulWidget {
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
}
// This is the private State class that goes with MyStatefulWidget.
//
/
This is the private State class that goes with MyStatefulWidget.
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
{{code}}
}
dev/snippets/config/templates/stateful_widget_cupertino.tmpl
0 → 100644
View file @
f89814b0
/// Flutter code sample for {{element}}
{{description}}
import 'package:flutter/cupertino.dart';
{{code-imports}}
void main() => runApp(new MyApp());
/// This is the main application widget.
class MyApp extends StatelessWidget {
static const String _title = 'Flutter Code Sample';
@override
Widget build(BuildContext context) {
return CupertinoApp(
title: _title,
home: MyStatefulWidget(),
);
}
}
{{code-preamble}}
/// This is the stateful widget that the main application instantiates.
class MyStatefulWidget extends StatefulWidget {
MyStatefulWidget({Key key}) : super(key: key);
@override
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
}
/// This is the private State class that goes with MyStatefulWidget.
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
{{code}}
}
dev/snippets/config/templates/stateful_widget_cupertino_page_scaffold.tmpl
0 → 100644
View file @
f89814b0
/// Flutter code sample for {{element}}
{{description}}
import 'package:flutter/cupertino.dart';
{{code-imports}}
void main() => runApp(new MyApp());
/// This is the main application widget.
class MyApp extends StatelessWidget {
static const String _title = 'Flutter Code Sample';
@override
Widget build(BuildContext context) {
return 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 {
MyStatefulWidget({Key key}) : super(key: key);
@override
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
}
/// This is the private State class that goes with MyStatefulWidget.
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
{{code}}
}
dev/snippets/config/templates/stateful_widget_cupertino_ticker.tmpl
0 → 100644
View file @
f89814b0
/// Flutter code sample for {{element}}
{{description}}
import 'package:flutter/cupertino.dart';
{{code-imports}}
void main() => runApp(new MyApp());
/// This is the main application widget.
class MyApp extends StatelessWidget {
static const String _title = 'Flutter Code Sample';
@override
Widget build(BuildContext context) {
return CupertinoApp(
title: _title,
home: MyStatefulWidget(),
);
}
}
{{code-preamble}}
/// This is the stateful widget that the main application instantiates.
class MyStatefulWidget extends StatefulWidget {
MyStatefulWidget({Key key}) : super(key: key);
@override
_MyStatefulWidgetState 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<MyStatefulWidget> with TickerProviderStateMixin {
{{code}}
}
dev/snippets/config/templates/stateful_widget_material.tmpl
View file @
f89814b0
// Flutter code sample for {{element}}
//
/
Flutter code sample for {{element}}
{{description}}
...
...
@@ -8,7 +8,7 @@ import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
/// This
Widget
is the main application widget.
/// This is the main application widget.
class MyApp extends StatelessWidget {
static const String _title = 'Flutter Code Sample';
...
...
@@ -23,6 +23,7 @@ class MyApp extends StatelessWidget {
{{code-preamble}}
/// This is the stateful widget that the main application instantiates.
class MyStatefulWidget extends StatefulWidget {
MyStatefulWidget({Key key}) : super(key: key);
...
...
@@ -30,6 +31,7 @@ class MyStatefulWidget extends StatefulWidget {
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
}
/// This is the private State class that goes with MyStatefulWidget.
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
{{code}}
}
dev/snippets/config/templates/stateful_widget_material_ticker.tmpl
View file @
f89814b0
// Flutter code sample for {{element}}
//
/
Flutter code sample for {{element}}
{{description}}
...
...
@@ -8,7 +8,7 @@ import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
/// This
Widget
is the main application widget.
/// This is the main application widget.
class MyApp extends StatelessWidget {
static const String _title = 'Flutter Code Sample';
...
...
@@ -23,6 +23,7 @@ class MyApp extends StatelessWidget {
{{code-preamble}}
/// This is the stateful widget that the main application instantiates.
class MyStatefulWidget extends StatefulWidget {
MyStatefulWidget({Key key}) : super(key: key);
...
...
@@ -30,6 +31,8 @@ class MyStatefulWidget extends StatefulWidget {
_MyStatefulWidgetState 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<MyStatefulWidget> with TickerProviderStateMixin {
{{code}}
}
dev/snippets/config/templates/stateful_widget_scaffold.tmpl
View file @
f89814b0
// Flutter code sample for {{element}}
//
/
Flutter code sample for {{element}}
{{description}}
...
...
@@ -8,7 +8,7 @@ import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
/// This
Widget
is the main application widget.
/// This is the main application widget.
class MyApp extends StatelessWidget {
static const String _title = 'Flutter Code Sample';
...
...
@@ -26,6 +26,7 @@ class MyApp extends StatelessWidget {
{{code-preamble}}
/// This is the stateful widget that the main application instantiates.
class MyStatefulWidget extends StatefulWidget {
MyStatefulWidget({Key key}) : super(key: key);
...
...
@@ -33,6 +34,7 @@ class MyStatefulWidget extends StatefulWidget {
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
}
/// This is the private State class that goes with MyStatefulWidget.
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
{{code}}
}
dev/snippets/config/templates/stateful_widget_scaffold_center.tmpl
View file @
f89814b0
// Flutter code sample for {{element}}
//
/
Flutter code sample for {{element}}
{{description}}
...
...
@@ -8,7 +8,7 @@ import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
/// This
Widget
is the main application widget.
/// This is the main application widget.
class MyApp extends StatelessWidget {
static const String _title = 'Flutter Code Sample';
...
...
@@ -28,6 +28,7 @@ class MyApp extends StatelessWidget {
{{code-preamble}}
/// This is the stateful widget that the main application instantiates.
class MyStatefulWidget extends StatefulWidget {
MyStatefulWidget({Key key}) : super(key: key);
...
...
@@ -35,6 +36,7 @@ class MyStatefulWidget extends StatefulWidget {
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
}
/// This is the private State class that goes with MyStatefulWidget.
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
{{code}}
}
dev/snippets/config/templates/stateful_widget_scaffold_center_freeform_state.tmpl
View file @
f89814b0
// Flutter code sample for {{element}}
//
/
Flutter code sample for {{element}}
{{description}}
...
...
@@ -8,7 +8,7 @@ import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
/// This
Widget
is the main application widget.
/// This is the main application widget.
class MyApp extends StatelessWidget {
static const String _title = 'Flutter Code Sample';
...
...
@@ -28,6 +28,7 @@ class MyApp extends StatelessWidget {
{{code-preamble}}
/// This is the stateful widget that the main application instantiates.
class MyStatefulWidget extends StatefulWidget {
MyStatefulWidget({Key key}) : super(key: key);
...
...
@@ -35,4 +36,5 @@ class MyStatefulWidget extends StatefulWidget {
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
}
/// This is the private State class that goes with MyStatefulWidget.
{{code}}
dev/snippets/config/templates/stateful_widget_ticker.tmpl
0 → 100644
View file @
f89814b0
/// Flutter code sample for {{element}}
{{description}}
import 'package:flutter/widgets.dart';
{{code-imports}}
void main() => runApp(new MyApp());
/// This is the main application widget.
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return WidgetsApp(
title: 'Flutter Code Sample',
home: MyStatefulWidget(),
color: const Color(0xffffffff),
);
}
}
{{code-preamble}}
/// This is the stateful widget that the main application instantiates.
class MyStatefulWidget extends StatefulWidget {
MyStatefulWidget({Key key}) : super(key: key);
@override
_MyStatefulWidgetState 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<MyStatefulWidget> with TickerProviderStateMixin {
{{code}}
}
dev/snippets/config/templates/stateless_widget.tmpl
View file @
f89814b0
// Flutter code sample for {{element}}
//
/
Flutter code sample for {{element}}
{{description}}
...
...
@@ -8,7 +8,7 @@ import 'package:flutter/widgets.dart';
void main() => runApp(new MyApp());
/// This
Widget
is the main application widget.
/// This is the main application widget.
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
...
...
dev/snippets/config/templates/stateless_widget_cupertino.tmpl
0 → 100644
View file @
f89814b0
/// Flutter code sample for {{element}}
{{description}}
import 'package:flutter/cupertino.dart';
{{code-imports}}
void main() => runApp(new MyApp());
/// This is the main application widget.
class MyApp extends StatelessWidget {
static const String _title = 'Flutter Code Sample';
@override
Widget build(BuildContext context) {
return CupertinoApp(
title: _title,
home: 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}}
}
dev/snippets/config/templates/stateless_widget_cupertino_page_scaffold.tmpl
0 → 100644
View file @
f89814b0
/// Flutter code sample for {{element}}
{{description}}
import 'package:flutter/cupertino.dart';
{{code-imports}}
void main() => runApp(new MyApp());
/// This is the main application widget.
class MyApp extends StatelessWidget {
static const String _title = 'Flutter Code Sample';
@override
Widget build(BuildContext context) {
return 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 {
MyStatelessWidget({Key key}) : super(key: key);
@override
{{code}}
}
dev/snippets/config/templates/stateless_widget_material.tmpl
View file @
f89814b0
// Flutter code sample for {{element}}
//
/
Flutter code sample for {{element}}
{{description}}
...
...
@@ -8,7 +8,7 @@ import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
/// This
Widget
is the main application widget.
/// This is the main application widget.
class MyApp extends StatelessWidget {
static const String _title = 'Flutter Code Sample';
...
...
dev/snippets/config/templates/stateless_widget_scaffold.tmpl
View file @
f89814b0
// Flutter code sample for {{element}}
//
/
Flutter code sample for {{element}}
{{description}}
...
...
@@ -8,7 +8,7 @@ import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
/// This
Widget
is the main application widget.
/// This is the main application widget.
class MyApp extends StatelessWidget {
static const String _title = 'Flutter Code Sample';
...
...
dev/snippets/config/templates/stateless_widget_scaffold_center.tmpl
View file @
f89814b0
// Flutter code sample for {{element}}
//
/
Flutter code sample for {{element}}
{{description}}
...
...
@@ -8,7 +8,7 @@ import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
/// This
Widget
is the main application widget.
/// This is the main application widget.
class MyApp extends StatelessWidget {
static const String _title = 'Flutter Code Sample';
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment