mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 22:09:06 +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';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
|
||||||
final ThemeData kIOSTheme = ThemeData(
|
final ThemeData kIOSTheme = ThemeData(
|
||||||
primarySwatch: Colors.orange,
|
primarySwatch: Colors.orange,
|
||||||
primaryColor: Colors.grey[100],
|
primaryColor: Colors.grey[100],
|
||||||
primaryColorBrightness: Brightness.light
|
primaryColorBrightness: Brightness.light,
|
||||||
);
|
);
|
||||||
final ThemeData kDefaultTheme = ThemeData(
|
final ThemeData kDefaultTheme = ThemeData(
|
||||||
primarySwatch: Colors.purple,
|
primarySwatch: Colors.purple,
|
||||||
accentColor: Colors.orangeAccent
|
accentColor: Colors.orangeAccent,
|
||||||
);
|
);
|
||||||
void main() {
|
void main() {
|
||||||
runApp(FriendlychatApp());
|
runApp(FriendlychatApp());
|
||||||
@@ -21,7 +20,9 @@ class FriendlychatApp extends StatelessWidget {
|
|||||||
Widget build(BuildContext build) {
|
Widget build(BuildContext build) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
title: 'Friendlychat',
|
title: 'Friendlychat',
|
||||||
theme: Theme.of(build).platform == TargetPlatform.iOS ? kIOSTheme : kDefaultTheme,
|
theme: Theme.of(build).platform == TargetPlatform.iOS
|
||||||
|
? kIOSTheme
|
||||||
|
: kDefaultTheme,
|
||||||
home: ChatAppHomePage(title: 'Friendlychat'),
|
home: ChatAppHomePage(title: 'Friendlychat'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -32,7 +33,6 @@ class ChatAppHomePage extends StatefulWidget {
|
|||||||
|
|
||||||
final String title;
|
final String title;
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_ChatAppHomePageState createState() => _ChatAppHomePageState();
|
_ChatAppHomePageState createState() => _ChatAppHomePageState();
|
||||||
}
|
}
|
||||||
@@ -80,7 +80,7 @@ class TwoPaneChatLayout extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Row(
|
return Row(
|
||||||
children: <Widget>[
|
children: [
|
||||||
Container(
|
Container(
|
||||||
child: ChatListScreen(chatEntries: chatEntries),
|
child: ChatListScreen(chatEntries: chatEntries),
|
||||||
constraints: BoxConstraints(minWidth: 100, maxWidth: 300),
|
constraints: BoxConstraints(minWidth: 100, maxWidth: 300),
|
||||||
@@ -107,21 +107,20 @@ class ChatListScreen extends StatelessWidget {
|
|||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
leading: CircleAvatar(
|
leading: CircleAvatar(
|
||||||
child: Text(chatEntries[index].name[0])
|
child: Text(chatEntries[index].name[0]),
|
||||||
),
|
),
|
||||||
title: Text(chatEntries[index].name),
|
title: Text(chatEntries[index].name),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.push(
|
Navigator.push<void>(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute<void>(
|
||||||
builder: (context) => ChatScreen(
|
builder: (context) =>
|
||||||
contactName: chatEntries[index].name
|
ChatScreen(contactName: chatEntries[index].name),
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -139,7 +138,7 @@ class ChatScreen extends StatefulWidget {
|
|||||||
|
|
||||||
class ChatScreenState extends State<ChatScreen> with TickerProviderStateMixin {
|
class ChatScreenState extends State<ChatScreen> with TickerProviderStateMixin {
|
||||||
final TextEditingController _textController = TextEditingController();
|
final TextEditingController _textController = TextEditingController();
|
||||||
final List<ChatMessage> _messages = <ChatMessage>[];
|
final List<ChatMessage> _messages = [];
|
||||||
final String contactName;
|
final String contactName;
|
||||||
|
|
||||||
ChatScreenState({@required this.contactName}) : super();
|
ChatScreenState({@required this.contactName}) : super();
|
||||||
@@ -149,14 +148,14 @@ class ChatScreenState extends State<ChatScreen> with TickerProviderStateMixin {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: Column(
|
body: Column(
|
||||||
children: <Widget>[
|
children: [
|
||||||
Flexible(
|
Flexible(
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
padding: EdgeInsets.all(8.0),
|
padding: EdgeInsets.all(8.0),
|
||||||
reverse: true,
|
reverse: true,
|
||||||
itemBuilder: (_, int index) => _messages[index],
|
itemBuilder: (_, index) => _messages[index],
|
||||||
itemCount: _messages.length,
|
itemCount: _messages.length,
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
Divider(height: 1.0),
|
Divider(height: 1.0),
|
||||||
Container(
|
Container(
|
||||||
@@ -164,7 +163,7 @@ class ChatScreenState extends State<ChatScreen> with TickerProviderStateMixin {
|
|||||||
child: _buildTextComposer(),
|
child: _buildTextComposer(),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,34 +181,37 @@ class ChatScreenState extends State<ChatScreen> with TickerProviderStateMixin {
|
|||||||
child: Container(
|
child: Container(
|
||||||
margin: const EdgeInsets.symmetric(horizontal: 8.0),
|
margin: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: <Widget>[
|
children: [
|
||||||
Flexible(
|
Flexible(
|
||||||
child: TextField(
|
child: TextField(
|
||||||
controller: _textController,
|
controller: _textController,
|
||||||
onSubmitted: _handleSubmitted,
|
onSubmitted: _handleSubmitted,
|
||||||
decoration: InputDecoration.collapsed(hintText: "Send a message"),
|
decoration:
|
||||||
onChanged: (String text) {
|
InputDecoration.collapsed(hintText: "Send a message"),
|
||||||
setState(() {
|
onChanged: (text) {
|
||||||
_isComposing = text.length > 0;
|
setState(() {
|
||||||
});
|
_isComposing = text.isNotEmpty;
|
||||||
},
|
});
|
||||||
)
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
margin: EdgeInsets.symmetric(horizontal: 4.0),
|
margin: EdgeInsets.symmetric(horizontal: 4.0),
|
||||||
child: IconButton( //modified
|
child: IconButton(
|
||||||
icon: Icon(Icons.send),
|
//modified
|
||||||
onPressed: _isComposing ?
|
icon: Icon(Icons.send),
|
||||||
() => _handleSubmitted(_textController.text) : null,
|
onPressed: _isComposing
|
||||||
)
|
? () => _handleSubmitted(_textController.text)
|
||||||
|
: null,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
)
|
),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleSubmitted (String text) {
|
void _handleSubmitted(String text) {
|
||||||
_textController.clear();
|
_textController.clear();
|
||||||
setState(() {
|
setState(() {
|
||||||
_isComposing = false;
|
_isComposing = false;
|
||||||
@@ -217,8 +219,8 @@ class ChatScreenState extends State<ChatScreen> with TickerProviderStateMixin {
|
|||||||
ChatMessage message = ChatMessage(
|
ChatMessage message = ChatMessage(
|
||||||
text: text,
|
text: text,
|
||||||
animationController: AnimationController(
|
animationController: AnimationController(
|
||||||
duration: Duration(milliseconds: 200),
|
duration: Duration(milliseconds: 200),
|
||||||
vsync: this
|
vsync: this,
|
||||||
),
|
),
|
||||||
name: contactName,
|
name: contactName,
|
||||||
);
|
);
|
||||||
@@ -237,16 +239,16 @@ class ChatMessage extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return SizeTransition(
|
return SizeTransition(
|
||||||
sizeFactor: CurvedAnimation(
|
sizeFactor: CurvedAnimation(
|
||||||
parent: animationController,
|
parent: animationController,
|
||||||
curve: Curves.easeOut
|
curve: Curves.easeOut,
|
||||||
),
|
),
|
||||||
axisAlignment: 0.0,
|
axisAlignment: 0.0,
|
||||||
child: Container(
|
child: Container(
|
||||||
margin: const EdgeInsets.symmetric(vertical: 10.0),
|
margin: const EdgeInsets.symmetric(vertical: 10.0),
|
||||||
child: Row(
|
child: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: [
|
||||||
Container(
|
Container(
|
||||||
margin: const EdgeInsets.only(right: 16.0),
|
margin: const EdgeInsets.only(right: 16.0),
|
||||||
child: CircleAvatar(child: Text(name[0])),
|
child: CircleAvatar(child: Text(name[0])),
|
||||||
@@ -254,7 +256,7 @@ class ChatMessage extends StatelessWidget {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: [
|
||||||
Text(name, style: Theme.of(context).textTheme.subhead),
|
Text(name, style: Theme.of(context).textTheme.subhead),
|
||||||
Container(
|
Container(
|
||||||
margin: const EdgeInsets.only(top: 5.0),
|
margin: const EdgeInsets.only(top: 5.0),
|
||||||
@@ -265,7 +267,7 @@ class ChatMessage extends StatelessWidget {
|
|||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -274,4 +276,4 @@ class ChatListEntry {
|
|||||||
final String name;
|
final String name;
|
||||||
|
|
||||||
ChatListEntry(this.name);
|
ChatListEntry(this.name);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "1.6.2"
|
version: "1.6.2"
|
||||||
pedantic:
|
pedantic:
|
||||||
dependency: transitive
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: pedantic
|
name: pedantic
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
@@ -143,4 +143,4 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.8"
|
version: "2.0.8"
|
||||||
sdks:
|
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
|
version: 1.0.0+1
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.1.0 <3.0.0"
|
sdk: ">=2.3.0-dev <3.0.0"
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
@@ -23,6 +23,7 @@ dependencies:
|
|||||||
# The following adds the Cupertino Icons font to your application.
|
# The following adds the Cupertino Icons font to your application.
|
||||||
# Use with the CupertinoIcons class for iOS style icons.
|
# Use with the CupertinoIcons class for iOS style icons.
|
||||||
cupertino_icons: ^0.1.2
|
cupertino_icons: ^0.1.2
|
||||||
|
pedantic: 1.5.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import 'package:flutter_test/flutter_test.dart';
|
|||||||
import 'package:friendlychat/main.dart';
|
import 'package:friendlychat/main.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
|
testWidgets('Counter increments smoke test', (tester) async {
|
||||||
// Build our app and trigger a frame.
|
// Build our app and trigger a frame.
|
||||||
await tester.pumpWidget(FriendlychatApp());
|
await tester.pumpWidget(FriendlychatApp());
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ packages:
|
|||||||
name: async
|
name: async
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.2.0"
|
version: "2.1.0"
|
||||||
boolean_selector:
|
boolean_selector:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -122,7 +122,7 @@ packages:
|
|||||||
name: quiver
|
name: quiver
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.3"
|
version: "2.0.2"
|
||||||
sky_engine:
|
sky_engine:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
@@ -169,7 +169,7 @@ packages:
|
|||||||
name: test_api
|
name: test_api
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.2.5"
|
version: "0.2.4"
|
||||||
typed_data:
|
typed_data:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ packages:
|
|||||||
name: async
|
name: async
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.2.0"
|
version: "2.1.0"
|
||||||
boolean_selector:
|
boolean_selector:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -87,7 +87,7 @@ packages:
|
|||||||
name: quiver
|
name: quiver
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.3"
|
version: "2.0.2"
|
||||||
sky_engine:
|
sky_engine:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
@@ -134,7 +134,7 @@ packages:
|
|||||||
name: test_api
|
name: test_api
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.2.5"
|
version: "0.2.4"
|
||||||
typed_data:
|
typed_data:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ packages:
|
|||||||
name: async
|
name: async
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.2.0"
|
version: "2.1.0"
|
||||||
boolean_selector:
|
boolean_selector:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -332,7 +332,7 @@ packages:
|
|||||||
name: quiver
|
name: quiver
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.3"
|
version: "2.0.2"
|
||||||
shelf:
|
shelf:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -407,7 +407,7 @@ packages:
|
|||||||
name: test_api
|
name: test_api
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.2.5"
|
version: "0.2.4"
|
||||||
timing:
|
timing:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
Reference in New Issue
Block a user