Skip to content

Adopting pkg:flutter_lints for 101-starter branch #251

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

Merged
merged 1 commit into from
Aug 24, 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
1 change: 1 addition & 0 deletions mdc_100_series/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
.pub-cache/
.pub/
/build/
pubspec.lock

# Web related
lib/generated_plugin_registrant.dart
Expand Down
1 change: 1 addition & 0 deletions mdc_100_series/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include: package:flutter_lints/flutter.yaml
7 changes: 4 additions & 3 deletions mdc_100_series/lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ import 'login.dart';

// TODO: Convert ShrineApp to stateful widget (104)
class ShrineApp extends StatelessWidget {

const ShrineApp({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Shrine',
// TODO: Change home: to a Backdrop with a HomePage frontLayer (104)
home: HomePage(),
home: const HomePage(),
// TODO: Make currentCategory field take _currentCategory (104)
// TODO: Pass _currentCategory for frontLayer (104)
// TODO: Change backLayer field value to CategoryMenuPage (104)
Expand All @@ -42,7 +43,7 @@ class ShrineApp extends StatelessWidget {

return MaterialPageRoute<void>(
settings: settings,
builder: (BuildContext context) => LoginPage(),
builder: (BuildContext context) => const LoginPage(),
fullscreenDialog: true,
);
}
Expand Down
4 changes: 3 additions & 1 deletion mdc_100_series/lib/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
import 'package:flutter/material.dart';

class HomePage extends StatelessWidget {
const HomePage({Key? key}) : super(key: key);

// TODO: Make a collection of cards (102)
// TODO: Add a variable for Category (104)
@override
Widget build(BuildContext context) {
// TODO: Return an AsymmetricView (104)
// TODO: Pass Category variable to AsymmetricView (104)
return Scaffold(
return const Scaffold(
// TODO: Add app bar (102)
// TODO: Add a grid view (102)
body: Center(
Expand Down
12 changes: 7 additions & 5 deletions mdc_100_series/lib/login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import 'package:flutter/material.dart';

class LoginPage extends StatefulWidget {
const LoginPage({Key? key}) : super(key: key);

@override
_LoginPageState createState() => _LoginPageState();
}
Expand All @@ -26,17 +28,17 @@ class _LoginPageState extends State<LoginPage> {
return Scaffold(
body: SafeArea(
child: ListView(
padding: EdgeInsets.symmetric(horizontal: 24.0),
padding: const EdgeInsets.symmetric(horizontal: 24.0),
children: <Widget>[
SizedBox(height: 80.0),
const SizedBox(height: 80.0),
Column(
children: <Widget>[
Image.asset('assets/diamond.png'),
SizedBox(height: 16.0),
Text('SHRINE'),
const SizedBox(height: 16.0),
const Text('SHRINE'),
],
),
SizedBox(height: 120.0),
const SizedBox(height: 120.0),
// TODO: Wrap Username with AccentColorOverride (103)
// TODO: Remove filled: true values (103)
// TODO: Wrap Password with AccentColorOverride (103)
Expand Down
4 changes: 2 additions & 2 deletions mdc_100_series/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@

import 'package:flutter/material.dart';

import 'package:Shrine/app.dart';
import 'app.dart';

void main() => runApp(ShrineApp());
void main() => runApp(const ShrineApp());
10 changes: 5 additions & 5 deletions mdc_100_series/lib/supplemental/asymmetric_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import 'product_columns.dart';
class AsymmetricView extends StatelessWidget {
final List<Product> products;

AsymmetricView({Key? key, required this.products});
const AsymmetricView({Key? key, required this.products}) : super(key: key);

List<Container> _buildColumns(BuildContext context) {
List<Widget> _buildColumns(BuildContext context) {
if (products.isEmpty) {
return <Container>[];
}
Expand Down Expand Up @@ -53,10 +53,10 @@ class AsymmetricView extends StatelessWidget {
product: products[_oddCasesIndex(index)],
);
}
return Container(
return SizedBox(
width: width,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 16.0),
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: column,
),
);
Expand Down Expand Up @@ -88,7 +88,7 @@ class AsymmetricView extends StatelessWidget {
Widget build(BuildContext context) {
return ListView(
scrollDirection: Axis.horizontal,
padding: EdgeInsets.fromLTRB(0.0, 34.0, 16.0, 44.0),
padding: const EdgeInsets.fromLTRB(0.0, 34.0, 16.0, 44.0),
children: _buildColumns(context),
);
}
Expand Down
4 changes: 2 additions & 2 deletions mdc_100_series/lib/supplemental/cut_corners_border.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ class CutCornersBorder extends OutlineInputBorder {
Canvas canvas,
Rect rect, {
double? gapStart,
double gapExtent: 0.0,
double gapPercentage: 0.0,
double gapExtent = 0.0,
double gapPercentage = 0.0,
TextDirection? textDirection,
}) {
assert(gapPercentage >= 0.0 && gapPercentage <= 1.0);
Expand Down
10 changes: 6 additions & 4 deletions mdc_100_series/lib/supplemental/product_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ import 'package:intl/intl.dart';
import '../model/product.dart';

class ProductCard extends StatelessWidget {
ProductCard({this.imageAspectRatio = 33 / 49, required this.product})
: assert(imageAspectRatio > 0);
const ProductCard(
{this.imageAspectRatio = 33 / 49, required this.product, Key? key})
: assert(imageAspectRatio > 0),
super(key: key);

final double imageAspectRatio;
final Product product;

static final kTextBoxHeight = 65.0;
static const kTextBoxHeight = 65.0;

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -60,7 +62,7 @@ class ProductCard extends StatelessWidget {
overflow: TextOverflow.ellipsis,
maxLines: 1,
),
SizedBox(height: 4.0),
const SizedBox(height: 4.0),
Text(
formatter.format(product.price),
style: theme.textTheme.subtitle2,
Expand Down
16 changes: 9 additions & 7 deletions mdc_100_series/lib/supplemental/product_columns.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ import '../model/product.dart';
import 'product_card.dart';

class TwoProductCardColumn extends StatelessWidget {
TwoProductCardColumn({
const TwoProductCardColumn({
required this.bottom,
this.top,
});
Key? key,
}) : super(key: key);

final Product bottom;
final Product? top;
Expand All @@ -43,7 +44,7 @@ class TwoProductCardColumn extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Padding(
padding: EdgeInsetsDirectional.only(start: 28.0),
padding: const EdgeInsetsDirectional.only(start: 28.0),
child: top != null
? ProductCard(
imageAspectRatio: imageAspectRatio,
Expand All @@ -53,9 +54,9 @@ class TwoProductCardColumn extends StatelessWidget {
height: heightOfCards,
),
),
SizedBox(height: spacerHeight),
const SizedBox(height: spacerHeight),
Padding(
padding: EdgeInsetsDirectional.only(end: 28.0),
padding: const EdgeInsetsDirectional.only(end: 28.0),
child: ProductCard(
imageAspectRatio: imageAspectRatio,
product: bottom,
Expand All @@ -68,7 +69,8 @@ class TwoProductCardColumn extends StatelessWidget {
}

class OneProductCardColumn extends StatelessWidget {
OneProductCardColumn({required this.product});
const OneProductCardColumn({required this.product, Key? key})
: super(key: key);

final Product product;

Expand All @@ -81,7 +83,7 @@ class OneProductCardColumn extends StatelessWidget {
ProductCard(
product: product,
),
SizedBox(
const SizedBox(
height: 40.0,
),
],
Expand Down
3 changes: 2 additions & 1 deletion mdc_100_series/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Shrine
name: shrine
description: Learn the basics of using Material Components by building a simple app with core components.

environment:
Expand All @@ -15,6 +15,7 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^1.0.0

flutter:
# TODO: Insert Fonts (103)
Expand Down