flutter/dev/snippets/config/templates/stateless_widget_restoration_material.tmpl
Shi-Hao Hong 49adef6792
[State Restoration] Code sample templates, migrate existing code samples (#78757)
* Create state restoration templates, 

* Update existing state restoration samples to use the new templates

* Add to README, decided to require stateful widgets to include RestorationMixin
2021-03-23 09:24:34 +08:00

37 lines
764 B
Cheetah

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