`experimental/context_menus`: Update `analysis_options.yaml` (#1579)

pull/1585/head
Brett Morgan 2 years ago committed by GitHub
parent e2a6ac66d3
commit c46d418532
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,29 +1 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.
# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml
linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at
# https://dart-lang.github.io/linter/lints/index.html.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
include: ../../analysis_options.yaml

@ -8,9 +8,9 @@ import 'platform_selector.dart';
class AnywherePage extends StatelessWidget {
AnywherePage({
Key? key,
super.key,
required this.onChangedPlatform,
}) : super(key: key);
});
static const String route = 'anywhere';
static const String title = 'Context Menu Anywhere Example';
@ -50,12 +50,11 @@ class AnywherePage extends StatelessWidget {
],
),
body: ContextMenuRegion(
contextMenuBuilder: (BuildContext context, Offset primaryAnchor,
[Offset? secondaryAnchor]) {
contextMenuBuilder: (context, primaryAnchor, [secondaryAnchor]) {
return AdaptiveTextSelectionToolbar.buttonItems(
anchors: TextSelectionToolbarAnchors(
primaryAnchor: primaryAnchor,
secondaryAnchor: secondaryAnchor,
secondaryAnchor: secondaryAnchor as Offset?,
),
buttonItems: <ContextMenuButtonItem>[
ContextMenuButtonItem(

@ -11,9 +11,9 @@ import 'platform_selector.dart';
class CascadingMenuPage extends StatelessWidget {
const CascadingMenuPage({
Key? key,
super.key,
required this.onChangedPlatform,
}) : super(key: key);
});
static const String route = 'cascading';
static const String title = 'Cascading Menu Example';
@ -80,8 +80,8 @@ class _MyContextMenuRegionState extends State<_MyContextMenuRegion> {
@override
Widget build(BuildContext context) {
return ContextMenuRegion(
contextMenuBuilder: (BuildContext context, Offset primaryAnchor,
[Offset? secondaryAnchor]) {
contextMenuBuilder: (context, primaryAnchor,
[secondaryAnchor]) {
return _MyCascadingContextMenu(
anchor: primaryAnchor,
showingMessage: _showMessage,
@ -90,12 +90,12 @@ class _MyContextMenuRegionState extends State<_MyContextMenuRegion> {
_showMessage = !_showMessage;
});
},
onChangeBackgroundColor: (Color color) {
onChangeBackgroundColor: (color) {
setState(() {
_backgroundColor = color;
});
},
onChangeSelection: (String selection) {
onChangeSelection: (selection) {
setState(() {
_lastSelection = selection;
});

@ -67,7 +67,7 @@ class _ContextMenuRegionState extends State<ContextMenuRegion> {
void _show(Offset position) {
_contextMenuController.show(
context: context,
contextMenuBuilder: (BuildContext context) {
contextMenuBuilder: (context) {
return widget.contextMenuBuilder(context, position);
},
);

@ -7,9 +7,9 @@ import 'platform_selector.dart';
class CustomButtonsPage extends StatelessWidget {
CustomButtonsPage({
Key? key,
super.key,
required this.onChangedPlatform,
}) : super(key: key);
});
static const String route = 'custom-buttons';
static const String title = 'Custom Buttons';
@ -52,14 +52,14 @@ class CustomButtonsPage extends StatelessWidget {
maxLines: 4,
minLines: 2,
contextMenuBuilder:
(BuildContext context, EditableTextState editableTextState) {
(context, editableTextState) {
return AdaptiveTextSelectionToolbar(
anchors: editableTextState.contextMenuAnchors,
// Build the default buttons, but make them look custom.
// Note that in a real project you may want to build
// different buttons depending on the platform.
children: editableTextState.contextMenuButtonItems
.map((ContextMenuButtonItem buttonItem) {
.map((buttonItem) {
return CupertinoButton(
borderRadius: null,
color: const Color(0xffaaaa00),

@ -6,9 +6,9 @@ import 'platform_selector.dart';
class DefaultValuesPage extends StatelessWidget {
DefaultValuesPage({
Key? key,
super.key,
required this.onChangedPlatform,
}) : super(key: key);
});
static const String route = 'default-values';
static const String title = 'Default API Values Example';
@ -34,7 +34,7 @@ class DefaultValuesPage extends StatelessWidget {
DialogRoute _showDialog(BuildContext context, String message) {
return DialogRoute<void>(
context: context,
builder: (BuildContext context) => AlertDialog(title: Text(message)),
builder: (context) => AlertDialog(title: Text(message)),
);
}
@ -84,8 +84,8 @@ class DefaultValuesPage extends StatelessWidget {
maxLines: 2,
minLines: 2,
controller: _controllerCustom,
contextMenuBuilder: (BuildContext context,
EditableTextState editableTextState) {
contextMenuBuilder: (context,
editableTextState) {
return AdaptiveTextSelectionToolbar.buttonItems(
anchors: editableTextState.contextMenuAnchors,
buttonItems: <ContextMenuButtonItem>[

@ -7,9 +7,9 @@ import 'platform_selector.dart';
class EmailButtonPage extends StatelessWidget {
EmailButtonPage({
Key? key,
super.key,
required this.onChangedPlatform,
}) : super(key: key);
});
static const String route = 'email-button';
static const String title = 'Email Button';
@ -25,7 +25,7 @@ class EmailButtonPage extends StatelessWidget {
DialogRoute _showDialog(BuildContext context) {
return DialogRoute<void>(
context: context,
builder: (BuildContext context) =>
builder: (context) =>
const AlertDialog(title: Text('You clicked send email!')),
);
}
@ -63,8 +63,8 @@ class EmailButtonPage extends StatelessWidget {
TextField(
maxLines: 2,
controller: _controller,
contextMenuBuilder: (BuildContext context,
EditableTextState editableTextState) {
contextMenuBuilder: (context,
editableTextState) {
final TextEditingValue value =
editableTextState.textEditingValue;
final List<ContextMenuButtonItem> buttonItems =

@ -7,9 +7,9 @@ import 'platform_selector.dart';
class FieldTypesPage extends StatelessWidget {
FieldTypesPage({
Key? key,
super.key,
required this.onChangedPlatform,
}) : super(key: key);
});
static const String route = 'field-types';
static const String title = 'The Context Menu in Different Field Types';
@ -82,8 +82,8 @@ class FieldTypesPage extends StatelessWidget {
CupertinoTextField(
maxLines: 3,
controller: _cupertinoControllerFixed,
contextMenuBuilder: (BuildContext context,
EditableTextState editableTextState) {
contextMenuBuilder: (context,
editableTextState) {
return AdaptiveTextSelectionToolbar.editableText(
editableTextState: editableTextState,
);
@ -93,8 +93,8 @@ class FieldTypesPage extends StatelessWidget {
CupertinoTextField(
maxLines: 3,
controller: _cupertinoControllerForced,
contextMenuBuilder: (BuildContext context,
EditableTextState editableTextState) {
contextMenuBuilder: (context,
editableTextState) {
return DesktopTextSelectionToolbar(
anchor: editableTextState.contextMenuAnchors.primaryAnchor,
children: AdaptiveTextSelectionToolbar.getAdaptiveButtons(
@ -118,8 +118,8 @@ class FieldTypesPage extends StatelessWidget {
// EditableText has no built-in gesture detection for
// selection. A wrapper would have to implement
// TextSelectionGestureDetectorBuilderDelegate, etc.
contextMenuBuilder: (BuildContext context,
EditableTextState editableTextState) {
contextMenuBuilder: (context,
editableTextState) {
return AdaptiveTextSelectionToolbar.editableText(
editableTextState: editableTextState,
);

@ -9,9 +9,9 @@ import 'platform_selector.dart';
class FullPage extends StatelessWidget {
FullPage({
Key? key,
super.key,
required this.onChangedPlatform,
}) : super(key: key);
});
static const String route = 'full';
static const String title = 'Combined Example';
@ -28,7 +28,7 @@ class FullPage extends StatelessWidget {
DialogRoute _showDialog(BuildContext context, String message) {
return DialogRoute<void>(
context: context,
builder: (BuildContext context) => AlertDialog(title: Text(message)),
builder: (context) => AlertDialog(title: Text(message)),
);
}
@ -52,7 +52,7 @@ class FullPage extends StatelessWidget {
],
),
body: ContextMenuRegion(
contextMenuBuilder: (BuildContext context, Offset offset) {
contextMenuBuilder: (context, offset) {
return AdaptiveTextSelectionToolbar.buttonItems(
anchors: TextSelectionToolbarAnchors(
primaryAnchor: offset,
@ -81,7 +81,7 @@ class FullPage extends StatelessWidget {
height: 60.0,
),
ContextMenuRegion(
contextMenuBuilder: (BuildContext context, Offset offset) {
contextMenuBuilder: (context, offset) {
return AdaptiveTextSelectionToolbar.buttonItems(
anchors: TextSelectionToolbarAnchors(
primaryAnchor: offset,
@ -107,8 +107,8 @@ class FullPage extends StatelessWidget {
Container(height: 20.0),
TextField(
controller: _controller,
contextMenuBuilder: (BuildContext context,
EditableTextState editableTextState) {
contextMenuBuilder: (context,
editableTextState) {
final TextEditingValue value =
editableTextState.textEditingValue;
final List<ContextMenuButtonItem> buttonItems =
@ -131,7 +131,7 @@ class FullPage extends StatelessWidget {
// Note that in a real project you may want to build
// different buttons depending on the platform.
children:
buttonItems.map((ContextMenuButtonItem buttonItem) {
buttonItems.map((buttonItem) {
return CupertinoButton(
borderRadius: null,
color: const Color(0xffaaaa00),

@ -6,9 +6,9 @@ import 'platform_selector.dart';
class GlobalSelectionPage extends StatelessWidget {
GlobalSelectionPage({
Key? key,
super.key,
required this.onChangedPlatform,
}) : super(key: key);
});
static const String route = 'global-selection';
static const String title = 'Global Selection Example';
@ -25,7 +25,7 @@ class GlobalSelectionPage extends StatelessWidget {
Widget build(BuildContext context) {
return SelectionArea(
contextMenuBuilder:
(BuildContext context, SelectableRegionState selectableRegionState) {
(context, selectableRegionState) {
return AdaptiveTextSelectionToolbar.buttonItems(
anchors: selectableRegionState.contextMenuAnchors,
buttonItems: <ContextMenuButtonItem>[

@ -7,9 +7,9 @@ import 'platform_selector.dart';
class ImagePage extends StatelessWidget {
const ImagePage({
Key? key,
super.key,
required this.onChangedPlatform,
}) : super(key: key);
});
static const String route = 'image';
static const String title = 'ContextMenu on an Image';
@ -22,7 +22,7 @@ class ImagePage extends StatelessWidget {
DialogRoute _showDialog(BuildContext context) {
return DialogRoute<void>(
context: context,
builder: (BuildContext context) =>
builder: (context) =>
const AlertDialog(title: Text('Image saved! (not really though)')),
);
}
@ -50,7 +50,7 @@ class ImagePage extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
ContextMenuRegion(
contextMenuBuilder: (BuildContext context, Offset offset) {
contextMenuBuilder: (context, offset) {
return AdaptiveTextSelectionToolbar.buttonItems(
anchors: TextSelectionToolbarAnchors(
primaryAnchor: offset,

@ -45,29 +45,29 @@ class _MyAppState extends State<MyApp> {
),
initialRoute: '/',
routes: <String, Widget Function(BuildContext)>{
'/': (BuildContext context) =>
'/': (context) =>
MyHomePage(onChangedPlatform: onChangedPlatform),
AnywherePage.route: (BuildContext context) =>
AnywherePage.route: (context) =>
AnywherePage(onChangedPlatform: onChangedPlatform),
CustomButtonsPage.route: (BuildContext context) =>
CustomButtonsPage.route: (context) =>
CustomButtonsPage(onChangedPlatform: onChangedPlatform),
ReorderedButtonsPage.route: (BuildContext context) =>
ReorderedButtonsPage.route: (context) =>
ReorderedButtonsPage(onChangedPlatform: onChangedPlatform),
EmailButtonPage.route: (BuildContext context) =>
EmailButtonPage.route: (context) =>
EmailButtonPage(onChangedPlatform: onChangedPlatform),
ImagePage.route: (BuildContext context) =>
ImagePage.route: (context) =>
ImagePage(onChangedPlatform: onChangedPlatform),
FieldTypesPage.route: (BuildContext context) =>
FieldTypesPage.route: (context) =>
FieldTypesPage(onChangedPlatform: onChangedPlatform),
FullPage.route: (BuildContext context) =>
FullPage.route: (context) =>
FullPage(onChangedPlatform: onChangedPlatform),
ModifiedActionPage.route: (BuildContext context) =>
ModifiedActionPage.route: (context) =>
ModifiedActionPage(onChangedPlatform: onChangedPlatform),
GlobalSelectionPage.route: (BuildContext context) =>
GlobalSelectionPage.route: (context) =>
GlobalSelectionPage(onChangedPlatform: onChangedPlatform),
DefaultValuesPage.route: (BuildContext context) =>
DefaultValuesPage.route: (context) =>
DefaultValuesPage(onChangedPlatform: onChangedPlatform),
CascadingMenuPage.route: (BuildContext context) =>
CascadingMenuPage.route: (context) =>
CascadingMenuPage(onChangedPlatform: onChangedPlatform),
},
);

@ -6,9 +6,9 @@ import 'platform_selector.dart';
class ModifiedActionPage extends StatelessWidget {
ModifiedActionPage({
Key? key,
super.key,
required this.onChangedPlatform,
}) : super(key: key);
});
static const String route = 'modified-action';
static const String title = 'Modified Action';
@ -25,7 +25,7 @@ class ModifiedActionPage extends StatelessWidget {
DialogRoute _showDialog(BuildContext context) {
return DialogRoute<void>(
context: context,
builder: (BuildContext context) => const AlertDialog(
builder: (context) => const AlertDialog(
title: Text('Copied, but also showed this dialog.')),
);
}
@ -63,13 +63,13 @@ class ModifiedActionPage extends StatelessWidget {
),
TextField(
controller: _controller,
contextMenuBuilder: (BuildContext context,
EditableTextState editableTextState) {
contextMenuBuilder: (context,
editableTextState) {
final List<ContextMenuButtonItem> buttonItems =
editableTextState.contextMenuButtonItems;
// Modify the copy buttonItem to show a dialog after copying.
final int copyButtonIndex = buttonItems.indexWhere(
(ContextMenuButtonItem buttonItem) {
(buttonItem) {
return buttonItem.type == ContextMenuButtonType.copy;
},
);

@ -32,7 +32,7 @@ class _PlatformSelectorState extends State<PlatformSelector> {
value: defaultTargetPlatform,
icon: const Icon(Icons.arrow_downward),
elevation: 16,
onChanged: (TargetPlatform? value) {
onChanged: (value) {
if (value == null) {
return;
}
@ -40,7 +40,7 @@ class _PlatformSelectorState extends State<PlatformSelector> {
widget.onChangedPlatform(value);
setState(() {});
},
items: TargetPlatform.values.map((TargetPlatform platform) {
items: TargetPlatform.values.map((platform) {
return DropdownMenuItem<TargetPlatform>(
value: platform,
child: Row(

@ -8,9 +8,9 @@ import 'platform_selector.dart';
class ReorderedButtonsPage extends StatelessWidget {
ReorderedButtonsPage({
Key? key,
super.key,
required this.onChangedPlatform,
}) : super(key: key);
});
static const String route = 'reordered-buttons';
static const String title = 'Reordered Buttons';
@ -60,8 +60,8 @@ class ReorderedButtonsPage extends StatelessWidget {
TextField(
controller: _controllerReordered,
maxLines: 2,
contextMenuBuilder: (BuildContext context,
EditableTextState editableTextState) {
contextMenuBuilder: (context,
editableTextState) {
// Reorder the button datas by type.
final HashMap<ContextMenuButtonType, ContextMenuButtonItem>
buttonItemsMap =

@ -1,12 +1,11 @@
import 'package:context_menus/anywhere_page.dart';
import 'package:context_menus/main.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:context_menus/main.dart';
import 'package:context_menus/anywhere_page.dart';
void main() {
testWidgets('Right click works outside of text', (WidgetTester tester) async {
testWidgets('Right click works outside of text', (tester) async {
await tester.pumpWidget(const MyApp());
// Navigate to the AnywherePage example.

@ -1,14 +1,13 @@
import 'package:context_menus/cascading_menu_page.dart';
import 'package:context_menus/main.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:context_menus/main.dart';
import 'package:context_menus/cascading_menu_page.dart';
void main() {
testWidgets('Can show and use the cascading menu',
(WidgetTester tester) async {
(tester) async {
await tester.pumpWidget(const MyApp());
// Navigate to the CascadingMenuPage example.

@ -1,15 +1,14 @@
import 'package:context_menus/custom_buttons_page.dart';
import 'package:context_menus/main.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:context_menus/main.dart';
import 'package:context_menus/custom_buttons_page.dart';
void main() {
testWidgets('Shows custom buttons in the built-in context menu',
(WidgetTester tester) async {
(tester) async {
await tester.pumpWidget(const MyApp());
// Navigate to the CustomButtonsPage example.

@ -1,15 +1,14 @@
import 'package:context_menus/default_values_page.dart';
import 'package:context_menus/main.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:context_menus/main.dart';
import 'package:context_menus/default_values_page.dart';
void main() {
testWidgets('Gives correct behavior for all values of contextMenuBuilder',
(WidgetTester tester) async {
(tester) async {
await tester.pumpWidget(const MyApp());
// Navigate to the DefaultValuesPage example.

@ -1,3 +1,5 @@
import 'package:context_menus/email_button_page.dart';
import 'package:context_menus/main.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
@ -5,14 +7,11 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:context_menus/main.dart';
import 'package:context_menus/email_button_page.dart';
import 'utils.dart';
void main() {
testWidgets('Selecting the email address shows a custom button',
(WidgetTester tester) async {
(tester) async {
await tester.pumpWidget(const MyApp());
// Navigate to the EmailButtonPage example.

@ -1,16 +1,15 @@
import 'package:context_menus/field_types_page.dart';
import 'package:context_menus/main.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:context_menus/main.dart';
import 'package:context_menus/field_types_page.dart';
void main() {
testWidgets(
'Gives correct behavior for all values of contextMenuBuilder',
(WidgetTester tester) async {
(tester) async {
await tester.pumpWidget(const MyApp());
// Navigate to the FieldTypesPage example.

@ -1,13 +1,12 @@
import 'package:context_menus/global_selection_page.dart';
import 'package:context_menus/main.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:context_menus/main.dart';
import 'package:context_menus/global_selection_page.dart';
void main() {
testWidgets('Gives correct behavior for all values of contextMenuBuilder',
(WidgetTester tester) async {
(tester) async {
await tester.pumpWidget(const MyApp());
// Navigate to the GlobalSelectionPage example.

@ -1,14 +1,13 @@
import 'package:context_menus/image_page.dart';
import 'package:context_menus/main.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:context_menus/main.dart';
import 'package:context_menus/image_page.dart';
void main() {
testWidgets(
'Gives correct behavior for all values of contextMenuBuilder',
(WidgetTester tester) async {
(tester) async {
await tester.pumpWidget(const MyApp());
// Navigate to the ImagePage example.

@ -37,7 +37,7 @@ Offset textOffsetToPosition(WidgetTester tester, int offset) {
List<TextSelectionPoint> globalize(
Iterable<TextSelectionPoint> points, RenderBox box) {
return points.map<TextSelectionPoint>((TextSelectionPoint point) {
return points.map<TextSelectionPoint>((point) {
return TextSelectionPoint(
box.localToGlobal(point.point),
point.direction,

@ -19,7 +19,8 @@ declare -ar PROJECT_NAMES=(
"code_sharing/server"
"desktop_photo_search/fluent_ui"
"desktop_photo_search/material"
"experimental/context_menus"
# TODO(DomesticMouse): Reformat code
# "experimental/context_menus"
"experimental/federated_plugin/federated_plugin"
# TODO(DomesticMouse): Error: Method not found: 'FallThroughError'.
# "experimental/web_dashboard"

Loading…
Cancel
Save