Skip to content

Commit

Permalink
Remove New Keyword
Browse files Browse the repository at this point in the history
*Remove unnecessary "new" keyword in Dart 2.0.
  • Loading branch information
rayliverified committed Nov 2, 2019
1 parent fe2a7ed commit 05c3ccf
Show file tree
Hide file tree
Showing 18 changed files with 262 additions and 271 deletions.
14 changes: 7 additions & 7 deletions lib/component/item_description.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@ class DescriptionText extends StatelessWidget {
var theme = Theme.of(context);
var textTheme = Theme.of(context).textTheme;

return new Column(
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
new Text(
Text(
'Summary',
style: textTheme.display1.apply(fontSizeDelta: 2.0),
),
new Padding(
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: new Text(
child: Text(
text,
style: textTheme.body1,
),
),
// No expand-collapse in this tutorial, we just slap the "more"
// button below the text like in the mockup.
new Row(
Row(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
new Text(
Text(
'more',
style: textTheme.display2.copyWith(color: theme.accentColor),
),
new Icon(
Icon(
Icons.keyboard_arrow_down,
size: 18.0,
color: theme.accentColor,
Expand Down
29 changes: 14 additions & 15 deletions lib/component/item_game_container.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import 'package:flutter/material.dart';

import 'package:stream_games/model/game.dart';
import "package:stream_games/ui/item_game_box.dart";
import "package:stream_games/page/page_game_details.dart";
import "package:stream_games/ui/item_game_box.dart";

class GameContainerItem extends StatelessWidget {
GameContainerItem(this.buildContext, this.game);
Expand All @@ -11,28 +10,28 @@ class GameContainerItem extends StatelessWidget {

@override
Widget build(BuildContext context) {
return new Padding(
return Padding(
padding: const EdgeInsets.only(right: 12.0),
child: new InkWell(
child: InkWell(
onTap: () => _goGameDetailsPage(context, game),
child: new Column(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
new Hero(
tag: game.name,
child: new GameBoxItem(context, game, width: 120.0),
Hero(
tag: game.name,
child: GameBoxItem(context, game, width: 120.0),
),
new Padding(padding: const EdgeInsets.only(top: 6.0)),
new ConstrainedBox(
Padding(padding: const EdgeInsets.only(top: 6.0)),
ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 120.0),
child: new Column(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
new Text(game.name,
Text(game.name,
style: Theme.of(context).textTheme.display1,
maxLines: 1,
overflow: TextOverflow.ellipsis),
new Text(game.getPlatforms(),
Text(game.getPlatforms(),
style: Theme.of(context).textTheme.caption,
maxLines: 1,
overflow: TextOverflow.fade),
Expand All @@ -46,9 +45,9 @@ class GameContainerItem extends StatelessWidget {

void _goGameDetailsPage(BuildContext context, Game game) {
Navigator.of(context).push(
new MaterialPageRoute(
MaterialPageRoute(
builder: (c) {
return new GameDetailsPage(game);
return GameDetailsPage(game);
},
),
);
Expand Down
86 changes: 40 additions & 46 deletions lib/component/item_header_game.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:flutter/material.dart';

import 'package:stream_games/icons.dart';
import 'package:stream_games/model/game.dart';
import 'package:stream_games/ui/item_game_box.dart';
Expand All @@ -13,106 +12,101 @@ class GameDetailHeader extends StatelessWidget {

@override
Widget build(BuildContext context) {
return new Stack(
return Stack(
children: <Widget>[
new Padding(
Padding(
padding: const EdgeInsets.only(bottom: 150.0),
child: _buildDiagonalImageBackground(context),
),
new Positioned(
Positioned(
top: 26.0,
left: 4.0,
child: new BackButton(color: Colors.white),
child: BackButton(color: Colors.white),
),
new Positioned(
Positioned(
bottom: 0.0,
left: 16.0,
right: 16.0,
child: new Row(
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.end,
children: [
new Hero(
Hero(
tag: game.name,
child: new GameBoxItem(
child: GameBoxItem(
context,
game,
width: 150.0,
)
),
new Expanded(
child: new Padding(
)),
Expanded(
child: Padding(
padding: const EdgeInsets.only(left: 16.0),
child: new Column(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
new Text(
Text(
game.name,
style: Theme.of(context).textTheme.subhead,
maxLines: 3,
overflow: TextOverflow.fade,
),
new Padding(
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: new RatingInformation(game),
child: RatingInformation(game),
),
new Padding(
Padding(
padding: const EdgeInsets.only(top: 12.0),
child: new Row(
child: Row(
children: [
new OutlineButton(
OutlineButton(
onPressed: () => {},
child: new Row(
child: Row(
children: <Widget>[
new Icon(
Icon(
playOutlineIcon,
color: Theme
.of(context)
color: Theme.of(context)
.textTheme
.display2
.color,
),
new Text("Trailer",
Text("Trailer",
style:
Theme.of(context).textTheme.display2),
Theme.of(context).textTheme.display2),
],
),
padding: const EdgeInsets.fromLTRB(
6.0, 0.0, 12.0, 0.0),
shape: new RoundedRectangleBorder(
borderRadius:
new BorderRadius.circular(30.0)),
borderSide: new BorderSide(
color: Colors.black54, width: 2.0),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30.0)),
borderSide:
BorderSide(color: Colors.black54, width: 2.0),
highlightColor: Colors.white70,
splashColor: Colors.black12,
highlightElevation: 0.0,
),
new Padding(padding: EdgeInsets.only(left: 8.0)),
new OutlineButton(
Padding(padding: EdgeInsets.only(left: 8.0)),
OutlineButton(
onPressed: () => {},
child: new Row(
child: Row(
children: <Widget>[
new Icon(
Icon(
plusIcon,
color: Theme
.of(context)
color: Theme.of(context)
.textTheme
.display2
.color,
),
new Text("Wishlist",
Text("Wishlist",
style:
Theme.of(context).textTheme.display2),
Theme.of(context).textTheme.display2),
],
),
padding: const EdgeInsets.fromLTRB(
6.0, 0.0, 12.0, 0.0),
shape: new RoundedRectangleBorder(
borderRadius:
new BorderRadius.circular(30.0)),
borderSide: new BorderSide(
color: Colors.black54, width: 2.0),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30.0)),
borderSide:
BorderSide(color: Colors.black54, width: 2.0),
highlightColor: Colors.white70,
splashColor: Colors.black12,
highlightElevation: 0.0,
Expand All @@ -134,8 +128,8 @@ class GameDetailHeader extends StatelessWidget {
Widget _buildDiagonalImageBackground(BuildContext context) {
var screenWidth = MediaQuery.of(context).size.width;

return new DiagonallyCutColoredImage(
new FadeInImage.assetNetwork(
return DiagonallyCutColoredImage(
FadeInImage.assetNetwork(
image: game.cover,
placeholder: "assets/placeholder_cover.jpg",
width: screenWidth,
Expand Down
14 changes: 7 additions & 7 deletions lib/component/item_screenshot_container.dart
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import 'package:flutter/material.dart';

import 'package:stream_games/ui/item_image_height.dart';

class ScreenshotContainerItem extends StatelessWidget {
ScreenshotContainerItem(this.buildContext, this.screenshot, {this.height = 400.0});
ScreenshotContainerItem(this.buildContext, this.screenshot,
{this.height = 400.0});
final BuildContext buildContext;
final String screenshot;
final double height;

@override
Widget build(BuildContext context) {
return new Padding(
return Padding(
padding: const EdgeInsets.only(right: 12.0),
child: new InkWell(
child: InkWell(
onTap: () => {},
child: new Column(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
new ImageHeightItem(context, screenshot, height),
ImageHeightItem(context, screenshot, height),
],
),
),
);
}
}
}
5 changes: 2 additions & 3 deletions lib/controller/scroll_horizontal_game.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:flutter/material.dart';

import 'package:stream_games/component/item_game_container.dart';
import 'package:stream_games/model/game.dart';

Expand All @@ -9,9 +8,9 @@ class HorizontalGameController extends StatelessWidget {

@override
Widget build(BuildContext context) {
return new SizedBox.fromSize(
return SizedBox.fromSize(
size: const Size.fromHeight(240.0),
child: new ListView.builder(
child: ListView.builder(
itemCount: gameItems.length,
scrollDirection: Axis.horizontal,
padding: const EdgeInsets.only(left: 12.0, top: 4.0),
Expand Down
8 changes: 4 additions & 4 deletions lib/controller/scroll_horizontal_screenshots.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:flutter/material.dart';

import 'package:stream_games/component/item_screenshot_container.dart';

class HorizontalScreenshotController extends StatelessWidget {
Expand All @@ -10,14 +9,15 @@ class HorizontalScreenshotController extends StatelessWidget {
Widget build(BuildContext context) {
const double height = 240.0;

return new SizedBox.fromSize(
return SizedBox.fromSize(
size: const Size.fromHeight(height),
child: new ListView.builder(
child: ListView.builder(
itemCount: screenshots.length,
scrollDirection: Axis.horizontal,
padding: const EdgeInsets.only(left: 12.0),
itemBuilder: (BuildContext context, int position) {
return ScreenshotContainerItem(context, screenshots[position], height: height - 16.0);
return ScreenshotContainerItem(context, screenshots[position],
height: height - 16.0);
}),
);
}
Expand Down
7 changes: 3 additions & 4 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import 'package:flutter/material.dart';

import 'package:stream_games/page/page_main.dart';
import 'package:stream_games/themes.dart';

void main() => runApp(new FlutterGames());
void main() => runApp(FlutterGames());

class FlutterGames extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
return MaterialApp(
title: 'Flutter Games',
theme: defaultTheme,
home: new MainPage(),
home: MainPage(),
debugShowCheckedModeBanner: false,
);
}
Expand Down
Loading

0 comments on commit 05c3ccf

Please sign in to comment.