refactor: clean up unused imports, remove TODO comments, and format code across samples

pull/2831/head
Eric Windmill 3 weeks ago
parent 2aedc3112f
commit 6a3ffef57b

@ -66,8 +66,6 @@ class _BookDetailState extends State<BookDetail> {
// Registering this `FlutterBookApiHandler` class lets us receive incoming
// calls from the platform.
// TODO(gaaclarke): make the setup method an instance method so it's
// injectable https://github.com/flutter/flutter/issues/59119.
FlutterBookApi.setup(
FlutterBookApiHandler(
// The `FlutterBookApi` just has one method. Just give a closure for that
@ -82,7 +80,6 @@ class _BookDetailState extends State<BookDetail> {
this.book!.title = titleTextController.text;
});
// Subtitle could be null.
// TODO(gaaclarke): https://github.com/flutter/flutter/issues/59118.
subtitleTextController.text = book.subtitle ?? '';
subtitleTextController.addListener(() {
this.book!.subtitle = subtitleTextController.text;

@ -37,11 +37,11 @@ class GalleryHome extends StatelessWidget {
return switch (index) {
0 => const WidgetsPage(),
1 => SettingsPage(
onThemeChange: onThemeChange,
isDarkMode: isDarkMode,
onTextSizeChange: onTextSizeChange,
textSize: textSize,
),
onThemeChange: onThemeChange,
isDarkMode: isDarkMode,
onTextSizeChange: onTextSizeChange,
textSize: textSize,
),
_ => const Center(child: Text('Widgets')),
};
},

@ -37,24 +37,31 @@ class _CupertinoGalleryAppState extends State<CupertinoGalleryApp> {
@override
Widget build(BuildContext context) {
final baseTheme = CupertinoThemeData(
brightness:
_themeMode == ThemeMode.dark ? Brightness.dark : Brightness.light,
brightness: _themeMode == ThemeMode.dark
? Brightness.dark
: Brightness.light,
);
final textTheme = baseTheme.textTheme.copyWith(
textStyle:
baseTheme.textTheme.textStyle.copyWith(fontSize: 14 * _textSize),
actionTextStyle: baseTheme.textTheme.actionTextStyle
.copyWith(fontSize: 14 * _textSize),
tabLabelTextStyle: baseTheme.textTheme.tabLabelTextStyle
.copyWith(fontSize: 10 * _textSize),
navTitleTextStyle: baseTheme.textTheme.navTitleTextStyle
.copyWith(fontSize: 17 * _textSize),
textStyle: baseTheme.textTheme.textStyle.copyWith(
fontSize: 14 * _textSize,
),
actionTextStyle: baseTheme.textTheme.actionTextStyle.copyWith(
fontSize: 14 * _textSize,
),
tabLabelTextStyle: baseTheme.textTheme.tabLabelTextStyle.copyWith(
fontSize: 10 * _textSize,
),
navTitleTextStyle: baseTheme.textTheme.navTitleTextStyle.copyWith(
fontSize: 17 * _textSize,
),
navLargeTitleTextStyle: baseTheme.textTheme.navLargeTitleTextStyle
.copyWith(fontSize: 34 * _textSize),
navActionTextStyle: baseTheme.textTheme.navActionTextStyle
.copyWith(fontSize: 17 * _textSize),
pickerTextStyle: baseTheme.textTheme.pickerTextStyle
.copyWith(fontSize: 21 * _textSize),
navActionTextStyle: baseTheme.textTheme.navActionTextStyle.copyWith(
fontSize: 17 * _textSize,
),
pickerTextStyle: baseTheme.textTheme.pickerTextStyle.copyWith(
fontSize: 21 * _textSize,
),
dateTimePickerTextStyle: baseTheme.textTheme.dateTimePickerTextStyle
.copyWith(fontSize: 21 * _textSize),
);

@ -140,4 +140,3 @@ class _SettingsPageState extends State<SettingsPage> {
);
}
}

@ -6,9 +6,7 @@ class ActionSheetPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
navigationBar: const CupertinoNavigationBar(
middle: Text('Action Sheet'),
),
navigationBar: const CupertinoNavigationBar(middle: Text('Action Sheet')),
child: Center(
child: CupertinoButton(
child: const Text('Show Action Sheet'),
@ -30,7 +28,7 @@ class ActionSheetPage extends StatelessWidget {
onPressed: () {
Navigator.pop(context);
},
)
),
],
cancelButton: CupertinoActionSheetAction(
isDefaultAction: true,

@ -6,12 +6,8 @@ class ActivityIndicatorPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(
middle: Text('Activity Indicator'),
),
child: Center(
child: CupertinoActivityIndicator(),
),
navigationBar: CupertinoNavigationBar(middle: Text('Activity Indicator')),
child: Center(child: CupertinoActivityIndicator()),
);
}
}

@ -13,9 +13,7 @@ class _CheckboxPageState extends State<CheckboxPage> {
@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
navigationBar: const CupertinoNavigationBar(
middle: Text('Checkbox'),
),
navigationBar: const CupertinoNavigationBar(middle: Text('Checkbox')),
child: Center(
child: CupertinoCheckbox(
value: _value,

@ -6,15 +6,11 @@ class DatePickerPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
navigationBar: const CupertinoNavigationBar(
middle: Text('Date Picker'),
),
navigationBar: const CupertinoNavigationBar(middle: Text('Date Picker')),
child: Center(
child: SizedBox(
height: 200,
child: CupertinoDatePicker(
onDateTimeChanged: (DateTime newDate) {},
),
child: CupertinoDatePicker(onDateTimeChanged: (DateTime newDate) {}),
),
),
);

@ -6,20 +6,14 @@ class PickerPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
navigationBar: const CupertinoNavigationBar(
middle: Text('Picker'),
),
navigationBar: const CupertinoNavigationBar(middle: Text('Picker')),
child: Center(
child: SizedBox(
height: 200,
child: CupertinoPicker(
itemExtent: 32,
onSelectedItemChanged: (int index) {},
children: const <Widget>[
Text('One'),
Text('Two'),
Text('Three'),
],
children: const <Widget>[Text('One'), Text('Two'), Text('Three')],
),
),
),

@ -6,9 +6,7 @@ class SearchTextFieldPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(
middle: Text('Search Text Field'),
),
navigationBar: CupertinoNavigationBar(middle: Text('Search Text Field')),
child: Center(
child: Padding(
padding: EdgeInsets.all(16.0),

@ -13,9 +13,7 @@ class _SliderPageState extends State<SliderPage> {
@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
navigationBar: const CupertinoNavigationBar(
middle: Text('Slider'),
),
navigationBar: const CupertinoNavigationBar(middle: Text('Slider')),
child: Center(
child: CupertinoSlider(
value: _value,

@ -13,9 +13,7 @@ class _SwitchPageState extends State<SwitchPage> {
@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
navigationBar: const CupertinoNavigationBar(
middle: Text('Switch'),
),
navigationBar: const CupertinoNavigationBar(middle: Text('Switch')),
child: Center(
child: CupertinoSwitch(
value: _value,

@ -6,15 +6,11 @@ class TextFieldPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(
middle: Text('Text Field'),
),
navigationBar: CupertinoNavigationBar(middle: Text('Text Field')),
child: Center(
child: Padding(
padding: EdgeInsets.all(16.0),
child: CupertinoTextField(
placeholder: 'Enter text',
),
child: CupertinoTextField(placeholder: 'Enter text'),
),
),
);

@ -6,9 +6,7 @@ class TextThemePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
navigationBar: const CupertinoNavigationBar(
middle: Text('Text Theme'),
),
navigationBar: const CupertinoNavigationBar(middle: Text('Text Theme')),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
@ -35,9 +33,9 @@ class TextThemePage extends StatelessWidget {
const SizedBox(height: 16),
Text(
'This is the nav large title text style',
style: CupertinoTheme.of(context)
.textTheme
.navLargeTitleTextStyle,
style: CupertinoTheme.of(
context,
).textTheme.navLargeTitleTextStyle,
),
const SizedBox(height: 16),
Text(
@ -47,8 +45,9 @@ class TextThemePage extends StatelessWidget {
const SizedBox(height: 16),
Text(
'This is the date time picker text style',
style:
CupertinoTheme.of(context).textTheme.dateTimePickerTextStyle,
style: CupertinoTheme.of(
context,
).textTheme.dateTimePickerTextStyle,
),
],
),

@ -6,9 +6,7 @@ class TimePickerPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
navigationBar: const CupertinoNavigationBar(
middle: Text('Time Picker'),
),
navigationBar: const CupertinoNavigationBar(middle: Text('Time Picker')),
child: Center(
child: SizedBox(
height: 200,

@ -62,9 +62,6 @@ class EventList extends StatelessWidget {
),
children: [
for (Event e in events.sorted(p))
// TODO: Support swipe action for deleting.
// Should probably use Dismissable?
// https://api.flutter.dev/flutter/widgets/Dismissible-class.html
EventRow(
event: e,
onTap: () async {

@ -5,7 +5,6 @@
import 'dart:io';
import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:logging/logging.dart';
import 'package:menubar/menubar.dart' as menubar;
@ -47,7 +46,6 @@ void main() {
);
}
class UnsplashSearchApp extends StatelessWidget {
const UnsplashSearchApp({super.key});

@ -19,8 +19,6 @@ import 'package:flutter/material.dart';
///
/// The user can drag the widget with key [dividerKey] to change
/// the space allocated between [firstChild] and [secondChild].
// TODO(djshuckerow): introduce support for a minimum fraction a child
// is allowed.
class Split extends StatefulWidget {
/// Builds a split oriented along [axis].
const Split({
@ -125,12 +123,6 @@ class _SplitState extends State<Split> {
});
}
// TODO(https://github.com/flutter/flutter/issues/43747): use an icon.
// The material icon for a drag handle is not currently available.
// For now, draw an indicator that is 3 lines running in the direction
// of the main axis, like a hamburger menu.
// TODO(https://github.com/flutter/devtools/issues/1265): update mouse
// to indicate that this is resizable.
final dragIndicator = Flex(
direction: isHorizontal ? Axis.vertical : Axis.horizontal,
mainAxisSize: MainAxisSize.min,

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// TODO: Retrieve an API Access Key from https://unsplash.com/developers
// To use this sample: Retrieve an API Access Key from https://unsplash.com/developers
const String unsplashAccessKey = '';
// The application name for the above API Access Key.

@ -19,8 +19,6 @@ import 'package:flutter/material.dart';
///
/// The user can drag the widget with key [dividerKey] to change
/// the space allocated between [firstChild] and [secondChild].
// TODO(djshuckerow): introduce support for a minimum fraction a child
// is allowed.
class Split extends StatefulWidget {
/// Builds a split oriented along [axis].
const Split({
@ -125,12 +123,6 @@ class _SplitState extends State<Split> {
});
}
// TODO(https://github.com/flutter/flutter/issues/43747): use an icon.
// The material icon for a drag handle is not currently available.
// For now, draw an indicator that is 3 lines running in the direction
// of the main axis, like a hamburger menu.
// TODO(https://github.com/flutter/devtools/issues/1265): update mouse
// to indicate that this is resizable.
final dragIndicator = Flex(
direction: isHorizontal ? Axis.vertical : Axis.horizontal,
mainAxisSize: MainAxisSize.min,

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// TODO: Retrieve an API Access Key from https://unsplash.com/developers
// To use this sample: Retrieve an API Access Key from https://unsplash.com/developers
const String unsplashAccessKey = '';
// The application name for the above API Access Key.

@ -2,9 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:io' show Platform;
import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
@ -19,7 +16,6 @@ void main() {
runApp(const FormApp());
}
final demos = [
Demo(
name: 'Sign in with HTTP',

@ -251,8 +251,6 @@ class Containment extends StatelessWidget {
Carousels(),
Dialogs(),
Dividers(),
// TODO: Add Lists, https://github.com/flutter/flutter/issues/114006
// TODO: Add Side sheets, https://github.com/flutter/flutter/issues/119328
],
);
}
@ -878,7 +876,6 @@ class _SwitchRowState extends State<SwitchRow> {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
// TODO: use SwitchListTile when thumbIcon is available https://github.com/flutter/flutter/issues/118616
Switch(
value: value0,
onChanged: widget.isEnabled
@ -948,7 +945,6 @@ class _CheckboxesState extends State<Checkboxes> {
tristate: true,
value: isChecked2,
title: const Text('Option 3'),
// TODO: showcase error state https://github.com/flutter/flutter/issues/118616
onChanged: (value) {
setState(() {
isChecked2 = value;
@ -1703,7 +1699,6 @@ class _BottomSheetSectionState extends State<BottomSheetSection> {
showModalBottomSheet<void>(
showDragHandle: true,
context: context,
// TODO: Remove when this is in the framework https://github.com/flutter/flutter/issues/118619
constraints: const BoxConstraints(maxWidth: 640),
builder: (context) {
return SizedBox(
@ -1746,7 +1741,6 @@ class _BottomSheetSectionState extends State<BottomSheetSection> {
_nonModalBottomSheetController = showBottomSheet(
elevation: 8.0,
context: context,
// TODO: Remove when this is in the framework https://github.com/flutter/flutter/issues/118619
constraints: const BoxConstraints(maxWidth: 640),
builder: (context) {
return SizedBox(
@ -2132,7 +2126,6 @@ class _TabsState extends State<Tabs> with TickerProviderStateMixin {
),
],
),
// TODO: Showcase secondary tab bar https://github.com/flutter/flutter/issues/111962
),
),
),

@ -1,10 +1,6 @@
// Copyright 2021, the Flutter project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:io' show Platform;
import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:flutter/material.dart';
import 'src/app.dart';
@ -16,4 +12,3 @@ void main() {
const double windowWidth = 480;
const double windowHeight = 854;

@ -73,8 +73,6 @@ class _BookstoreState extends State<Bookstore> {
pageBuilder: (context, state, child) {
return FadeTransitionPage<dynamic>(
key: state.pageKey,
// Use a builder to get the correct BuildContext
// TODO (johnpryan): remove when https://github.com/flutter/flutter/issues/108177 lands
child: Builder(
builder: (context) {
return BooksScreen(
@ -103,8 +101,6 @@ class _BookstoreState extends State<Bookstore> {
path: '/books/popular',
pageBuilder: (context, state) {
return FadeTransitionPage<dynamic>(
// Use a builder to get the correct BuildContext
// TODO (johnpryan): remove when https://github.com/flutter/flutter/issues/108177 lands
key: state.pageKey,
child: Builder(
builder: (context) {
@ -139,8 +135,6 @@ class _BookstoreState extends State<Bookstore> {
pageBuilder: (context, state) {
return FadeTransitionPage<dynamic>(
key: state.pageKey,
// Use a builder to get the correct BuildContext
// TODO (johnpryan): remove when https://github.com/flutter/flutter/issues/108177 lands
child: Builder(
builder: (context) {
return BookList(
@ -174,8 +168,6 @@ class _BookstoreState extends State<Bookstore> {
pageBuilder: (context, state) {
return FadeTransitionPage<dynamic>(
key: state.pageKey,
// Use a builder to get the correct BuildContext
// TODO (johnpryan): remove when https://github.com/flutter/flutter/issues/108177 lands
child: Builder(
builder: (context) {
return BookList(
@ -234,7 +226,6 @@ class _BookstoreState extends State<Bookstore> {
int.parse(state.pathParameters['authorId']!),
);
// Use a builder to get the correct BuildContext
// TODO (johnpryan): remove when https://github.com/flutter/flutter/issues/108177 lands
return Builder(
builder: (context) {
return AuthorDetailsScreen(
@ -266,7 +257,6 @@ class _BookstoreState extends State<Bookstore> {
path: '/sign-in',
builder: (context, state) {
// Use a builder to get the correct BuildContext
// TODO (johnpryan): remove when https://github.com/flutter/flutter/issues/108177 lands
return Builder(
builder: (context) {
return SignInScreen(

Loading…
Cancel
Save