make @immutable const classes (#9532)
* make @immutable const * fix build
This commit is contained in:
committed by
GitHub
parent
1abb6f5d74
commit
9541848272
@@ -24,7 +24,7 @@ class ComplexLayoutAppState extends State<ComplexLayoutApp> {
|
||||
return new MaterialApp(
|
||||
theme: lightTheme ? new ThemeData.light() : new ThemeData.dark(),
|
||||
title: 'Advanced Layout',
|
||||
home: new ComplexLayout()
|
||||
home: const ComplexLayout()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ class ComplexLayoutAppState extends State<ComplexLayoutApp> {
|
||||
}
|
||||
|
||||
class ComplexLayout extends StatefulWidget {
|
||||
ComplexLayout({ Key key }) : super(key: key);
|
||||
const ComplexLayout({ Key key }) : super(key: key);
|
||||
|
||||
@override
|
||||
ComplexLayoutState createState() => new ComplexLayoutState();
|
||||
@@ -85,7 +85,7 @@ class ComplexLayoutState extends State<ComplexLayout> {
|
||||
new BottomBar(),
|
||||
],
|
||||
),
|
||||
drawer: new GalleryDrawer(),
|
||||
drawer: const GalleryDrawer(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -100,9 +100,9 @@ class TopBarMenu extends StatelessWidget {
|
||||
value: 'Friends',
|
||||
child: new MenuItemWithIcon(Icons.people, 'Friends', '5 new')
|
||||
),
|
||||
new PopupMenuItem<String>(
|
||||
const PopupMenuItem<String>(
|
||||
value: 'Events',
|
||||
child: new MenuItemWithIcon(Icons.event, 'Events', '12 upcoming')
|
||||
child: const MenuItemWithIcon(Icons.event, 'Events', '12 upcoming')
|
||||
),
|
||||
new PopupMenuItem<String>(
|
||||
value: 'Events',
|
||||
@@ -120,9 +120,9 @@ class TopBarMenu extends StatelessWidget {
|
||||
value: 'Friends',
|
||||
child: new MenuItemWithIcon(Icons.people, 'Friends', '5')
|
||||
),
|
||||
new PopupMenuItem<String>(
|
||||
const PopupMenuItem<String>(
|
||||
value: 'Events',
|
||||
child: new MenuItemWithIcon(Icons.event, 'Events', '12')
|
||||
child: const MenuItemWithIcon(Icons.event, 'Events', '12')
|
||||
),
|
||||
new PopupMenuItem<String>(
|
||||
value: 'Events',
|
||||
@@ -142,7 +142,7 @@ class TopBarMenu extends StatelessWidget {
|
||||
}
|
||||
|
||||
class MenuItemWithIcon extends StatelessWidget {
|
||||
MenuItemWithIcon(this.icon, this.title, this.subtitle);
|
||||
const MenuItemWithIcon(this.icon, this.title, this.subtitle);
|
||||
|
||||
final IconData icon;
|
||||
final String title;
|
||||
@@ -164,7 +164,7 @@ class MenuItemWithIcon extends StatelessWidget {
|
||||
}
|
||||
|
||||
class FancyImageItem extends StatelessWidget {
|
||||
FancyImageItem(this.index, {Key key}) : super(key: key);
|
||||
const FancyImageItem(this.index, {Key key}) : super(key: key);
|
||||
|
||||
final int index;
|
||||
|
||||
@@ -188,14 +188,14 @@ class FancyImageItem extends StatelessWidget {
|
||||
}
|
||||
|
||||
class FancyGalleryItem extends StatelessWidget {
|
||||
FancyGalleryItem(this.index, {Key key}) : super(key: key);
|
||||
const FancyGalleryItem(this.index, {Key key}) : super(key: key);
|
||||
|
||||
final int index;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new ListBody(
|
||||
children: <Widget>[
|
||||
new UserHeader('Ali Connors'),
|
||||
const UserHeader('Ali Connors'),
|
||||
new ItemGalleryBox(index),
|
||||
new InfoBar(),
|
||||
new Padding(
|
||||
@@ -217,7 +217,7 @@ class InfoBar extends StatelessWidget {
|
||||
child: new Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
new MiniIconWithText(Icons.thumb_up, '42'),
|
||||
const MiniIconWithText(Icons.thumb_up, '42'),
|
||||
new Text('3 Comments', style: Theme.of(context).textTheme.caption)
|
||||
]
|
||||
)
|
||||
@@ -233,9 +233,9 @@ class IconBar extends StatelessWidget {
|
||||
child: new Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
new IconWithText(Icons.thumb_up, 'Like'),
|
||||
const IconWithText(Icons.thumb_up, 'Like'),
|
||||
new IconWithText(Icons.comment, 'Comment'),
|
||||
new IconWithText(Icons.share, 'Share'),
|
||||
const IconWithText(Icons.share, 'Share'),
|
||||
]
|
||||
)
|
||||
);
|
||||
@@ -243,7 +243,7 @@ class IconBar extends StatelessWidget {
|
||||
}
|
||||
|
||||
class IconWithText extends StatelessWidget {
|
||||
IconWithText(this.icon, this.title);
|
||||
const IconWithText(this.icon, this.title);
|
||||
|
||||
final IconData icon;
|
||||
final String title;
|
||||
@@ -264,7 +264,7 @@ class IconWithText extends StatelessWidget {
|
||||
}
|
||||
|
||||
class MiniIconWithText extends StatelessWidget {
|
||||
MiniIconWithText(this.icon, this.title);
|
||||
const MiniIconWithText(this.icon, this.title);
|
||||
|
||||
final IconData icon;
|
||||
final String title;
|
||||
@@ -305,7 +305,7 @@ class FatDivider extends StatelessWidget {
|
||||
}
|
||||
|
||||
class UserHeader extends StatelessWidget {
|
||||
UserHeader(this.userName);
|
||||
const UserHeader(this.userName);
|
||||
|
||||
final String userName;
|
||||
|
||||
@@ -443,7 +443,7 @@ class ItemImageBox extends StatelessWidget {
|
||||
}
|
||||
|
||||
class ItemGalleryBox extends StatelessWidget {
|
||||
ItemGalleryBox(this.index);
|
||||
const ItemGalleryBox(this.index);
|
||||
|
||||
final int index;
|
||||
|
||||
@@ -506,7 +506,7 @@ class ItemGalleryBox extends StatelessWidget {
|
||||
)
|
||||
),
|
||||
new Container(
|
||||
child: new TabPageSelector()
|
||||
child: const TabPageSelector()
|
||||
)
|
||||
]
|
||||
)
|
||||
@@ -542,7 +542,7 @@ class BottomBar extends StatelessWidget {
|
||||
}
|
||||
|
||||
class BottomBarButton extends StatelessWidget {
|
||||
BottomBarButton(this.icon, this.title);
|
||||
const BottomBarButton(this.icon, this.title);
|
||||
|
||||
final IconData icon;
|
||||
final String title;
|
||||
@@ -565,7 +565,7 @@ class BottomBarButton extends StatelessWidget {
|
||||
}
|
||||
|
||||
class GalleryDrawer extends StatelessWidget {
|
||||
GalleryDrawer({ Key key }) : super(key: key);
|
||||
const GalleryDrawer({ Key key }) : super(key: key);
|
||||
|
||||
void _changeTheme(BuildContext context, bool value) {
|
||||
ComplexLayoutApp.of(context).lightTheme = value;
|
||||
|
||||
@@ -74,7 +74,7 @@ class DotState extends State<Dot> {
|
||||
}
|
||||
|
||||
class ExampleDragSource extends StatelessWidget {
|
||||
ExampleDragSource({
|
||||
const ExampleDragSource({
|
||||
Key key,
|
||||
this.color,
|
||||
this.heavy: false,
|
||||
@@ -174,7 +174,7 @@ class DashOutlineCirclePainter extends CustomPainter {
|
||||
}
|
||||
|
||||
class MovableBall extends StatelessWidget {
|
||||
MovableBall(this.position, this.ballPosition, this.callback);
|
||||
const MovableBall(this.position, this.ballPosition, this.callback);
|
||||
|
||||
final int position;
|
||||
final int ballPosition;
|
||||
|
||||
@@ -103,7 +103,7 @@ class _PointDemoPainter extends CustomPainter {
|
||||
}
|
||||
|
||||
class _PointDemo extends StatefulWidget {
|
||||
_PointDemo({ Key key, this.controller }) : super(key: key);
|
||||
const _PointDemo({ Key key, this.controller }) : super(key: key);
|
||||
|
||||
final AnimationController controller;
|
||||
|
||||
@@ -268,7 +268,7 @@ class _RectangleDemoPainter extends CustomPainter {
|
||||
}
|
||||
|
||||
class _RectangleDemo extends StatefulWidget {
|
||||
_RectangleDemo({ Key key, this.controller }) : super(key: key);
|
||||
const _RectangleDemo({ Key key, this.controller }) : super(key: key);
|
||||
|
||||
final AnimationController controller;
|
||||
|
||||
@@ -404,7 +404,7 @@ class _ArcDemo {
|
||||
}
|
||||
|
||||
class AnimationDemo extends StatefulWidget {
|
||||
AnimationDemo({ Key key }) : super(key: key);
|
||||
const AnimationDemo({ Key key }) : super(key: key);
|
||||
|
||||
@override
|
||||
_AnimationDemoState createState() => new _AnimationDemoState();
|
||||
@@ -469,6 +469,6 @@ class _AnimationDemoState extends State<AnimationDemo> with TickerProviderStateM
|
||||
|
||||
void main() {
|
||||
runApp(new MaterialApp(
|
||||
home: new AnimationDemo()
|
||||
home: const AnimationDemo()
|
||||
));
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ class _MarkerPainter extends CustomPainter {
|
||||
}
|
||||
|
||||
class Marker extends StatelessWidget {
|
||||
Marker({
|
||||
const Marker({
|
||||
Key key,
|
||||
this.type: MarkerType.touch,
|
||||
this.position,
|
||||
|
||||
@@ -12,15 +12,15 @@ void main() {
|
||||
appBar: new AppBar(
|
||||
title: const Text('Hardware Key Demo'),
|
||||
),
|
||||
body: new Center(
|
||||
child: new RawKeyboardDemo(),
|
||||
body: const Center(
|
||||
child: const RawKeyboardDemo(),
|
||||
),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
class RawKeyboardDemo extends StatefulWidget {
|
||||
RawKeyboardDemo({ Key key }) : super(key: key);
|
||||
const RawKeyboardDemo({ Key key }) : super(key: key);
|
||||
|
||||
@override
|
||||
_HardwareKeyDemoState createState() => new _HardwareKeyDemoState();
|
||||
|
||||
Reference in New Issue
Block a user