diff --git a/chrome-os-best-practices/analysis_options.yaml b/chrome-os-best-practices/analysis_options.yaml new file mode 100644 index 000000000..f117e8a5f --- /dev/null +++ b/chrome-os-best-practices/analysis_options.yaml @@ -0,0 +1,30 @@ +include: package:pedantic/analysis_options.yaml + +analyzer: + strong-mode: + implicit-casts: false + implicit-dynamic: false + +linter: + rules: + - avoid_types_on_closure_parameters + - avoid_void_async + - await_only_futures + - camel_case_types + - cancel_subscriptions + - close_sinks + - constant_identifier_names + - control_flow_in_finally + - empty_statements + - hash_and_equals + - implementation_imports + - non_constant_identifier_names + - package_api_docs + - package_names + - package_prefixed_library_names + - test_types_in_equals + - throw_in_finally + - unnecessary_brace_in_string_interps + - unnecessary_getters_setters + - unnecessary_new + - unnecessary_statements diff --git a/chrome-os-best-practices/lib/main.dart b/chrome-os-best-practices/lib/main.dart index 1c4dbce6e..960458d4e 100755 --- a/chrome-os-best-practices/lib/main.dart +++ b/chrome-os-best-practices/lib/main.dart @@ -1,14 +1,13 @@ import 'package:flutter/material.dart'; - final ThemeData kIOSTheme = ThemeData( primarySwatch: Colors.orange, primaryColor: Colors.grey[100], - primaryColorBrightness: Brightness.light + primaryColorBrightness: Brightness.light, ); final ThemeData kDefaultTheme = ThemeData( primarySwatch: Colors.purple, - accentColor: Colors.orangeAccent + accentColor: Colors.orangeAccent, ); void main() { runApp(FriendlychatApp()); @@ -21,7 +20,9 @@ class FriendlychatApp extends StatelessWidget { Widget build(BuildContext build) { return MaterialApp( title: 'Friendlychat', - theme: Theme.of(build).platform == TargetPlatform.iOS ? kIOSTheme : kDefaultTheme, + theme: Theme.of(build).platform == TargetPlatform.iOS + ? kIOSTheme + : kDefaultTheme, home: ChatAppHomePage(title: 'Friendlychat'), ); } @@ -32,7 +33,6 @@ class ChatAppHomePage extends StatefulWidget { final String title; - @override _ChatAppHomePageState createState() => _ChatAppHomePageState(); } @@ -80,7 +80,7 @@ class TwoPaneChatLayout extends StatelessWidget { @override Widget build(BuildContext context) { return Row( - children: [ + children: [ Container( child: ChatListScreen(chatEntries: chatEntries), constraints: BoxConstraints(minWidth: 100, maxWidth: 300), @@ -107,21 +107,20 @@ class ChatListScreen extends StatelessWidget { itemBuilder: (context, index) { return ListTile( leading: CircleAvatar( - child: Text(chatEntries[index].name[0]) + child: Text(chatEntries[index].name[0]), ), title: Text(chatEntries[index].name), onTap: () { - Navigator.push( + Navigator.push( context, - MaterialPageRoute( - builder: (context) => ChatScreen( - contactName: chatEntries[index].name - ), + MaterialPageRoute( + builder: (context) => + ChatScreen(contactName: chatEntries[index].name), ), ); }, ); - } + }, ), ); } @@ -139,7 +138,7 @@ class ChatScreen extends StatefulWidget { class ChatScreenState extends State with TickerProviderStateMixin { final TextEditingController _textController = TextEditingController(); - final List _messages = []; + final List _messages = []; final String contactName; ChatScreenState({@required this.contactName}) : super(); @@ -149,14 +148,14 @@ class ChatScreenState extends State with TickerProviderStateMixin { Widget build(BuildContext context) { return Scaffold( body: Column( - children: [ + children: [ Flexible( child: ListView.builder( padding: EdgeInsets.all(8.0), reverse: true, - itemBuilder: (_, int index) => _messages[index], + itemBuilder: (_, index) => _messages[index], itemCount: _messages.length, - ) + ), ), Divider(height: 1.0), Container( @@ -164,7 +163,7 @@ class ChatScreenState extends State with TickerProviderStateMixin { child: _buildTextComposer(), ) ], - ) + ), ); } @@ -182,34 +181,37 @@ class ChatScreenState extends State with TickerProviderStateMixin { child: Container( margin: const EdgeInsets.symmetric(horizontal: 8.0), child: Row( - children: [ + children: [ Flexible( - child: TextField( - controller: _textController, - onSubmitted: _handleSubmitted, - decoration: InputDecoration.collapsed(hintText: "Send a message"), - onChanged: (String text) { - setState(() { - _isComposing = text.length > 0; - }); - }, - ) + child: TextField( + controller: _textController, + onSubmitted: _handleSubmitted, + decoration: + InputDecoration.collapsed(hintText: "Send a message"), + onChanged: (text) { + setState(() { + _isComposing = text.isNotEmpty; + }); + }, + ), ), Container( margin: EdgeInsets.symmetric(horizontal: 4.0), - child: IconButton( //modified - icon: Icon(Icons.send), - onPressed: _isComposing ? - () => _handleSubmitted(_textController.text) : null, - ) + child: IconButton( + //modified + icon: Icon(Icons.send), + onPressed: _isComposing + ? () => _handleSubmitted(_textController.text) + : null, + ), ) ], - ) - ) + ), + ), ); } - void _handleSubmitted (String text) { + void _handleSubmitted(String text) { _textController.clear(); setState(() { _isComposing = false; @@ -217,8 +219,8 @@ class ChatScreenState extends State with TickerProviderStateMixin { ChatMessage message = ChatMessage( text: text, animationController: AnimationController( - duration: Duration(milliseconds: 200), - vsync: this + duration: Duration(milliseconds: 200), + vsync: this, ), name: contactName, ); @@ -237,16 +239,16 @@ class ChatMessage extends StatelessWidget { @override Widget build(BuildContext context) { return SizeTransition( - sizeFactor: CurvedAnimation( + sizeFactor: CurvedAnimation( parent: animationController, - curve: Curves.easeOut - ), - axisAlignment: 0.0, - child: Container( + curve: Curves.easeOut, + ), + axisAlignment: 0.0, + child: Container( margin: const EdgeInsets.symmetric(vertical: 10.0), child: Row( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Container( margin: const EdgeInsets.only(right: 16.0), child: CircleAvatar(child: Text(name[0])), @@ -254,7 +256,7 @@ class ChatMessage extends StatelessWidget { Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Text(name, style: Theme.of(context).textTheme.subhead), Container( margin: const EdgeInsets.only(top: 5.0), @@ -265,7 +267,7 @@ class ChatMessage extends StatelessWidget { ) ], ), - ) + ), ); } } @@ -274,4 +276,4 @@ class ChatListEntry { final String name; ChatListEntry(this.name); -} \ No newline at end of file +} diff --git a/chrome-os-best-practices/pubspec.lock b/chrome-os-best-practices/pubspec.lock index f6b0bbdcf..fcff2cebe 100755 --- a/chrome-os-best-practices/pubspec.lock +++ b/chrome-os-best-practices/pubspec.lock @@ -68,7 +68,7 @@ packages: source: hosted version: "1.6.2" pedantic: - dependency: transitive + dependency: "direct main" description: name: pedantic url: "https://pub.dartlang.org" @@ -143,4 +143,4 @@ packages: source: hosted version: "2.0.8" sdks: - dart: ">=2.2.0 <3.0.0" + dart: ">=2.3.0-dev <3.0.0" diff --git a/chrome-os-best-practices/pubspec.yaml b/chrome-os-best-practices/pubspec.yaml index f4b88112d..0ef0f353b 100755 --- a/chrome-os-best-practices/pubspec.yaml +++ b/chrome-os-best-practices/pubspec.yaml @@ -14,7 +14,7 @@ description: A new Flutter application. version: 1.0.0+1 environment: - sdk: ">=2.1.0 <3.0.0" + sdk: ">=2.3.0-dev <3.0.0" dependencies: flutter: @@ -23,6 +23,7 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^0.1.2 + pedantic: 1.5.0 dev_dependencies: flutter_test: diff --git a/chrome-os-best-practices/test/widget_test.dart b/chrome-os-best-practices/test/widget_test.dart index 2e8b47d6c..1af688a24 100755 --- a/chrome-os-best-practices/test/widget_test.dart +++ b/chrome-os-best-practices/test/widget_test.dart @@ -11,7 +11,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:friendlychat/main.dart'; void main() { - testWidgets('Counter increments smoke test', (WidgetTester tester) async { + testWidgets('Counter increments smoke test', (tester) async { // Build our app and trigger a frame. await tester.pumpWidget(FriendlychatApp()); diff --git a/flutter_maps_firestore/pubspec.lock b/flutter_maps_firestore/pubspec.lock index bdc3e75e0..f6aea7f75 100644 --- a/flutter_maps_firestore/pubspec.lock +++ b/flutter_maps_firestore/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.2.0" + version: "2.1.0" boolean_selector: dependency: transitive description: @@ -122,7 +122,7 @@ packages: name: quiver url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "2.0.2" sky_engine: dependency: transitive description: flutter @@ -169,7 +169,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.5" + version: "0.2.4" typed_data: dependency: transitive description: diff --git a/isolate_example/pubspec.lock b/isolate_example/pubspec.lock index 7774e55cc..c6bb6436b 100644 --- a/isolate_example/pubspec.lock +++ b/isolate_example/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.2.0" + version: "2.1.0" boolean_selector: dependency: transitive description: @@ -87,7 +87,7 @@ packages: name: quiver url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "2.0.2" sky_engine: dependency: transitive description: flutter @@ -134,7 +134,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.5" + version: "0.2.4" typed_data: dependency: transitive description: diff --git a/jsonexample/pubspec.lock b/jsonexample/pubspec.lock index c999a5d3f..cc3441c09 100644 --- a/jsonexample/pubspec.lock +++ b/jsonexample/pubspec.lock @@ -28,7 +28,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.2.0" + version: "2.1.0" boolean_selector: dependency: transitive description: @@ -332,7 +332,7 @@ packages: name: quiver url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "2.0.2" shelf: dependency: transitive description: @@ -407,7 +407,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.5" + version: "0.2.4" timing: dependency: transitive description: