mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 13:58:47 +00:00
Add analysis_options, re-format, add commas. (#101)
This commit is contained in:
30
chrome-os-best-practices/analysis_options.yaml
Normal file
30
chrome-os-best-practices/analysis_options.yaml
Normal file
@@ -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
|
||||
@@ -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: <Widget>[
|
||||
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<void>(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChatScreen(
|
||||
contactName: chatEntries[index].name
|
||||
),
|
||||
MaterialPageRoute<void>(
|
||||
builder: (context) =>
|
||||
ChatScreen(contactName: chatEntries[index].name),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -139,7 +138,7 @@ class ChatScreen extends StatefulWidget {
|
||||
|
||||
class ChatScreenState extends State<ChatScreen> with TickerProviderStateMixin {
|
||||
final TextEditingController _textController = TextEditingController();
|
||||
final List<ChatMessage> _messages = <ChatMessage>[];
|
||||
final List<ChatMessage> _messages = [];
|
||||
final String contactName;
|
||||
|
||||
ChatScreenState({@required this.contactName}) : super();
|
||||
@@ -149,14 +148,14 @@ class ChatScreenState extends State<ChatScreen> with TickerProviderStateMixin {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Column(
|
||||
children: <Widget>[
|
||||
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<ChatScreen> with TickerProviderStateMixin {
|
||||
child: _buildTextComposer(),
|
||||
)
|
||||
],
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -182,30 +181,33 @@ class ChatScreenState extends State<ChatScreen> with TickerProviderStateMixin {
|
||||
child: Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
children: [
|
||||
Flexible(
|
||||
child: TextField(
|
||||
controller: _textController,
|
||||
onSubmitted: _handleSubmitted,
|
||||
decoration: InputDecoration.collapsed(hintText: "Send a message"),
|
||||
onChanged: (String text) {
|
||||
decoration:
|
||||
InputDecoration.collapsed(hintText: "Send a message"),
|
||||
onChanged: (text) {
|
||||
setState(() {
|
||||
_isComposing = text.length > 0;
|
||||
_isComposing = text.isNotEmpty;
|
||||
});
|
||||
},
|
||||
)
|
||||
),
|
||||
),
|
||||
Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 4.0),
|
||||
child: IconButton( //modified
|
||||
child: IconButton(
|
||||
//modified
|
||||
icon: Icon(Icons.send),
|
||||
onPressed: _isComposing ?
|
||||
() => _handleSubmitted(_textController.text) : null,
|
||||
)
|
||||
onPressed: _isComposing
|
||||
? () => _handleSubmitted(_textController.text)
|
||||
: null,
|
||||
),
|
||||
)
|
||||
],
|
||||
)
|
||||
)
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -218,7 +220,7 @@ class ChatScreenState extends State<ChatScreen> with TickerProviderStateMixin {
|
||||
text: text,
|
||||
animationController: AnimationController(
|
||||
duration: Duration(milliseconds: 200),
|
||||
vsync: this
|
||||
vsync: this,
|
||||
),
|
||||
name: contactName,
|
||||
);
|
||||
@@ -239,14 +241,14 @@ class ChatMessage extends StatelessWidget {
|
||||
return SizeTransition(
|
||||
sizeFactor: CurvedAnimation(
|
||||
parent: animationController,
|
||||
curve: Curves.easeOut
|
||||
curve: Curves.easeOut,
|
||||
),
|
||||
axisAlignment: 0.0,
|
||||
child: Container(
|
||||
margin: const EdgeInsets.symmetric(vertical: 10.0),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
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: <Widget>[
|
||||
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 {
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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());
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user