Adjust desktop_photo_search's lint rules (#816)

pull/831/head
Brett Morgan 4 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 test_types_in_equals: true
throw_in_finally: true throw_in_finally: true
unnecessary_statements: true unnecessary_statements: true
use_key_in_widget_constructors: false

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

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

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

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

Loading…
Cancel
Save