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,38 +2,35 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [Focus].
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() => runApp(const MyApp());
/// Flutter code sample for [Focus].
class MyApp extends StatelessWidget {
const MyApp({super.key});
void main() => runApp(const FocusExampleApp());
static const String _title = 'Flutter Code Sample';
class FocusExampleApp extends StatelessWidget {
const FocusExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: _title,
home: Scaffold(
appBar: AppBar(title: const Text(_title)),
body: const MyStatefulWidget(),
appBar: AppBar(title: const Text('Focus Sample')),
body: const FocusExample(),
),
);
}
}
class MyStatefulWidget extends StatefulWidget {
const MyStatefulWidget({super.key});
class FocusExample extends StatefulWidget {
const FocusExample({super.key});
@override
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
State<FocusExample> createState() => _FocusExampleState();
}
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
class _FocusExampleState extends State<FocusExample> {
Color _color = Colors.white;
KeyEventResult _handleKeyPress(FocusNode node, RawKeyEvent event) {
@@ -91,9 +88,7 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
height: 100,
alignment: Alignment.center,
color: hasFocus ? _color : Colors.white,
child: Text(hasFocus
? "I'm in color! Press R,G,B!"
: 'Press to focus'),
child: Text(hasFocus ? "I'm in color! Press R,G,B!" : 'Press to focus'),
),
),
);

View File

@@ -2,22 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [Focus].
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
/// Flutter code sample for [Focus].
class MyApp extends StatelessWidget {
const MyApp({super.key});
void main() => runApp(const FocusExampleApp());
static const String _title = 'Flutter Code Sample';
class FocusExampleApp extends StatelessWidget {
const FocusExampleApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: _title,
home: MyStatelessWidget(),
home: FocusExample(),
);
}
}
@@ -58,8 +55,8 @@ class FocusableText extends StatelessWidget {
}
}
class MyStatelessWidget extends StatelessWidget {
const MyStatelessWidget({super.key});
class FocusExample extends StatelessWidget {
const FocusExample({super.key});
@override
Widget build(BuildContext context) {

View File

@@ -2,34 +2,31 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [Focus].
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
/// Flutter code sample for [Focus].
class MyApp extends StatelessWidget {
const MyApp({super.key});
void main() => runApp(const FocusExampleApp());
static const String _title = 'Flutter Code Sample';
class FocusExampleApp extends StatelessWidget {
const FocusExampleApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: _title,
home: MyStatefulWidget(),
home: FocusExample(),
);
}
}
class MyStatefulWidget extends StatefulWidget {
const MyStatefulWidget({super.key});
class FocusExample extends StatefulWidget {
const FocusExample({super.key});
@override
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
State<FocusExample> createState() => _FocusExampleState();
}
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
class _FocusExampleState extends State<FocusExample> {
int focusedChild = 0;
List<Widget> children = <Widget>[];
List<FocusNode> childFocusNodes = <FocusNode>[];
@@ -52,8 +49,7 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
void _addChild() {
// Calling requestFocus here creates a deferred request for focus, since the
// node is not yet part of the focus tree.
childFocusNodes
.add(FocusNode(debugLabel: 'Child ${children.length}')..requestFocus());
childFocusNodes.add(FocusNode(debugLabel: 'Child ${children.length}')..requestFocus());
children.add(Padding(
padding: const EdgeInsets.all(2.0),

View File

@@ -2,22 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [FocusScope].
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
/// Flutter code sample for [FocusScope].
class MyApp extends StatelessWidget {
const MyApp({super.key});
void main() => runApp(const FocusScopeExampleApp());
static const String _title = 'Flutter Code Sample';
class FocusScopeExampleApp extends StatelessWidget {
const FocusScopeExampleApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: _title,
home: MyStatefulWidget(),
home: FocusScopeExample(),
);
}
}
@@ -66,14 +63,14 @@ class Pane extends StatelessWidget {
}
}
class MyStatefulWidget extends StatefulWidget {
const MyStatefulWidget({super.key});
class FocusScopeExample extends StatefulWidget {
const FocusScopeExample({super.key});
@override
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
State<FocusScopeExample> createState() => _FocusScopeExampleState();
}
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
class _FocusScopeExampleState extends State<FocusScopeExample> {
bool backdropIsVisible = false;
FocusNode backdropNode = FocusNode(debugLabel: 'Close Backdrop Button');
FocusNode foregroundNode = FocusNode(debugLabel: 'Option Button');
@@ -119,8 +116,9 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
child: const Text('ANOTHER BUTTON TO FOCUS'),
),
DefaultTextStyle(
style: Theme.of(context).textTheme.displayMedium!,
child: const Text('BACKDROP')),
style: Theme.of(context).textTheme.displayMedium!,
child: const Text('BACKDROP'),
),
],
),
),
@@ -144,12 +142,11 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
// TRY THIS: Try changing this to Colors.green.withOpacity(0.8) to see for
// yourself that the hidden components do/don't get focus.
backgroundColor: Colors.green,
onPressed: backdropIsVisible
? null
: () => setState(() => backdropIsVisible = true),
onPressed: backdropIsVisible ? null : () => setState(() => backdropIsVisible = true),
child: DefaultTextStyle(
style: Theme.of(context).textTheme.displayMedium!,
child: const Text('FOREGROUND')),
style: Theme.of(context).textTheme.displayMedium!,
child: const Text('FOREGROUND'),
),
),
),
],