Adjust desktop_photo_search's lint rules (#816)

pull/831/head
Brett Morgan 3 years ago committed by GitHub
parent 7acef097f0
commit 9ad1fae51c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -17,4 +17,3 @@ linter:
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true
use_key_in_widget_constructors: false

@ -37,12 +37,14 @@ void main() {
create: (context) => PhotoSearchModel(
Unsplash(accessKey: unsplashAccessKey),
),
child: UnsplashSearchApp(),
child: const UnsplashSearchApp(),
),
);
}
class UnsplashSearchApp extends StatelessWidget {
const UnsplashSearchApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
@ -56,7 +58,7 @@ class UnsplashSearchApp extends StatelessWidget {
}
class UnsplashHomePage extends StatelessWidget {
const UnsplashHomePage({required this.title});
const UnsplashHomePage({required this.title, Key? key}) : super(key: key);
final String title;
@override
@ -70,7 +72,7 @@ class UnsplashHomePage extends StatelessWidget {
showDialog<void>(
context: context,
builder: (context) =>
PhotoSearchDialog(photoSearchModel.addSearch),
PhotoSearchDialog(callback: photoSearchModel.addSearch),
);
},
),
@ -139,7 +141,8 @@ class UnsplashHomePage extends StatelessWidget {
floatingActionButton: FloatingActionButton(
onPressed: () => showDialog<void>(
context: context,
builder: (context) => PhotoSearchDialog(photoSearchModel.addSearch),
builder: (context) =>
PhotoSearchDialog(callback: photoSearchModel.addSearch),
),
tooltip: 'Search for a photo',
child: const Icon(Icons.search),

@ -18,7 +18,8 @@ class PhotoDetails extends StatefulWidget {
const PhotoDetails({
required this.photo,
required this.onPhotoSave,
});
Key? key,
}) : super(key: key);
final Photo photo;
final PhotoDetailsPhotoSaveCallback onPhotoSave;

@ -7,7 +7,7 @@ import 'package:flutter/material.dart';
typedef PhotoSearchDialogCallback = void Function(String searchQuery);
class PhotoSearchDialog extends StatefulWidget {
const PhotoSearchDialog(this.callback);
const PhotoSearchDialog({required this.callback, Key? key}) : super(key: key);
final PhotoSearchDialogCallback callback;
@override
State<PhotoSearchDialog> createState() => _PhotoSearchDialogState();

@ -85,7 +85,8 @@ class FakeUnsplash implements Unsplash {
const fabKey = Key('fab');
class PhotoSearchModelTester extends StatelessWidget {
const PhotoSearchModelTester(this.query);
const PhotoSearchModelTester({required this.query, Key? key})
: super(key: key);
final String query;
@override
Widget build(BuildContext context) {
@ -110,7 +111,7 @@ void main() {
final unsplashSearches = PhotoSearchModel(FakeUnsplash());
final testWidget = ChangeNotifierProvider<PhotoSearchModel>(
create: (context) => unsplashSearches,
child: const PhotoSearchModelTester('clouds'),
child: const PhotoSearchModelTester(query: 'clouds'),
);
await tester.pumpWidget(testWidget);
expect(unsplashSearches.entries.length, 0);
@ -120,7 +121,7 @@ void main() {
final unsplashSearches = PhotoSearchModel(FakeUnsplash());
final testWidget = ChangeNotifierProvider<PhotoSearchModel>(
create: (context) => unsplashSearches,
child: const PhotoSearchModelTester('clouds'),
child: const PhotoSearchModelTester(query: 'clouds'),
);
await tester.pumpWidget(testWidget);
await tester.tap(find.byKey(fabKey));

Loading…
Cancel
Save