1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-10 14:58:34 +00:00

Adding flutter_lints (#811)

This commit is contained in:
Brett Morgan
2021-06-08 08:15:11 +10:00
committed by GitHub
parent 55e02d6e4d
commit 14cce8b0f7
4 changed files with 49 additions and 15 deletions

View File

@@ -5,33 +5,33 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() => runApp(MyApp(Colors.blue));
void main() => runApp(const MyApp(color: Colors.blue));
@pragma('vm:entry-point')
void topMain() => runApp(MyApp(Colors.green));
void topMain() => runApp(const MyApp(color: Colors.green));
@pragma('vm:entry-point')
void bottomMain() => runApp(MyApp(Colors.purple));
void bottomMain() => runApp(const MyApp(color: Colors.purple));
class MyApp extends StatelessWidget {
MyApp(this.color);
const MyApp({Key key, @required this.color}) : super(key: key);
final Color color;
final MaterialColor color;
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: this.color,
primarySwatch: color,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
const MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
@@ -45,8 +45,8 @@ class _MyHomePageState extends State<MyHomePage> {
@override
void initState() {
super.initState();
_channel = MethodChannel('multiple-flutters');
_channel.setMethodCallHandler((MethodCall call) async {
_channel = const MethodChannel('multiple-flutters');
_channel.setMethodCallHandler((call) async {
if (call.method == "setCount") {
// A notification that the host platform's data model has been updated.
setState(() {
@@ -60,7 +60,7 @@ class _MyHomePageState extends State<MyHomePage> {
void _incrementCounter() {
// Mutations to the data model are forwarded to the host platform.
_channel.invokeMethod("incrementCount", _counter);
_channel.invokeMethod<void>("incrementCount", _counter);
}
@override
@@ -73,7 +73,7 @@ class _MyHomePageState extends State<MyHomePage> {
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
const Text(
'You have pushed the button this many times:',
),
Text(
@@ -82,13 +82,13 @@ class _MyHomePageState extends State<MyHomePage> {
),
TextButton(
onPressed: _incrementCounter,
child: Text('Add'),
child: const Text('Add'),
),
TextButton(
onPressed: () {
_channel.invokeMethod("next", _counter);
_channel.invokeMethod<void>("next", _counter);
},
child: Text('Next'),
child: const Text('Next'),
),
],
),