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
68ff032f
Commit
68ff032f
authored
Feb 14, 2017
by
Adam Barth
Committed by
GitHub
Feb 14, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove mentions of ScrollableViewport from flutter_markdown (#8132)
Also, actually run the flutter_markdown tests.
parent
fd30f631
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
33 deletions
+40
-33
test.dart
dev/bots/test.dart
+1
-0
markdown.dart
packages/flutter_markdown/lib/src/markdown.dart
+8
-5
markdown_raw.dart
packages/flutter_markdown/lib/src/markdown_raw.dart
+9
-6
flutter_markdown_test.dart
packages/flutter_markdown/test/flutter_markdown_test.dart
+22
-22
No files found.
dev/bots/test.dart
View file @
68ff032f
...
@@ -66,6 +66,7 @@ Future<Null> main() async {
...
@@ -66,6 +66,7 @@ Future<Null> main() async {
);
);
await
_runAllDartTests
(
p
.
join
(
flutterRoot
,
'packages'
,
'flutter_driver'
));
await
_runAllDartTests
(
p
.
join
(
flutterRoot
,
'packages'
,
'flutter_driver'
));
await
_runFlutterTest
(
p
.
join
(
flutterRoot
,
'packages'
,
'flutter_test'
));
await
_runFlutterTest
(
p
.
join
(
flutterRoot
,
'packages'
,
'flutter_test'
));
await
_runFlutterTest
(
p
.
join
(
flutterRoot
,
'packages'
,
'flutter_markdown'
));
await
_runAllDartTests
(
p
.
join
(
flutterRoot
,
'packages'
,
'flutter_tools'
),
await
_runAllDartTests
(
p
.
join
(
flutterRoot
,
'packages'
,
'flutter_tools'
),
environment:
<
String
,
String
>{
'FLUTTER_ROOT'
:
flutterRoot
},
environment:
<
String
,
String
>{
'FLUTTER_ROOT'
:
flutterRoot
},
);
);
...
...
packages/flutter_markdown/lib/src/markdown.dart
View file @
68ff032f
...
@@ -50,11 +50,14 @@ class Markdown extends MarkdownRaw {
...
@@ -50,11 +50,14 @@ class Markdown extends MarkdownRaw {
}
}
}
}
/// A [Widget] that renders markdown formatted text. It supports all standard
/// A [Widget] that renders markdown formatted text.
/// markdowns from the original markdown specification found here:
///
/// https://daringfireball.net/projects/markdown/ This class doesn't implement
/// It supports all standard markdowns from the original markdown specification
/// any scrolling behavior, if you want scrolling either wrap the widget in
/// found here: <https://daringfireball.net/projects/markdown/>
/// a [ScrollableViewport] or use the [Markdown] widget.
///
/// This class doesn't implement any scrolling behavior, if you want scrolling
/// either wrap the widget in a [SingleChildScrollView] or use the [Markdown]
/// widget.
class
MarkdownBody
extends
MarkdownBodyRaw
{
class
MarkdownBody
extends
MarkdownBodyRaw
{
/// Creates a new Markdown [Widget] that renders the markdown formatted string
/// Creates a new Markdown [Widget] that renders the markdown formatted string
...
...
packages/flutter_markdown/lib/src/markdown_raw.dart
View file @
68ff032f
...
@@ -80,11 +80,14 @@ class MarkdownRaw extends StatelessWidget {
...
@@ -80,11 +80,14 @@ class MarkdownRaw extends StatelessWidget {
}
}
}
}
/// A [Widget] that renders markdown formatted text. It supports all standard
/// A [Widget] that renders markdown formatted text.
/// markdowns from the original markdown specification found here:
///
/// https://daringfireball.net/projects/markdown/ This class doesn't implement
/// It supports all standard markdowns from the original markdown specification
/// any scrolling behavior, if you want scrolling either wrap the widget in
/// found here: <https://daringfireball.net/projects/markdown/>.
/// a [ScrollableViewport] or use the [MarkdownRaw] widget.
///
/// This class doesn't implement any scrolling behavior, if you want scrolling
/// either wrap the widget in a [SingleChildScrollView] or use the [MarkdownRaw]
/// widget.
class
MarkdownBodyRaw
extends
StatefulWidget
{
class
MarkdownBodyRaw
extends
StatefulWidget
{
/// Creates a new Markdown [Widget] that renders the markdown formatted string
/// Creates a new Markdown [Widget] that renders the markdown formatted string
...
@@ -93,7 +96,7 @@ class MarkdownBodyRaw extends StatefulWidget {
...
@@ -93,7 +96,7 @@ class MarkdownBodyRaw extends StatefulWidget {
/// highlighting, but it's possible to pass in a custom [syntaxHighlighter].
/// highlighting, but it's possible to pass in a custom [syntaxHighlighter].
///
///
/// Typically, you may want to wrap the [MarkdownBodyRaw] widget in a
/// Typically, you may want to wrap the [MarkdownBodyRaw] widget in a
/// a [S
crollableViewport
], or use the [Markdown class].
/// a [S
ingleChildScrollView
], or use the [Markdown class].
///
///
/// ```dart
/// ```dart
/// new SingleChildScrollView(
/// new SingleChildScrollView(
...
...
packages/flutter_markdown/test/flutter_markdown_test.dart
View file @
68ff032f
...
@@ -9,31 +9,31 @@ import 'package:flutter/widgets.dart';
...
@@ -9,31 +9,31 @@ import 'package:flutter/widgets.dart';
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
void
main
(
)
{
void
main
(
)
{
testWidgets
(
'Simple string'
,
(
WidgetTester
tester
)
{
testWidgets
(
'Simple string'
,
(
WidgetTester
tester
)
async
{
tester
.
pumpWidget
(
new
MarkdownBody
(
data:
'Hello'
));
await
tester
.
pumpWidget
(
new
MarkdownBody
(
data:
'Hello'
));
Iterable
<
Widget
>
widgets
=
tester
.
allWidgets
;
Iterable
<
Widget
>
widgets
=
tester
.
allWidgets
;
_expectWidgetTypes
(
widgets
,
<
Type
>[
MarkdownBody
,
Column
,
Container
,
Padding
,
RichText
]);
_expectWidgetTypes
(
widgets
,
<
Type
>[
MarkdownBody
,
Column
,
Container
,
Padding
,
RichText
]);
_expectTextStrings
(
widgets
,
<
String
>[
'Hello'
]);
_expectTextStrings
(
widgets
,
<
String
>[
'Hello'
]);
});
});
testWidgets
(
'Header'
,
(
WidgetTester
tester
)
{
testWidgets
(
'Header'
,
(
WidgetTester
tester
)
async
{
tester
.
pumpWidget
(
new
MarkdownBody
(
data:
'# Header'
));
await
tester
.
pumpWidget
(
new
MarkdownBody
(
data:
'# Header'
));
Iterable
<
Widget
>
widgets
=
tester
.
allWidgets
;
Iterable
<
Widget
>
widgets
=
tester
.
allWidgets
;
_expectWidgetTypes
(
widgets
,
<
Type
>[
MarkdownBody
,
Column
,
Container
,
Padding
,
RichText
]);
_expectWidgetTypes
(
widgets
,
<
Type
>[
MarkdownBody
,
Column
,
Container
,
Padding
,
RichText
]);
_expectTextStrings
(
widgets
,
<
String
>[
'Header'
]);
_expectTextStrings
(
widgets
,
<
String
>[
'Header'
]);
});
});
testWidgets
(
'Empty string'
,
(
WidgetTester
tester
)
{
testWidgets
(
'Empty string'
,
(
WidgetTester
tester
)
async
{
tester
.
pumpWidget
(
new
MarkdownBody
(
data:
''
));
await
tester
.
pumpWidget
(
new
MarkdownBody
(
data:
''
));
Iterable
<
Widget
>
widgets
=
tester
.
allWidgets
;
Iterable
<
Widget
>
widgets
=
tester
.
allWidgets
;
_expectWidgetTypes
(
widgets
,
<
Type
>[
MarkdownBody
,
Column
]);
_expectWidgetTypes
(
widgets
,
<
Type
>[
MarkdownBody
,
Column
]);
});
});
testWidgets
(
'Ordered list'
,
(
WidgetTester
tester
)
{
testWidgets
(
'Ordered list'
,
(
WidgetTester
tester
)
async
{
tester
.
pumpWidget
(
new
MarkdownBody
(
data:
'1. Item 1
\n
1. Item 2
\n
2. Item 3'
));
await
tester
.
pumpWidget
(
new
MarkdownBody
(
data:
'1. Item 1
\n
1. Item 2
\n
2. Item 3'
));
Iterable
<
Widget
>
widgets
=
tester
.
allWidgets
;
Iterable
<
Widget
>
widgets
=
tester
.
allWidgets
;
_expectTextStrings
(
widgets
,
<
String
>[
_expectTextStrings
(
widgets
,
<
String
>[
...
@@ -46,8 +46,8 @@ void main() {
...
@@ -46,8 +46,8 @@ void main() {
);
);
});
});
testWidgets
(
'Unordered list'
,
(
WidgetTester
tester
)
{
testWidgets
(
'Unordered list'
,
(
WidgetTester
tester
)
async
{
tester
.
pumpWidget
(
new
MarkdownBody
(
data:
'- Item 1
\n
- Item 2
\n
- Item 3'
));
await
tester
.
pumpWidget
(
new
MarkdownBody
(
data:
'- Item 1
\n
- Item 2
\n
- Item 3'
));
Iterable
<
Widget
>
widgets
=
tester
.
allWidgets
;
Iterable
<
Widget
>
widgets
=
tester
.
allWidgets
;
_expectTextStrings
(
widgets
,
<
String
>[
_expectTextStrings
(
widgets
,
<
String
>[
...
@@ -60,13 +60,13 @@ void main() {
...
@@ -60,13 +60,13 @@ void main() {
);
);
});
});
testWidgets
(
'Scrollable wrapping'
,
(
WidgetTester
tester
)
{
testWidgets
(
'Scrollable wrapping'
,
(
WidgetTester
tester
)
async
{
tester
.
pumpWidget
(
new
Markdown
(
data:
''
));
await
tester
.
pumpWidget
(
new
Markdown
(
data:
''
));
List
<
Widget
>
widgets
=
tester
.
allWidgets
.
toList
();
List
<
Widget
>
widgets
=
tester
.
allWidgets
.
toList
();
_expectWidgetTypes
(
widgets
.
take
(
2
),
<
Type
>[
_expectWidgetTypes
(
widgets
.
take
(
2
),
<
Type
>[
Markdown
,
Markdown
,
S
crollableViewport
,
S
ingleChildScrollView
,
]);
]);
_expectWidgetTypes
(
widgets
.
reversed
.
take
(
3
).
toList
().
reversed
,
<
Type
>[
_expectWidgetTypes
(
widgets
.
reversed
.
take
(
3
).
toList
().
reversed
,
<
Type
>[
Padding
,
Padding
,
...
@@ -75,8 +75,8 @@ void main() {
...
@@ -75,8 +75,8 @@ void main() {
]);
]);
});
});
testWidgets
(
'Links'
,
(
WidgetTester
tester
)
{
testWidgets
(
'Links'
,
(
WidgetTester
tester
)
async
{
tester
.
pumpWidget
(
new
Markdown
(
data:
'[Link Text](href)'
));
await
tester
.
pumpWidget
(
new
Markdown
(
data:
'[Link Text](href)'
));
RichText
textWidget
=
tester
.
allWidgets
.
firstWhere
((
Widget
widget
)
=>
widget
is
RichText
);
RichText
textWidget
=
tester
.
allWidgets
.
firstWhere
((
Widget
widget
)
=>
widget
is
RichText
);
TextSpan
span
=
textWidget
.
text
;
TextSpan
span
=
textWidget
.
text
;
...
@@ -84,29 +84,29 @@ void main() {
...
@@ -84,29 +84,29 @@ void main() {
expect
(
span
.
children
[
0
].
recognizer
.
runtimeType
,
equals
(
TapGestureRecognizer
));
expect
(
span
.
children
[
0
].
recognizer
.
runtimeType
,
equals
(
TapGestureRecognizer
));
});
});
testWidgets
(
'Changing config - data'
,
(
WidgetTester
tester
)
{
testWidgets
(
'Changing config - data'
,
(
WidgetTester
tester
)
async
{
tester
.
pumpWidget
(
new
Markdown
(
data:
'Data1'
));
await
tester
.
pumpWidget
(
new
Markdown
(
data:
'Data1'
));
_expectTextStrings
(
tester
.
allWidgets
,
<
String
>[
'Data1'
]);
_expectTextStrings
(
tester
.
allWidgets
,
<
String
>[
'Data1'
]);
String
stateBefore
=
WidgetsBinding
.
instance
.
renderViewElement
.
toStringDeep
();
String
stateBefore
=
WidgetsBinding
.
instance
.
renderViewElement
.
toStringDeep
();
tester
.
pumpWidget
(
new
Markdown
(
data:
'Data1'
));
await
tester
.
pumpWidget
(
new
Markdown
(
data:
'Data1'
));
String
stateAfter
=
WidgetsBinding
.
instance
.
renderViewElement
.
toStringDeep
();
String
stateAfter
=
WidgetsBinding
.
instance
.
renderViewElement
.
toStringDeep
();
expect
(
stateBefore
,
equals
(
stateAfter
));
expect
(
stateBefore
,
equals
(
stateAfter
));
tester
.
pumpWidget
(
new
Markdown
(
data:
'Data2'
));
await
tester
.
pumpWidget
(
new
Markdown
(
data:
'Data2'
));
_expectTextStrings
(
tester
.
allWidgets
,
<
String
>[
'Data2'
]);
_expectTextStrings
(
tester
.
allWidgets
,
<
String
>[
'Data2'
]);
});
});
testWidgets
(
'Changing config - style'
,
(
WidgetTester
tester
)
{
testWidgets
(
'Changing config - style'
,
(
WidgetTester
tester
)
async
{
ThemeData
theme
=
new
ThemeData
.
light
();
ThemeData
theme
=
new
ThemeData
.
light
();
MarkdownStyle
style1
=
new
MarkdownStyle
.
defaultFromTheme
(
theme
);
MarkdownStyle
style1
=
new
MarkdownStyle
.
defaultFromTheme
(
theme
);
MarkdownStyle
style2
=
new
MarkdownStyle
.
largeFromTheme
(
theme
);
MarkdownStyle
style2
=
new
MarkdownStyle
.
largeFromTheme
(
theme
);
tester
.
pumpWidget
(
new
Markdown
(
data:
'Test'
,
markdownStyle:
style1
));
await
tester
.
pumpWidget
(
new
Markdown
(
data:
'Test'
,
markdownStyle:
style1
));
String
stateBefore
=
WidgetsBinding
.
instance
.
renderViewElement
.
toStringDeep
();
String
stateBefore
=
WidgetsBinding
.
instance
.
renderViewElement
.
toStringDeep
();
tester
.
pumpWidget
(
new
Markdown
(
data:
'Test'
,
markdownStyle:
style2
));
await
tester
.
pumpWidget
(
new
Markdown
(
data:
'Test'
,
markdownStyle:
style2
));
String
stateAfter
=
WidgetsBinding
.
instance
.
renderViewElement
.
toStringDeep
();
String
stateAfter
=
WidgetsBinding
.
instance
.
renderViewElement
.
toStringDeep
();
expect
(
stateBefore
,
isNot
(
stateAfter
));
expect
(
stateBefore
,
isNot
(
stateAfter
));
});
});
...
...
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