Skip to content

Commit

Permalink
Update example to flutter_lints.
Browse files Browse the repository at this point in the history
  • Loading branch information
edufolly committed Sep 5, 2021
1 parent 5473b11 commit 0b4380d
Show file tree
Hide file tree
Showing 40 changed files with 277 additions and 217 deletions.
10 changes: 4 additions & 6 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@ linter:
always_use_package_imports: true
annotate_overrides: true
# avoid_annotating_with_dynamic: true
# avoid_multiple_declarations_per_line: true
# avoid_print: true
avoid_multiple_declarations_per_line: true
avoid_types_as_parameter_names: true
# camel_case_types: true
camel_case_types: true
empty_constructor_bodies: true
lines_longer_than_80_chars: false
# no_logic_in_create_state: true
no_logic_in_create_state: true
omit_local_variable_types: false
prefer_if_null_operators: true
prefer_typing_uninitialized_variables: true
# throw_in_finally: true
prefer_typing_uninitialized_variables: true
29 changes: 24 additions & 5 deletions example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
include: package:pedantic/analysis_options.yaml
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml

analizer:
exclude: [ example/** ]
strong-mode:
implicit-casts: false

linter:
rules:
always_specify_types: true
always_declare_return_types: true
omit_local_variable_types: false
prefer_typing_uninitialized_variables: true
always_specify_types: true
always_use_package_imports: true
avoid_types_as_parameter_names: true
annotate_overrides: true
# avoid_annotating_with_dynamic: true
avoid_multiple_declarations_per_line: true
avoid_print: false
avoid_types_as_parameter_names: true
camel_case_types: true
empty_constructor_bodies: true
lines_longer_than_80_chars: false
no_logic_in_create_state: true
omit_local_variable_types: false
prefer_if_null_operators: true
prefer_typing_uninitialized_variables: true
10 changes: 8 additions & 2 deletions example/lib/advanced/base_consumer_mock.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ import 'package:folly_fields_example/example_model.dart';
///
///
///
@immutable
abstract class BaseConsumerMock<T extends AbstractModel<Object>>
extends AbstractConsumer<T> {
///
///
///
const BaseConsumerMock();

///
///
///
Expand All @@ -17,7 +23,7 @@ abstract class BaseConsumerMock<T extends AbstractModel<Object>>
List<String>? paths,
) =>
Future<ConsumerPermission>.value(
ConsumerPermission(
const ConsumerPermission(
name: 'mock',
iconName: 'question',
view: true,
Expand All @@ -43,7 +49,7 @@ abstract class BaseConsumerMock<T extends AbstractModel<Object>>
int qtd = int.tryParse(qsParam['q'] ?? '50') ?? 50;

return Future<List<T>>.delayed(
Duration(seconds: 2),
const Duration(seconds: 2),
() => List<T>.generate(
qtd,
(int index) => (ExampleModel.generate(seed: first + index) as T),
Expand Down
3 changes: 1 addition & 2 deletions example/lib/advanced/example_builder.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:folly_fields/crud/abstract_ui_builder.dart';
import 'package:folly_fields_example/example_model.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
Expand All @@ -11,7 +10,7 @@ class ExampleBuilder extends AbstractUIBuilder<ExampleModel> {
///
///
///
ExampleBuilder([String prefix = '']) : super(prefix);
const ExampleBuilder([String prefix = '']) : super(prefix);

///
///
Expand Down
5 changes: 5 additions & 0 deletions example/lib/advanced/example_consumer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import 'package:folly_fields_example/example_model.dart';
///
///
class ExampleConsumer extends BaseConsumerMock<ExampleModel> {
///
///
///
const ExampleConsumer();

///
///
///
Expand Down
1 change: 0 additions & 1 deletion example/lib/advanced/example_edit.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:folly_fields/crud/abstract_edit.dart';
import 'package:folly_fields/fields/bool_field.dart';
import 'package:folly_fields/fields/cep_field.dart';
Expand Down
2 changes: 1 addition & 1 deletion example/lib/advanced/example_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ExampleList
selection: selection,
multipleSelection: multipleSelection,
forceOffline: false,
consumer: ExampleConsumer(),
consumer: const ExampleConsumer(),
uiBuilder: ExampleBuilder(prefix),
onAdd: (
BuildContext context,
Expand Down
16 changes: 8 additions & 8 deletions example/lib/code_link.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class CodeLink extends StatelessWidget {
child: child,
),
IconButton(
icon: Text(
icon: const Text(
'?',
style: TextStyle(
fontSize: 18.0,
Expand Down Expand Up @@ -73,7 +73,7 @@ class CodeLink extends StatelessWidget {
content: ClipRRect(
borderRadius: BorderRadius.circular(12.0),
child: Container(
padding: EdgeInsets.all(12.0),
padding: const EdgeInsets.all(12.0),
color: Colors.black38,
child: SingleChildScrollView(
child: HighlightView(
Expand All @@ -87,12 +87,12 @@ class CodeLink extends StatelessWidget {
),
actions: <Widget>[
ElevatedButton.icon(
label: Text('Copiar'),
icon: Icon(Icons.copy),
label: const Text('Copiar'),
icon: const Icon(Icons.copy),
onPressed: () async {
await Clipboard.setData(ClipboardData(text: example));
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
const SnackBar(
content: Text(
'Código copiado para a área de transferência.',
),
Expand All @@ -101,8 +101,8 @@ class CodeLink extends StatelessWidget {
},
),
ElevatedButton.icon(
label: Text('Código Fonte'),
icon: Icon(FontAwesomeIcons.github),
label: const Text('Código Fonte'),
icon: const Icon(FontAwesomeIcons.github),
onPressed: () async {
if (await canLaunch(source)) {
await launch(source);
Expand All @@ -116,7 +116,7 @@ class CodeLink extends StatelessWidget {
),
ElevatedButton(
onPressed: () => Navigator.of(context).pop(),
child: Text('Fechar'),
child: const Text('Fechar'),
),
],
);
Expand Down
15 changes: 10 additions & 5 deletions example/lib/example_table.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ import 'package:url_launcher/url_launcher.dart';
///
///
class ExampleTable extends StatefulWidget {
///
///
///
const ExampleTable({Key? key}) : super(key: key);

///
///
///
Expand Down Expand Up @@ -44,11 +49,11 @@ class _ExampleTableState extends State<ExampleTable> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Tabela'),
title: const Text('Tabela'),
actions: <Widget>[
/// Github
IconButton(
icon: Icon(FontAwesomeIcons.github),
icon: const Icon(FontAwesomeIcons.github),
onPressed: () async {
const String url = 'https://github.com/edufolly/folly_fields/'
'blob/main/example/lib/example_table.dart';
Expand All @@ -72,7 +77,7 @@ class _ExampleTableState extends State<ExampleTable> {
headerHeight: rowHeight,
rowHeight: rowHeight,
freezeColumns: 2,
columnsSize: <double>[
columnsSize: const <double>[
160.0,
230.0,
150.0,
Expand Down Expand Up @@ -138,8 +143,8 @@ class _ExampleTableState extends State<ExampleTable> {
MaterialPageRoute<void>(
builder: (_) => ExampleEdit(
list[row],
ExampleBuilder(),
ExampleConsumer(),
const ExampleBuilder(),
const ExampleConsumer(),
false,
),
),
Expand Down
32 changes: 19 additions & 13 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,19 @@ void main() {

FollyFields.start(Config(), debug: debug);

runApp(MyApp());
runApp(const MyApp());
}

///
///
///
class MyApp extends StatelessWidget {

///
///
///
const MyApp({Key? key}) : super(key: key);

///
///
///
Expand All @@ -71,19 +77,19 @@ class MyApp extends StatelessWidget {
brightness: Brightness.dark,
snackBarTheme: ThemeData.dark().snackBarTheme.copyWith(
backgroundColor: Colors.deepOrange,
contentTextStyle: TextStyle(
contentTextStyle: const TextStyle(
color: Colors.white,
fontSize: 16.0,
),
),
),
// home: MyHomePage(),
routes: <String, WidgetBuilder>{
'/': (_) => MyHomePage(),
'/table': (_) => ExampleTable(),
'/': (_) => const MyHomePage(),
'/table': (_) => const ExampleTable(),
'/list': (_) => ExampleList(),
},
localizationsDelegates: <LocalizationsDelegate<dynamic>>[
localizationsDelegates: const <LocalizationsDelegate<dynamic>>[
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
Expand All @@ -101,7 +107,7 @@ class MyHomePage extends StatefulWidget {
///
///
///
MyHomePage({Key? key}) : super(key: key);
const MyHomePage({Key? key}) : super(key: key);

///
///
Expand Down Expand Up @@ -136,11 +142,11 @@ class _MyHomePageState extends State<MyHomePage> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Exemplo - Folly Fields'),
title: const Text('Exemplo - Folly Fields'),
actions: <Widget>[
/// Github
IconButton(
icon: Icon(FontAwesomeIcons.github),
icon: const Icon(FontAwesomeIcons.github),
onPressed: () async {
const String url = 'https://github.com/edufolly/folly_fields';
if (await canLaunch(url)) {
Expand All @@ -157,14 +163,14 @@ class _MyHomePageState extends State<MyHomePage> {

/// Table
IconButton(
icon: Icon(FontAwesomeIcons.table),
icon: const Icon(FontAwesomeIcons.table),
onPressed: () => Navigator.of(context).pushNamed('/table'),
tooltip: 'Tabela',
),

/// AbstractList
IconButton(
icon: Icon(FontAwesomeIcons.list),
icon: const Icon(FontAwesomeIcons.list),
onPressed: () => Navigator.of(context).pushNamed('/list'),
tooltip: 'Lista',
),
Expand Down Expand Up @@ -683,8 +689,8 @@ class _MyHomePageState extends State<MyHomePage> {
horizontal: 8.0,
),
child: ElevatedButton.icon(
icon: Icon(Icons.send),
label: Text('ENVIAR'),
icon: const Icon(Icons.send),
label: const Text('ENVIAR'),
onPressed: _send,
),
),
Expand All @@ -694,7 +700,7 @@ class _MyHomePageState extends State<MyHomePage> {
);
}

return WaitingMessage();
return const WaitingMessage();
},
),
),
Expand Down
16 changes: 15 additions & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.7.0"
flutter_lints:
dependency: "direct dev"
description:
name: flutter_lints
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
flutter_localizations:
dependency: transitive
description: flutter
Expand Down Expand Up @@ -203,6 +210,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.3"
lints:
dependency: transitive
description:
name: lints
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
matcher:
dependency: transitive
description:
Expand Down Expand Up @@ -260,7 +274,7 @@ packages:
source: hosted
version: "2.0.0"
pedantic:
dependency: "direct dev"
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
Expand Down
6 changes: 3 additions & 3 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: A new Flutter project.

publish_to: 'none'

version: 0.2.18+63
version: 0.2.19+64

environment:
sdk: ">=2.12.0 <3.0.0"
Expand Down Expand Up @@ -31,8 +31,8 @@ dev_dependencies:
flutter_test:
sdk: flutter

# https://pub.dev/packages/pedantic
pedantic: 1.11.1
# https://pub.dev/packages/flutter_lints
flutter_lints: ^1.0.0

flutter:
uses-material-design: true
Loading

0 comments on commit 0b4380d

Please sign in to comment.