Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: fix all lint issues #100

Merged
merged 13 commits into from
Dec 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,9 @@ Check proposal documents for [v1.0](https://github.com/fluttercommunity/backdrop
2. Fork the [repository](https://github.com/fluttercommunity/backdrop).
3. Pick an issue to work on from [issue tracker](https://github.com/fluttercommunity/backdrop/issues).
4. Implement it.
5. Add your name and email in `authors` section in `pubspec.yaml` file.
6. Send merge request.
7. Star this project.
8. Become a hero!!
5. Send merge request.
6. Star this project.
7. Become a hero!!

## Features and bugs
Please file feature requests and bugs at the [issue tracker](https://github.com/fluttercommunity/backdrop/issues).
Expand Down
36 changes: 29 additions & 7 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,35 @@
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`.

analyzer:
exclude: [build/**]
strong-mode:
implicit-casts: false
# 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

linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at
# https://dart-lang.github.io/linter/lints/index.html.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
- camel_case_types
- public_member_api_docs
# doc-style related: https://dart.dev/guides/language/effective-dart/documentation
- package_api_docs
- public_member_api_docs
- comment_references
- slash_for_doc_comments
# pub related: https://dart.dev/tools/linter-rules#pub-rules
- depend_on_referenced_packages
- secure_pubspec_urls

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
27 changes: 16 additions & 11 deletions demo/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,28 @@ import 'package:flutter/material.dart';
import 'package:gallerize/gallerize.dart';
import 'package:gallerize/themes/gallerize_theme_data.dart';

void main() => runApp(DemoApp());
void main() => runApp(const DemoApp());

/// Demo app that provides a show-case of different backdrop use cases.
class DemoApp extends StatelessWidget {
/// Default constructor for [DemoApp].
const DemoApp({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return MaterialApp(
title: "Backdrop Gallery",
theme: GallerizeThemeData.darkThemeData,
home: HomePage(),
home: _HomePage(),
);
}
}

/// The home page of the demo app showing a selection of use cases.
class HomePage extends StatelessWidget {
List<UseCase> _useCases = [
class _HomePage extends StatelessWidget {
_HomePage({Key? key}) : super(key: key);

final _useCases = <UseCase>[
ContextualInfoUseCase(),
ContextualControlsUseCase(),
NavigationUseCase(),
Expand All @@ -34,16 +39,16 @@ class HomePage extends StatelessWidget {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Backdrop Gallery"),
title: const Text("Backdrop Gallery"),
),
body: Column(
children: [
Container(
margin: EdgeInsets.all(16.0),
child:
Text("This app shows some use cases for the backdrop widget. "
"Open any one to show information about it, preview it and "
"look at its code."),
margin: const EdgeInsets.all(16.0),
child: const Text(
"This app shows some use cases for the backdrop widget. "
"Open any one to show information about it, preview it and "
"look at its code."),
),
ListView.separated(
itemCount: _useCases.length,
Expand All @@ -52,7 +57,7 @@ class HomePage extends StatelessWidget {
onTap: () => _openDemoPage(context, _useCases[index]),
),
shrinkWrap: true,
separatorBuilder: (context, index) => Divider(),
separatorBuilder: (context, index) => const Divider(),
),
],
),
Expand Down
59 changes: 31 additions & 28 deletions demo/lib/use_cases/contextual_controls/contextual_controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,33 @@ import 'package:flutter/material.dart';

/// Contextual controls preview app.
class ContextualControls extends StatefulWidget {
/// Default constructor for [ContextualControls].
const ContextualControls({Key? key}) : super(key: key);

@override
_ContextualControlsState createState() => _ContextualControlsState();
}

class _ContextualControlsState extends State<ContextualControls> {
static final _COLOR_MAP = {
static final _colorMap = {
Colors.black: "Black",
Colors.red: "Red",
Colors.green: "Green",
Colors.blue: "Blue"
};
static const _RAM_CHOICES = [4, 8, 16];
static const _ramChoices = [4, 8, 16];

Color _color = _COLOR_MAP.keys.first;
Color _color = _colorMap.keys.first;
double _resolution = 15.0;
int _ram = _RAM_CHOICES.first;
int _ram = _ramChoices.first;

@override
Widget build(BuildContext context) {
return Theme(
data: ThemeData.light(),
child: BackdropScaffold(
appBar: BackdropAppBar(
title: Text("Contextual Controls Example"),
title: const Text("Contextual Controls Example"),
automaticallyImplyLeading: false,
),
backLayer: _createBackLayer(context),
Expand All @@ -41,7 +44,7 @@ class _ContextualControlsState extends State<ContextualControls> {
ListTile(
leading: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
children: const [
Text(
"Color",
),
Expand All @@ -50,10 +53,10 @@ class _ContextualControlsState extends State<ContextualControls> {
title: DropdownButton<Color>(
isExpanded: true,
value: _color,
items: _COLOR_MAP.keys.map<DropdownMenuItem<Color>>((Color c) {
items: _colorMap.keys.map<DropdownMenuItem<Color>>((Color c) {
return DropdownMenuItem<Color>(
value: c,
child: Text(_COLOR_MAP[c]!),
child: Text(_colorMap[c]!),
);
}).toList(),
onChanged: (Color? newValue) {
Expand All @@ -66,7 +69,7 @@ class _ContextualControlsState extends State<ContextualControls> {
ListTile(
leading: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
children: const [
Text("Resolution"),
],
),
Expand All @@ -86,14 +89,14 @@ class _ContextualControlsState extends State<ContextualControls> {
ListTile(
leading: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
children: const [
Text("RAM"),
],
),
title: DropdownButton<int>(
isExpanded: true,
value: _ram,
items: _RAM_CHOICES.map<DropdownMenuItem<int>>((int r) {
items: _ramChoices.map<DropdownMenuItem<int>>((int r) {
return DropdownMenuItem<int>(
value: r,
child: Text("${r.toString()} GB"),
Expand All @@ -108,15 +111,15 @@ class _ContextualControlsState extends State<ContextualControls> {
),
Builder(
builder: (context) => MaterialButton(
child: Text("Return to product page"),
child: const Text("Return to product page"),
onPressed: () => Backdrop.of(context).fling(),
))
],
shrinkWrap: true,
);

Widget _createFrontLayer(BuildContext context) => Container(
margin: EdgeInsets.all(16.0),
margin: const EdgeInsets.all(16.0),
child: Column(
children: [
Row(
Expand All @@ -138,21 +141,21 @@ class _ContextualControlsState extends State<ContextualControls> {
],
),
Container(
margin: EdgeInsets.all(8.0),
margin: const EdgeInsets.all(8.0),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Row(
children: [
children: const [
Icon(Icons.star, color: Colors.grey),
Icon(Icons.star, color: Colors.grey),
Icon(Icons.star, color: Colors.grey),
Icon(Icons.star, color: Colors.grey),
Icon(Icons.star_half, color: Colors.grey),
],
),
Text(
const Text(
"73 Reviews",
style: TextStyle(color: Colors.grey),
)
Expand All @@ -163,64 +166,64 @@ class _ContextualControlsState extends State<ContextualControls> {
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
const Text(
"Price",
style: TextStyle(color: Colors.grey),
),
Container(
margin: EdgeInsets.all(8.0),
child: Text(
margin: const EdgeInsets.all(8.0),
child: const Text(
"\$999",
style: TextStyle(fontSize: 18),
),
),
],
),
Container(
margin: EdgeInsets.only(
margin: const EdgeInsets.only(
top: 32.0, left: 8.0, right: 8.0, bottom: 8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
mainAxisSize: MainAxisSize.max,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [Text("Resolution")],
children: const [Text("Resolution")],
),
Text(
"${_resolution.toString()}\"",
style: TextStyle(fontWeight: FontWeight.bold),
style: const TextStyle(fontWeight: FontWeight.bold),
),
],
),
),
Container(
margin: EdgeInsets.only(
margin: const EdgeInsets.only(
top: 8.0, left: 8.0, right: 8.0, bottom: 32.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
mainAxisSize: MainAxisSize.max,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [Text("RAM")],
children: const [Text("RAM")],
),
Text(
"${_ram.toString()} GB",
style: TextStyle(fontWeight: FontWeight.bold),
style: const TextStyle(fontWeight: FontWeight.bold),
),
],
),
),
Container(
margin: EdgeInsets.all(16.0),
margin: const EdgeInsets.all(16.0),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Builder(
builder: (context) => RaisedButton(
child: Text("Configure"),
builder: (context) => ElevatedButton(
child: const Text("Configure"),
onPressed: () => Backdrop.of(context).fling(),
),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ class ContextualControlsUseCase extends UseCase {
"The backdrop's back layer can be used to control the content that is being "
"shown on the front layer.";
codeFile = "lib/use_cases/contextual_controls/contextual_controls.dart";
preview = ContextualControls();
preview = const ContextualControls();
}
}
Loading