stateful_widget_scaffold_center.tmpl 1.02 KB
Newer Older
1 2
// Flutter code sample for {{element}}
//
3 4
{{description}}

5
{{code-dartImports}}
6

7
import 'package:flutter/material.dart';
8 9
{{code-imports}}

10
void main() => runApp(const MyApp());
11

12
/// This is the main application widget.
13
class MyApp extends StatelessWidget {
14 15
  const MyApp({Key? key}) : super(key: key);

16 17 18 19 20 21 22 23
  static const String _title = 'Flutter Code Sample';

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: _title,
      home: Scaffold(
        appBar: AppBar(title: const Text(_title)),
24
        body: const Center(
25 26 27 28 29 30 31 32 33
          child: MyStatefulWidget(),
        ),
      ),
    );
  }
}

{{code-preamble}}

34
/// This is the stateful widget that the main application instantiates.
35
class MyStatefulWidget extends StatefulWidget {
36
  const MyStatefulWidget({Key? key}) : super(key: key);
37 38

  @override
39
  State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
40 41
}

42
/// This is the private State class that goes with MyStatefulWidget.
43
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
44
{{code}}
45
}