Rename Sample classes (#124080)

Rename Sample classes
This commit is contained in:
Greg Spencer
2023-04-04 13:34:29 -07:00
committed by GitHub
parent c8a3dbaf06
commit e3bc8efd39
480 changed files with 3125 additions and 3816 deletions

View File

@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [SharedAppData].
import 'package:flutter/material.dart';
/// Flutter code sample for [SharedAppData].
class ShowSharedValue extends StatelessWidget {
const ShowSharedValue({ super.key, required this.appDataKey });
const ShowSharedValue({super.key, required this.appDataKey});
final String appDataKey;
@@ -25,7 +25,7 @@ class ShowSharedValue extends StatelessWidget {
// widgets to be rebuilt. In this case that's the ShowSharedValue widget that's
// displaying the value of a key whose value has been updated.
class Home extends StatefulWidget {
const Home({ super.key });
const Home({super.key});
@override
State<Home> createState() => _HomeState();
@@ -52,7 +52,8 @@ class _HomeState extends State<Home> {
_fooVersion += 1;
// Changing the SharedAppData's value for 'foo' causes the
// widgets that depend on 'foo' to be rebuilt.
SharedAppData.setValue<String, String?>(context, 'foo', 'FOO $_fooVersion'); // no need to call setState()
SharedAppData.setValue<String, String?>(
context, 'foo', 'FOO $_fooVersion'); // no need to call setState()
},
),
const SizedBox(height: 16),
@@ -60,7 +61,8 @@ class _HomeState extends State<Home> {
child: const Text('change bar'),
onPressed: () {
_barVersion += 1;
SharedAppData.setValue<String, String?>(context, 'bar', 'BAR $_barVersion'); // no need to call setState()
SharedAppData.setValue<String, String?>(
context, 'bar', 'BAR $_barVersion'); // no need to call setState()
},
),
],

View File

@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [SharedAppData].
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
/// Flutter code sample for [SharedAppData].
// A single lazily-constructed object that's shared with the entire application
// via `SharedObject.of(context)`. The value of the object can be changed with
// `SharedObject.reset(context)`. Resetting the value will cause all of the
@@ -34,7 +34,7 @@ class SharedObject {
// An example of a widget which depends on the SharedObject's value, which might
// be provided - along with SharedObject - in a Dart package.
class CustomWidget extends StatelessWidget {
const CustomWidget({ super.key });
const CustomWidget({super.key});
@override
Widget build(BuildContext context) {
@@ -49,14 +49,12 @@ class CustomWidget extends StatelessWidget {
}
class Home extends StatelessWidget {
const Home({ super.key });
const Home({super.key});
@override
Widget build(BuildContext context) {
return const Scaffold(
body: Center(
child: CustomWidget()
),
body: Center(child: CustomWidget()),
);
}
}