Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
3e21c070
Commit
3e21c070
authored
Sep 12, 2017
by
gspencergoog
Committed by
GitHub
Sep 12, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding a default title for Title widget (#12015)
Adds a default title to the Title widget, fixes #6802.
parent
ecb56927
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
9 deletions
+68
-9
app.dart
packages/flutter/lib/src/material/app.dart
+3
-2
app.dart
packages/flutter/lib/src/widgets/app.dart
+3
-2
title.dart
packages/flutter/lib/src/widgets/title.dart
+13
-5
title_test.dart
packages/flutter/test/widgets/title_test.dart
+49
-0
No files found.
packages/flutter/lib/src/material/app.dart
View file @
3e21c070
...
...
@@ -84,7 +84,7 @@ class MaterialApp extends StatefulWidget {
/// The boolean arguments, [routes], and [navigatorObservers], must not be null.
MaterialApp
({
// can't be const because the asserts use methods on Map :-(
Key
key
,
this
.
title
,
this
.
title
:
''
,
this
.
color
,
this
.
theme
,
this
.
home
,
...
...
@@ -103,7 +103,8 @@ class MaterialApp extends StatefulWidget {
this
.
checkerboardOffscreenLayers
:
false
,
this
.
showSemanticsDebugger
:
false
,
this
.
debugShowCheckedModeBanner
:
true
})
:
assert
(
routes
!=
null
),
})
:
assert
(
title
!=
null
),
assert
(
routes
!=
null
),
assert
(
navigatorObservers
!=
null
),
assert
(
debugShowMaterialGrid
!=
null
),
assert
(
showPerformanceOverlay
!=
null
),
...
...
packages/flutter/lib/src/widgets/app.dart
View file @
3e21c070
...
...
@@ -70,7 +70,7 @@ class WidgetsApp extends StatefulWidget {
Key
key
,
@required
this
.
onGenerateRoute
,
this
.
onUnknownRoute
,
this
.
title
,
this
.
title
:
''
,
this
.
textStyle
,
@required
this
.
color
,
this
.
navigatorObservers
:
const
<
NavigatorObserver
>[],
...
...
@@ -86,7 +86,8 @@ class WidgetsApp extends StatefulWidget {
this
.
debugShowWidgetInspector
:
false
,
this
.
debugShowCheckedModeBanner
:
true
,
this
.
inspectorSelectButtonBuilder
,
})
:
assert
(
onGenerateRoute
!=
null
),
})
:
assert
(
title
!=
null
),
assert
(
onGenerateRoute
!=
null
),
assert
(
color
!=
null
),
assert
(
navigatorObservers
!=
null
),
assert
(
supportedLocales
!=
null
&&
supportedLocales
.
isNotEmpty
),
...
...
packages/flutter/lib/src/widgets/title.dart
View file @
3e21c070
...
...
@@ -11,18 +11,26 @@ import 'framework.dart';
/// A widget that describes this app in the operating system.
class
Title
extends
StatelessWidget
{
/// Creates a widget that describes this app to the operating system.
///
/// [title] will default to the empty string if not supplied.
/// [color] must be an opaque color (i.e. color.alpha must be 255 (0xFF)).
/// [color] and [child] are required arguments.
Title
({
Key
key
,
this
.
title
,
this
.
color
,
this
.
title
:
''
,
@required
this
.
color
,
@required
this
.
child
,
})
:
assert
(
color
==
null
||
color
.
alpha
==
0xFF
),
})
:
assert
(
title
!=
null
),
assert
(
color
!=
null
&&
color
.
alpha
==
0xFF
),
super
(
key:
key
);
/// A one-line description of this app for use in the window manager.
/// Must not be null.
final
String
title
;
/// A color that the window manager should use to identify this app.
/// A color that the window manager should use to identify this app. Must be
/// an opaque color (i.e. color.alpha must be 255 (0xFF)), and must not be
/// null.
final
Color
color
;
/// The widget below this widget in the tree.
...
...
@@ -42,7 +50,7 @@ class Title extends StatelessWidget {
@override
void
debugFillProperties
(
DiagnosticPropertiesBuilder
description
)
{
super
.
debugFillProperties
(
description
);
description
.
add
(
new
StringProperty
(
'title'
,
title
,
defaultValue:
null
));
description
.
add
(
new
StringProperty
(
'title'
,
title
,
defaultValue:
''
));
description
.
add
(
new
DiagnosticsProperty
<
Color
>(
'color'
,
color
,
defaultValue:
null
));
}
}
packages/flutter/test/widgets/title_test.dart
View file @
3e21c070
...
...
@@ -4,6 +4,7 @@
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/services.dart'
;
void
main
(
)
{
testWidgets
(
'toString control test'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -14,4 +15,52 @@ void main() {
);
expect
(
widget
.
toString
,
isNot
(
throwsException
));
});
testWidgets
(
'should handle having no title'
,
(
WidgetTester
tester
)
async
{
final
Title
widget
=
new
Title
(
child:
new
Container
(),
color:
const
Color
(
0xFF00FF00
),
);
expect
(
widget
.
toString
,
isNot
(
throwsException
));
expect
(
widget
.
title
,
equals
(
''
));
expect
(
widget
.
color
,
equals
(
const
Color
(
0xFF00FF00
)));
});
testWidgets
(
'should not allow null title or color'
,
(
WidgetTester
tester
)
async
{
expect
(()
=>
new
Title
(
title:
null
,
color:
const
Color
(
0xFF00FF00
),
child:
new
Container
(),
),
throwsAssertionError
);
expect
(()
=>
new
Title
(
color:
null
,
child:
new
Container
(),
),
throwsAssertionError
);
});
testWidgets
(
'should not allow non-opaque color'
,
(
WidgetTester
tester
)
async
{
expect
(()
=>
new
Title
(
color:
const
Color
(
0
),
child:
new
Container
(),
),
throwsAssertionError
);
});
testWidgets
(
'should not pass "null" to setApplicationSwitcherDescription'
,
(
WidgetTester
tester
)
async
{
final
List
<
MethodCall
>
log
=
<
MethodCall
>[];
SystemChannels
.
platform
.
setMockMethodCallHandler
((
MethodCall
methodCall
)
async
{
log
.
add
(
methodCall
);
});
await
tester
.
pumpWidget
(
new
Title
(
child:
new
Container
(),
color:
const
Color
(
0xFF00FF00
),
));
expect
(
log
,
equals
(<
MethodCall
>[
new
MethodCall
(
'SystemChrome.setApplicationSwitcherDescription'
,
<
String
,
dynamic
>{
'label'
:
''
,
'primaryColor'
:
4278255360
},
)]));
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment