Skip to content

Merge NNBD branch into 104 complete #235

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 4 commits into from
May 12, 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
10 changes: 5 additions & 5 deletions mdc_100_series/lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class _ShrineAppState extends State<ShrineApp> {
}
}

Route<dynamic> _getRoute(RouteSettings settings) {
Route<dynamic>? _getRoute(RouteSettings settings) {
if (settings.name != '/login') {
return null;
}
Expand Down Expand Up @@ -107,17 +107,17 @@ ThemeData _buildShrineTheme() {

TextTheme _buildShrineTextTheme(TextTheme base) {
return base.copyWith(
headline5: base.headline5.copyWith(
headline5: base.headline5!.copyWith(
fontWeight: FontWeight.w500,
),
headline6: base.headline6.copyWith(
headline6: base.headline6!.copyWith(
fontSize: 18.0
),
caption: base.caption.copyWith(
caption: base.caption!.copyWith(
fontWeight: FontWeight.w400,
fontSize: 14.0,
),
bodyText1: base.bodyText1.copyWith(
bodyText1: base.bodyText1!.copyWith(
fontWeight: FontWeight.w500,
fontSize: 16.0,
),
Expand Down
46 changes: 21 additions & 25 deletions mdc_100_series/lib/backdrop.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// limitations under the License.

import 'package:flutter/material.dart';
import 'package:meta/meta.dart';

import 'model/product.dart';
import 'login.dart';
Expand All @@ -22,12 +21,12 @@ const double _kFlingVelocity = 2.0;

class _FrontLayer extends StatelessWidget {
const _FrontLayer({
Key key,
Key? key,
this.onTap,
this.child,
required this.child,
}) : super(key: key);

final VoidCallback onTap;
final VoidCallback? onTap;
final Widget child;

@override
Expand Down Expand Up @@ -58,26 +57,27 @@ class _FrontLayer extends StatelessWidget {
}

class _BackdropTitle extends AnimatedWidget {
final Function onPress;
final void Function() onPress;
final Widget frontTitle;
final Widget backTitle;

const _BackdropTitle({
Key key,
Listenable listenable,
this.onPress,
@required this.frontTitle,
@required this.backTitle,
}) : assert(frontTitle != null),
assert(backTitle != null),
Key? key,
required Animation<double> listenable,
required this.onPress,
required this.frontTitle,
required this.backTitle,
}) : _listenable = listenable,
super(key: key, listenable: listenable);

final Animation<double> _listenable;

@override
Widget build(BuildContext context) {
final Animation<double> animation = this.listenable;
final Animation<double> animation = _listenable;

return DefaultTextStyle(
style: Theme.of(context).primaryTextTheme.headline6,
style: Theme.of(context).primaryTextTheme.headline6!,
softWrap: false,
overflow: TextOverflow.ellipsis,
child: Row(children: <Widget>[
Expand Down Expand Up @@ -158,16 +158,12 @@ class Backdrop extends StatefulWidget {
final Widget backTitle;

const Backdrop({
@required this.currentCategory,
@required this.frontLayer,
@required this.backLayer,
@required this.frontTitle,
@required this.backTitle,
}) : assert(currentCategory != null),
assert(frontLayer != null),
assert(backLayer != null),
assert(frontTitle != null),
assert(backTitle != null);
required this.currentCategory,
required this.frontLayer,
required this.backLayer,
required this.frontTitle,
required this.backTitle,
});

@override
_BackdropState createState() => _BackdropState();
Expand All @@ -176,7 +172,7 @@ class Backdrop extends StatefulWidget {
class _BackdropState extends State<Backdrop>
with SingleTickerProviderStateMixin {
final GlobalKey _backdropKey = GlobalKey(debugLabel: 'Backdrop');
AnimationController _controller;
late AnimationController _controller;

@override
void initState() {
Expand Down
12 changes: 5 additions & 7 deletions mdc_100_series/lib/category_menu_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// limitations under the License.

import 'package:flutter/material.dart';
import 'package:meta/meta.dart';

import 'colors.dart';
import 'model/product.dart';
Expand All @@ -24,11 +23,10 @@ class CategoryMenuPage extends StatelessWidget {
final List<Category> _categories = Category.values;

const CategoryMenuPage({
Key key,
@required this.currentCategory,
@required this.onCategoryTap,
}) : assert(currentCategory != null),
assert(onCategoryTap != null);
Key? key,
required this.currentCategory,
required this.onCategoryTap,
});

Widget _buildCategory(Category category, BuildContext context) {
final categoryString =
Expand Down Expand Up @@ -57,7 +55,7 @@ class CategoryMenuPage extends StatelessWidget {
padding: EdgeInsets.symmetric(vertical: 16.0),
child: Text(
categoryString,
style: theme.textTheme.bodyText1.copyWith(
style: theme.textTheme.bodyText1!.copyWith(
color: kShrineBrown900.withAlpha(153)
),
textAlign: TextAlign.center,
Expand Down
2 changes: 1 addition & 1 deletion mdc_100_series/lib/login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class _LoginPageState extends State<LoginPage> {
}

class AccentColorOverride extends StatelessWidget {
const AccentColorOverride({Key key, this.color, this.child})
const AccentColorOverride({Key? key, required this.color, required this.child})
: super(key: key);

final Color color;
Expand Down
18 changes: 6 additions & 12 deletions mdc_100_series/lib/model/product.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,16 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import 'package:flutter/foundation.dart';

enum Category { all, accessories, clothing, home, }

class Product {
const Product({
@required this.category,
@required this.id,
@required this.isFeatured,
@required this.name,
@required this.price,
}) : assert(category != null),
assert(id != null),
assert(isFeatured != null),
assert(name != null),
assert(price != null);
required this.category,
required this.id,
required this.isFeatured,
required this.name,
required this.price,
});

final Category category;
final int id;
Expand Down
4 changes: 2 additions & 2 deletions mdc_100_series/lib/supplemental/asymmetric_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import 'product_columns.dart';
class AsymmetricView extends StatelessWidget {
final List<Product> products;

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

List<Container> _buildColumns(BuildContext context) {
if (products == null || products.isEmpty) {
if (products.isEmpty) {
return <Container>[];
}

Expand Down
33 changes: 16 additions & 17 deletions mdc_100_series/lib/supplemental/cut_corners_border.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ import 'package:flutter/widgets.dart';

class CutCornersBorder extends OutlineInputBorder {
const CutCornersBorder({
BorderSide borderSide: const BorderSide(),
BorderRadius borderRadius: const BorderRadius.all(Radius.circular(2.0)),
this.cut: 7.0,
double gapPadding: 2.0,
BorderSide borderSide = const BorderSide(),
BorderRadius borderRadius = const BorderRadius.all(Radius.circular(2.0)),
this.cut = 7.0,
double gapPadding = 2.0,
}) : super(
borderSide: borderSide,
borderRadius: borderRadius,
gapPadding: gapPadding);

@override
CutCornersBorder copyWith({
BorderSide borderSide,
BorderRadius borderRadius,
double gapPadding,
double cut,
BorderSide? borderSide,
BorderRadius? borderRadius,
double? gapPadding,
double? cut,
}) {
return CutCornersBorder(
borderRadius: borderRadius ?? this.borderRadius,
Expand All @@ -46,11 +46,11 @@ class CutCornersBorder extends OutlineInputBorder {
final double cut;

@override
ShapeBorder lerpFrom(ShapeBorder a, double t) {
ShapeBorder? lerpFrom(ShapeBorder? a, double t) {
if (a is CutCornersBorder) {
final CutCornersBorder outline = a;
return CutCornersBorder(
borderRadius: BorderRadius.lerp(outline.borderRadius, borderRadius, t),
borderRadius: BorderRadius.lerp(outline.borderRadius, borderRadius, t)!,
borderSide: BorderSide.lerp(outline.borderSide, borderSide, t),
cut: cut,
gapPadding: outline.gapPadding,
Expand All @@ -60,11 +60,11 @@ class CutCornersBorder extends OutlineInputBorder {
}

@override
ShapeBorder lerpTo(ShapeBorder b, double t) {
ShapeBorder? lerpTo(ShapeBorder? b, double t) {
if (b is CutCornersBorder) {
final CutCornersBorder outline = b;
return CutCornersBorder(
borderRadius: BorderRadius.lerp(borderRadius, outline.borderRadius, t),
borderRadius: BorderRadius.lerp(borderRadius, outline.borderRadius, t)!,
borderSide: BorderSide.lerp(borderSide, outline.borderSide, t),
cut: cut,
gapPadding: outline.gapPadding,
Expand Down Expand Up @@ -103,12 +103,11 @@ class CutCornersBorder extends OutlineInputBorder {
void paint(
Canvas canvas,
Rect rect, {
double gapStart,
double? gapStart,
double gapExtent: 0.0,
double gapPercentage: 0.0,
TextDirection textDirection,
TextDirection? textDirection,
}) {
assert(gapExtent != null);
assert(gapPercentage >= 0.0 && gapPercentage <= 1.0);

final Paint paint = borderSide.toPaint();
Expand All @@ -117,8 +116,8 @@ class CutCornersBorder extends OutlineInputBorder {
canvas.drawPath(_notchedCornerPath(outer.middleRect), paint);
} else {
final double extent =
lerpDouble(0.0, gapExtent + gapPadding * 2.0, gapPercentage);
switch (textDirection) {
lerpDouble(0.0, gapExtent + gapPadding * 2.0, gapPercentage)!;
switch (textDirection!) {
case TextDirection.rtl:
{
final Path path = _notchedCornerPath(
Expand Down
8 changes: 4 additions & 4 deletions mdc_100_series/lib/supplemental/product_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import 'package:intl/intl.dart';
import '../model/product.dart';

class ProductCard extends StatelessWidget {
ProductCard({this.imageAspectRatio: 33 / 49, this.product})
: assert(imageAspectRatio == null || imageAspectRatio > 0);
ProductCard({this.imageAspectRatio = 33 / 49, required this.product})
: assert(imageAspectRatio > 0);

final double imageAspectRatio;
final Product product;
Expand Down Expand Up @@ -54,15 +54,15 @@ class ProductCard extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text(
product == null ? '' : product.name,
product.name,
style: theme.textTheme.headline6,
softWrap: false,
overflow: TextOverflow.ellipsis,
maxLines: 1,
),
SizedBox(height: 4.0),
Text(
product == null ? '' : formatter.format(product.price),
formatter.format(product.price),
style: theme.textTheme.subtitle2,
),
],
Expand Down
11 changes: 6 additions & 5 deletions mdc_100_series/lib/supplemental/product_columns.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ import 'product_card.dart';

class TwoProductCardColumn extends StatelessWidget {
TwoProductCardColumn({
this.bottom,
required this.bottom,
this.top,
}) : assert(bottom != null);
});

final Product bottom, top;
final Product bottom;
final Product? top;

@override
Widget build(BuildContext context) {
Expand All @@ -45,7 +46,7 @@ class TwoProductCardColumn extends StatelessWidget {
child: top != null
? ProductCard(
imageAspectRatio: imageAspectRatio,
product: top,
product: top!,
)
: SizedBox(
height: heightOfCards > 0 ? heightOfCards : spacerHeight,
Expand All @@ -66,7 +67,7 @@ class TwoProductCardColumn extends StatelessWidget {
}

class OneProductCardColumn extends StatelessWidget {
OneProductCardColumn({this.product});
OneProductCardColumn({required this.product});

final Product product;

Expand Down
4 changes: 2 additions & 2 deletions mdc_100_series/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ name: Shrine
description: Take your design up a notch and learn to use our advanced component backdrop menu.

environment:
sdk: '>=2.10.0 <3.0.0'
sdk: '>=2.12.0-0 <3.0.0'

dependencies:
flutter:
sdk: flutter
intl: ^0.15.6
intl: ^0.17.0-nullsafety.2

cupertino_icons: ^0.1.0
shrine_images: 1.1.1
Expand Down