Skip to content

Commit 757f751

Browse files
johnsonmhpennzht
andauthored
Merge NNBD branch into 104 complete (#235)
* Migrate 104-complete to NNBD. (#211) Migrate 104-complete to NNBD. (#211) * Update pubspec.yaml. (#213) * Migrate 104-complete to NNBD (#218) * Update intl version. * Update SDK version. * Remove `!`. * Remove analysis_options.yaml. Co-authored-by: Tianguang <[email protected]>
1 parent 28b647e commit 757f751

File tree

10 files changed

+68
-80
lines changed

10 files changed

+68
-80
lines changed

mdc_100_series/lib/app.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class _ShrineAppState extends State<ShrineApp> {
5858
}
5959
}
6060

61-
Route<dynamic> _getRoute(RouteSettings settings) {
61+
Route<dynamic>? _getRoute(RouteSettings settings) {
6262
if (settings.name != '/login') {
6363
return null;
6464
}
@@ -107,17 +107,17 @@ ThemeData _buildShrineTheme() {
107107

108108
TextTheme _buildShrineTextTheme(TextTheme base) {
109109
return base.copyWith(
110-
headline5: base.headline5.copyWith(
110+
headline5: base.headline5!.copyWith(
111111
fontWeight: FontWeight.w500,
112112
),
113-
headline6: base.headline6.copyWith(
113+
headline6: base.headline6!.copyWith(
114114
fontSize: 18.0
115115
),
116-
caption: base.caption.copyWith(
116+
caption: base.caption!.copyWith(
117117
fontWeight: FontWeight.w400,
118118
fontSize: 14.0,
119119
),
120-
bodyText1: base.bodyText1.copyWith(
120+
bodyText1: base.bodyText1!.copyWith(
121121
fontWeight: FontWeight.w500,
122122
fontSize: 16.0,
123123
),

mdc_100_series/lib/backdrop.dart

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
// limitations under the License.
1414

1515
import 'package:flutter/material.dart';
16-
import 'package:meta/meta.dart';
1716

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

2322
class _FrontLayer extends StatelessWidget {
2423
const _FrontLayer({
25-
Key key,
24+
Key? key,
2625
this.onTap,
27-
this.child,
26+
required this.child,
2827
}) : super(key: key);
2928

30-
final VoidCallback onTap;
29+
final VoidCallback? onTap;
3130
final Widget child;
3231

3332
@override
@@ -58,26 +57,27 @@ class _FrontLayer extends StatelessWidget {
5857
}
5958

6059
class _BackdropTitle extends AnimatedWidget {
61-
final Function onPress;
60+
final void Function() onPress;
6261
final Widget frontTitle;
6362
final Widget backTitle;
6463

6564
const _BackdropTitle({
66-
Key key,
67-
Listenable listenable,
68-
this.onPress,
69-
@required this.frontTitle,
70-
@required this.backTitle,
71-
}) : assert(frontTitle != null),
72-
assert(backTitle != null),
65+
Key? key,
66+
required Animation<double> listenable,
67+
required this.onPress,
68+
required this.frontTitle,
69+
required this.backTitle,
70+
}) : _listenable = listenable,
7371
super(key: key, listenable: listenable);
7472

73+
final Animation<double> _listenable;
74+
7575
@override
7676
Widget build(BuildContext context) {
77-
final Animation<double> animation = this.listenable;
77+
final Animation<double> animation = _listenable;
7878

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

160160
const Backdrop({
161-
@required this.currentCategory,
162-
@required this.frontLayer,
163-
@required this.backLayer,
164-
@required this.frontTitle,
165-
@required this.backTitle,
166-
}) : assert(currentCategory != null),
167-
assert(frontLayer != null),
168-
assert(backLayer != null),
169-
assert(frontTitle != null),
170-
assert(backTitle != null);
161+
required this.currentCategory,
162+
required this.frontLayer,
163+
required this.backLayer,
164+
required this.frontTitle,
165+
required this.backTitle,
166+
});
171167

172168
@override
173169
_BackdropState createState() => _BackdropState();
@@ -176,7 +172,7 @@ class Backdrop extends StatefulWidget {
176172
class _BackdropState extends State<Backdrop>
177173
with SingleTickerProviderStateMixin {
178174
final GlobalKey _backdropKey = GlobalKey(debugLabel: 'Backdrop');
179-
AnimationController _controller;
175+
late AnimationController _controller;
180176

181177
@override
182178
void initState() {

mdc_100_series/lib/category_menu_page.dart

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
// limitations under the License.
1414

1515
import 'package:flutter/material.dart';
16-
import 'package:meta/meta.dart';
1716

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

2625
const CategoryMenuPage({
27-
Key key,
28-
@required this.currentCategory,
29-
@required this.onCategoryTap,
30-
}) : assert(currentCategory != null),
31-
assert(onCategoryTap != null);
26+
Key? key,
27+
required this.currentCategory,
28+
required this.onCategoryTap,
29+
});
3230

3331
Widget _buildCategory(Category category, BuildContext context) {
3432
final categoryString =
@@ -57,7 +55,7 @@ class CategoryMenuPage extends StatelessWidget {
5755
padding: EdgeInsets.symmetric(vertical: 16.0),
5856
child: Text(
5957
categoryString,
60-
style: theme.textTheme.bodyText1.copyWith(
58+
style: theme.textTheme.bodyText1!.copyWith(
6159
color: kShrineBrown900.withAlpha(153)
6260
),
6361
textAlign: TextAlign.center,

mdc_100_series/lib/login.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class _LoginPageState extends State<LoginPage> {
9696
}
9797

9898
class AccentColorOverride extends StatelessWidget {
99-
const AccentColorOverride({Key key, this.color, this.child})
99+
const AccentColorOverride({Key? key, required this.color, required this.child})
100100
: super(key: key);
101101

102102
final Color color;

mdc_100_series/lib/model/product.dart

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,16 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import 'package:flutter/foundation.dart';
16-
1715
enum Category { all, accessories, clothing, home, }
1816

1917
class Product {
2018
const Product({
21-
@required this.category,
22-
@required this.id,
23-
@required this.isFeatured,
24-
@required this.name,
25-
@required this.price,
26-
}) : assert(category != null),
27-
assert(id != null),
28-
assert(isFeatured != null),
29-
assert(name != null),
30-
assert(price != null);
19+
required this.category,
20+
required this.id,
21+
required this.isFeatured,
22+
required this.name,
23+
required this.price,
24+
});
3125

3226
final Category category;
3327
final int id;

mdc_100_series/lib/supplemental/asymmetric_view.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ import 'product_columns.dart';
2020
class AsymmetricView extends StatelessWidget {
2121
final List<Product> products;
2222

23-
AsymmetricView({Key key, this.products});
23+
AsymmetricView({Key? key, required this.products});
2424

2525
List<Container> _buildColumns(BuildContext context) {
26-
if (products == null || products.isEmpty) {
26+
if (products.isEmpty) {
2727
return <Container>[];
2828
}
2929

mdc_100_series/lib/supplemental/cut_corners_border.dart

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,21 @@ import 'package:flutter/widgets.dart';
1919

2020
class CutCornersBorder extends OutlineInputBorder {
2121
const CutCornersBorder({
22-
BorderSide borderSide: const BorderSide(),
23-
BorderRadius borderRadius: const BorderRadius.all(Radius.circular(2.0)),
24-
this.cut: 7.0,
25-
double gapPadding: 2.0,
22+
BorderSide borderSide = const BorderSide(),
23+
BorderRadius borderRadius = const BorderRadius.all(Radius.circular(2.0)),
24+
this.cut = 7.0,
25+
double gapPadding = 2.0,
2626
}) : super(
2727
borderSide: borderSide,
2828
borderRadius: borderRadius,
2929
gapPadding: gapPadding);
3030

3131
@override
3232
CutCornersBorder copyWith({
33-
BorderSide borderSide,
34-
BorderRadius borderRadius,
35-
double gapPadding,
36-
double cut,
33+
BorderSide? borderSide,
34+
BorderRadius? borderRadius,
35+
double? gapPadding,
36+
double? cut,
3737
}) {
3838
return CutCornersBorder(
3939
borderRadius: borderRadius ?? this.borderRadius,
@@ -46,11 +46,11 @@ class CutCornersBorder extends OutlineInputBorder {
4646
final double cut;
4747

4848
@override
49-
ShapeBorder lerpFrom(ShapeBorder a, double t) {
49+
ShapeBorder? lerpFrom(ShapeBorder? a, double t) {
5050
if (a is CutCornersBorder) {
5151
final CutCornersBorder outline = a;
5252
return CutCornersBorder(
53-
borderRadius: BorderRadius.lerp(outline.borderRadius, borderRadius, t),
53+
borderRadius: BorderRadius.lerp(outline.borderRadius, borderRadius, t)!,
5454
borderSide: BorderSide.lerp(outline.borderSide, borderSide, t),
5555
cut: cut,
5656
gapPadding: outline.gapPadding,
@@ -60,11 +60,11 @@ class CutCornersBorder extends OutlineInputBorder {
6060
}
6161

6262
@override
63-
ShapeBorder lerpTo(ShapeBorder b, double t) {
63+
ShapeBorder? lerpTo(ShapeBorder? b, double t) {
6464
if (b is CutCornersBorder) {
6565
final CutCornersBorder outline = b;
6666
return CutCornersBorder(
67-
borderRadius: BorderRadius.lerp(borderRadius, outline.borderRadius, t),
67+
borderRadius: BorderRadius.lerp(borderRadius, outline.borderRadius, t)!,
6868
borderSide: BorderSide.lerp(borderSide, outline.borderSide, t),
6969
cut: cut,
7070
gapPadding: outline.gapPadding,
@@ -103,12 +103,11 @@ class CutCornersBorder extends OutlineInputBorder {
103103
void paint(
104104
Canvas canvas,
105105
Rect rect, {
106-
double gapStart,
106+
double? gapStart,
107107
double gapExtent: 0.0,
108108
double gapPercentage: 0.0,
109-
TextDirection textDirection,
109+
TextDirection? textDirection,
110110
}) {
111-
assert(gapExtent != null);
112111
assert(gapPercentage >= 0.0 && gapPercentage <= 1.0);
113112

114113
final Paint paint = borderSide.toPaint();
@@ -117,8 +116,8 @@ class CutCornersBorder extends OutlineInputBorder {
117116
canvas.drawPath(_notchedCornerPath(outer.middleRect), paint);
118117
} else {
119118
final double extent =
120-
lerpDouble(0.0, gapExtent + gapPadding * 2.0, gapPercentage);
121-
switch (textDirection) {
119+
lerpDouble(0.0, gapExtent + gapPadding * 2.0, gapPercentage)!;
120+
switch (textDirection!) {
122121
case TextDirection.rtl:
123122
{
124123
final Path path = _notchedCornerPath(

mdc_100_series/lib/supplemental/product_card.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import 'package:intl/intl.dart';
1818
import '../model/product.dart';
1919

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

2424
final double imageAspectRatio;
2525
final Product product;
@@ -54,15 +54,15 @@ class ProductCard extends StatelessWidget {
5454
crossAxisAlignment: CrossAxisAlignment.center,
5555
children: <Widget>[
5656
Text(
57-
product == null ? '' : product.name,
57+
product.name,
5858
style: theme.textTheme.headline6,
5959
softWrap: false,
6060
overflow: TextOverflow.ellipsis,
6161
maxLines: 1,
6262
),
6363
SizedBox(height: 4.0),
6464
Text(
65-
product == null ? '' : formatter.format(product.price),
65+
formatter.format(product.price),
6666
style: theme.textTheme.subtitle2,
6767
),
6868
],

mdc_100_series/lib/supplemental/product_columns.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ import 'product_card.dart';
1919

2020
class TwoProductCardColumn extends StatelessWidget {
2121
TwoProductCardColumn({
22-
this.bottom,
22+
required this.bottom,
2323
this.top,
24-
}) : assert(bottom != null);
24+
});
2525

26-
final Product bottom, top;
26+
final Product bottom;
27+
final Product? top;
2728

2829
@override
2930
Widget build(BuildContext context) {
@@ -45,7 +46,7 @@ class TwoProductCardColumn extends StatelessWidget {
4546
child: top != null
4647
? ProductCard(
4748
imageAspectRatio: imageAspectRatio,
48-
product: top,
49+
product: top!,
4950
)
5051
: SizedBox(
5152
height: heightOfCards > 0 ? heightOfCards : spacerHeight,
@@ -66,7 +67,7 @@ class TwoProductCardColumn extends StatelessWidget {
6667
}
6768

6869
class OneProductCardColumn extends StatelessWidget {
69-
OneProductCardColumn({this.product});
70+
OneProductCardColumn({required this.product});
7071

7172
final Product product;
7273

mdc_100_series/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ name: Shrine
22
description: Take your design up a notch and learn to use our advanced component backdrop menu.
33

44
environment:
5-
sdk: '>=2.10.0 <3.0.0'
5+
sdk: '>=2.12.0-0 <3.0.0'
66

77
dependencies:
88
flutter:
99
sdk: flutter
10-
intl: ^0.15.6
10+
intl: ^0.17.0-nullsafety.2
1111

1212
cupertino_icons: ^0.1.0
1313
shrine_images: 1.1.1

0 commit comments

Comments
 (0)