1
0
mirror of https://github.com/flutter/samples.git synced 2026-03-31 08:44:26 +00:00
This commit is contained in:
Brett Morgan
2022-05-11 12:48:11 -07:00
committed by GitHub
parent fb00d0a102
commit ccd68f34e2
242 changed files with 1719 additions and 1430 deletions

View File

@@ -19,7 +19,7 @@ class LintingTool extends StatefulWidget {
static const String homeRoute = routes.homeRoute;
@override
_LintingToolState createState() => _LintingToolState();
State<LintingTool> createState() => _LintingToolState();
}
class _LintingToolState extends State<LintingTool> {

View File

@@ -60,6 +60,7 @@ class ProfilesStore extends ChangeNotifier {
}
Future<void> addToExistingProfile(RulesProfile profile, Rule rule) async {
// ignore: todo
// TODO(abd99): Consider refactoring to LinkedHashSet/SplayTreeSet to avoid
// duplication automatically.
// ref: https://github.com/flutter/samples/pull/870#discussion_r685666792

View File

@@ -32,7 +32,7 @@ class RuleStore extends ChangeNotifier {
String? get error => _error;
List<RulesProfile> get defaultProfiles {
List<RulesProfile> _defaultProfiles = [];
List<RulesProfile> defaultProfiles = [];
var rulesWithDefaultSets =
rules.where((rule) => rule.sets.isNotEmpty).toList();
@@ -40,16 +40,16 @@ class RuleStore extends ChangeNotifier {
for (final rule in rulesWithDefaultSets) {
for (final setName in rule.sets) {
var profileIndex =
_defaultProfiles.indexWhere((profile) => profile.name == setName);
defaultProfiles.indexWhere((profile) => profile.name == setName);
if (profileIndex >= 0) {
_defaultProfiles[profileIndex].rules.add(rule);
defaultProfiles[profileIndex].rules.add(rule);
} else {
_defaultProfiles.add(RulesProfile(name: setName, rules: [rule]));
defaultProfiles.add(RulesProfile(name: setName, rules: [rule]));
}
}
}
return _defaultProfiles;
return defaultProfiles;
}
Future<void> fetchRules() async {

View File

@@ -10,9 +10,14 @@ import 'package:linting_tool/pages/rules_page.dart';
import 'package:linting_tool/theme/colors.dart';
import 'package:provider/provider.dart';
class SavedLintsPage extends StatelessWidget {
class SavedLintsPage extends StatefulWidget {
const SavedLintsPage({Key? key}) : super(key: key);
@override
State<SavedLintsPage> createState() => _SavedLintsPageState();
}
class _SavedLintsPageState extends State<SavedLintsPage> {
@override
Widget build(BuildContext context) {
return Consumer<ProfilesStore>(
@@ -90,11 +95,14 @@ class SavedLintsPage extends StatelessWidget {
onSelected: (value) async {
switch (value) {
case 'Export file':
// ignore: todo
// TODO(abd99): Add option to select formatting style.
var saved = await profilesStore
.exportProfileFile(profile);
if (!mounted) return;
if (!saved) {
_showSnackBar(
context,
@@ -112,12 +120,12 @@ class SavedLintsPage extends StatelessWidget {
itemBuilder: (context) {
return [
const PopupMenuItem(
child: Text('Export file'),
value: 'Export file',
child: Text('Export file'),
),
const PopupMenuItem(
child: Text('Delete'),
value: 'Delete',
child: Text('Delete'),
),
];
},

View File

@@ -18,14 +18,14 @@ class AdaptiveNav extends StatefulWidget {
const AdaptiveNav({Key? key}) : super(key: key);
@override
_AdaptiveNavState createState() => _AdaptiveNavState();
State<AdaptiveNav> createState() => _AdaptiveNavState();
}
class _AdaptiveNavState extends State<AdaptiveNav> {
@override
Widget build(BuildContext context) {
final isDesktop = isDisplayLarge(context);
const _navigationDestinations = <_Destination>[
const navigationDestinations = <_Destination>[
_Destination(
textLabel: 'Home',
icon: Icons.home_outlined,
@@ -46,14 +46,14 @@ class _AdaptiveNavState extends State<AdaptiveNav> {
),
];
final _trailing = <String, IconData>{
final trailing = <String, IconData>{
'About': Icons.info_outline,
};
return _NavView(
extended: isDesktop,
destinations: _navigationDestinations,
trailing: _trailing,
destinations: navigationDestinations,
trailing: trailing,
);
}
}

View File

@@ -19,7 +19,7 @@ class LintExpansionTile extends StatefulWidget {
}) : super(key: key);
@override
_LintExpansionTileState createState() => _LintExpansionTileState();
State<LintExpansionTile> createState() => _LintExpansionTileState();
}
class _LintExpansionTileState extends State<LintExpansionTile> {
@@ -142,7 +142,7 @@ class _LintExpansionTileState extends State<LintExpansionTile> {
await showDialog<String>(
context: context,
builder: (context) {
return _NewProfileDialog(rule: rule);
return NewProfileDialog(rule: rule);
},
);
} else if (destinationProfileType ==
@@ -150,7 +150,7 @@ class _LintExpansionTileState extends State<LintExpansionTile> {
await showDialog<String>(
context: context,
builder: (context) {
return _ExistingProfileDialog(rule: rule);
return ExistingProfileDialog(rule: rule);
},
);
}
@@ -205,22 +205,27 @@ class _ProfileTypeDialog extends StatelessWidget {
}
}
class _NewProfileDialog extends StatelessWidget {
class NewProfileDialog extends StatefulWidget {
final Rule rule;
const _NewProfileDialog({
const NewProfileDialog({
required this.rule,
Key? key,
}) : super(key: key);
@override
State<NewProfileDialog> createState() => _NewProfileDialogState();
}
class _NewProfileDialogState extends State<NewProfileDialog> {
@override
Widget build(BuildContext context) {
String name = '';
final _formKey = GlobalKey<FormState>();
final formKey = GlobalKey<FormState>();
return AlertDialog(
title: const Text('Create new lint profile'),
content: Form(
key: _formKey,
key: formKey,
autovalidateMode: AutovalidateMode.onUserInteraction,
child: Column(
mainAxisSize: MainAxisSize.min,
@@ -251,13 +256,14 @@ class _NewProfileDialog extends StatelessWidget {
),
ElevatedButton(
onPressed: () async {
if (_formKey.currentState!.validate()) {
if (formKey.currentState!.validate()) {
var newProfile = RulesProfile(
name: name,
rules: [rule],
rules: [widget.rule],
);
await Provider.of<ProfilesStore>(context, listen: false)
.addToNewProfile(newProfile);
if (!mounted) return;
Navigator.pop(context);
}
},
@@ -268,14 +274,19 @@ class _NewProfileDialog extends StatelessWidget {
}
}
class _ExistingProfileDialog extends StatelessWidget {
const _ExistingProfileDialog({
class ExistingProfileDialog extends StatefulWidget {
const ExistingProfileDialog({
Key? key,
required this.rule,
}) : super(key: key);
final Rule rule;
@override
State<ExistingProfileDialog> createState() => _ExistingProfileDialogState();
}
class _ExistingProfileDialogState extends State<ExistingProfileDialog> {
@override
Widget build(BuildContext context) {
var profilesStore = Provider.of<ProfilesStore>(context);
@@ -291,7 +302,8 @@ class _ExistingProfileDialog extends StatelessWidget {
title: Text(savedProfiles[index].name),
onTap: () async {
await profilesStore.addToExistingProfile(
savedProfiles[index], rule);
savedProfiles[index], widget.rule);
if (!mounted) return;
Navigator.pop(context);
},
),

View File

@@ -18,7 +18,7 @@ class SavedRuleTile extends StatefulWidget {
}) : super(key: key);
@override
_SavedRuleTileState createState() => _SavedRuleTileState();
State<SavedRuleTile> createState() => _SavedRuleTileState();
}
class _SavedRuleTileState extends State<SavedRuleTile> {

View File

@@ -8,6 +8,9 @@ list(APPEND FLUTTER_PLUGIN_LIST
window_size
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST
)
set(PLUGIN_BUNDLED_LIBRARIES)
foreach(plugin ${FLUTTER_PLUGIN_LIST})
@@ -16,3 +19,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST})
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
endforeach(plugin)
foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
endforeach(ffi_plugin)

View File

@@ -29,12 +29,12 @@ EXTERNAL SOURCES:
:path: Flutter/ephemeral/.symlinks/plugins/window_size/macos
SPEC CHECKSUMS:
file_selector_macos: ff6dc948d4ddd34e8602a1f60b7d0b4cc6051a47
file_selector_macos: f1b08a781e66103e3ba279fd5d4024a2478b3af6
FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424
path_provider_macos: 160cab0d5461f0c0e02995469a98f24bdb9a3f1f
url_launcher_macos: 45af3d61de06997666568a7149c1be98b41c95d4
url_launcher_macos: 597e05b8e514239626bcf4a850fcf9ef5c856ec3
window_size: 339dafa0b27a95a62a843042038fa6c3c48de195
PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c
COCOAPODS: 1.11.0
COCOAPODS: 1.11.3

View File

@@ -49,7 +49,7 @@ packages:
name: build
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.1"
version: "2.3.0"
build_config:
dependency: transitive
description:
@@ -70,7 +70,7 @@ packages:
name: build_resolvers
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.6"
version: "2.0.8"
build_runner:
dependency: "direct dev"
description:
@@ -98,7 +98,7 @@ packages:
name: built_value
url: "https://pub.dartlang.org"
source: hosted
version: "8.1.4"
version: "8.3.0"
characters:
dependency: transitive
description:
@@ -140,7 +140,7 @@ packages:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0"
version: "1.16.0"
context_menus:
dependency: "direct main"
description:
@@ -161,14 +161,14 @@ packages:
name: cross_file
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.2"
version: "0.3.3"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
version: "3.0.2"
cupertino_icons:
dependency: "direct main"
description:
@@ -182,7 +182,7 @@ packages:
name: dart_style
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.2"
version: "2.2.3"
equatable:
dependency: "direct main"
description:
@@ -196,7 +196,7 @@ packages:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.3.0"
ffi:
dependency: transitive
description:
@@ -271,7 +271,7 @@ packages:
name: flutter_lints
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
version: "2.0.1"
flutter_markdown:
dependency: "direct main"
description:
@@ -372,7 +372,7 @@ packages:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.3"
version: "0.6.4"
json2yaml:
dependency: "direct main"
description:
@@ -400,7 +400,7 @@ packages:
name: lints
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
version: "2.0.0"
logging:
dependency: transitive
description:
@@ -428,7 +428,7 @@ packages:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
version: "0.1.4"
meta:
dependency: transitive
description:
@@ -442,7 +442,7 @@ packages:
name: mime
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
version: "1.0.2"
mockito:
dependency: "direct main"
description:
@@ -470,7 +470,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
version: "1.8.1"
path_provider:
dependency: transitive
description:
@@ -484,7 +484,7 @@ packages:
name: path_provider_android
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.12"
version: "2.0.13"
path_provider_ios:
dependency: transitive
description:
@@ -594,21 +594,21 @@ packages:
name: source_gen
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.1"
version: "1.2.2"
source_helper:
dependency: transitive
description:
name: source_helper
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.1"
version: "1.3.2"
source_span:
dependency: transitive
description:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
version: "1.8.2"
stack_trace:
dependency: transitive
description:
@@ -650,7 +650,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.8"
version: "0.4.9"
timing:
dependency: transitive
description:
@@ -671,14 +671,14 @@ packages:
name: url_launcher
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.20"
version: "6.1.0"
url_launcher_android:
dependency: transitive
description:
name: url_launcher_android
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.15"
version: "6.0.16"
url_launcher_ios:
dependency: transitive
description:
@@ -727,7 +727,7 @@ packages:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
version: "2.1.2"
watcher:
dependency: transitive
description:
@@ -741,14 +741,14 @@ packages:
name: web_socket_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
version: "2.2.0"
win32:
dependency: transitive
description:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.1"
version: "2.5.2"
window_size:
dependency: "direct main"
description:
@@ -773,5 +773,5 @@ packages:
source: hosted
version: "3.1.0"
sdks:
dart: ">=2.16.0 <3.0.0"
dart: ">=2.17.0-206.0.dev <3.0.0"
flutter: ">=2.10.0"

View File

@@ -3,10 +3,10 @@ description: A new Flutter project.
version: 1.0.0+1
publish_to: 'none'
publish_to: "none"
environment:
sdk: ">=2.15.0 <3.0.0"
sdk: ">=2.17.0-0 <3.0.0"
dependencies:
flutter:
@@ -39,7 +39,7 @@ dev_dependencies:
flutter_test:
sdk: flutter
build_runner: ^2.0.6
flutter_lints: ^1.0.3
flutter_lints: ^2.0.1
hive_generator: ^1.1.0
json_serializable: ^6.2.0

View File

@@ -8,6 +8,9 @@ list(APPEND FLUTTER_PLUGIN_LIST
window_size
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST
)
set(PLUGIN_BUNDLED_LIBRARIES)
foreach(plugin ${FLUTTER_PLUGIN_LIST})
@@ -16,3 +19,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST})
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
endforeach(plugin)
foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
endforeach(ffi_plugin)