-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[flutter_markdown] Adopt code excerpts in README (#4656)
Updates the README to use a compiled excerpt source for its example of creating a `Markdown`. Part of flutter/flutter#102679
- Loading branch information
1 parent
6cb2a32
commit 470a325
Showing
5 changed files
with
85 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
packages/flutter_markdown/example/lib/readme_excerpts.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'package:flutter/cupertino.dart'; | ||
import 'package:flutter_markdown/flutter_markdown.dart'; | ||
|
||
// #docregion CreateMarkdownWithEmojiExtension | ||
import 'package:markdown/markdown.dart' as md; | ||
// #enddocregion CreateMarkdownWithEmojiExtension | ||
|
||
/// Create a simple `Markdown` wdget. | ||
void createMarkdown() { | ||
const String markdownSource = ''; | ||
|
||
// #docregion CreateMarkdown | ||
const Markdown(data: markdownSource); | ||
// #enddocregion CreateMarkdown | ||
} | ||
|
||
/// Create a simple `MarkdownBody` widget. | ||
void createMarkdownBody() { | ||
const String markdownSource = ''; | ||
|
||
// #docregion CreateMarkdownBody | ||
const MarkdownBody(data: markdownSource); | ||
// #enddocregion CreateMarkdownBody | ||
} | ||
|
||
/// Create a simple `Markdown` widget with an emoji. | ||
void createMarkdownWithEmoji() { | ||
final ScrollController controller = ScrollController(); | ||
|
||
// #docregion CreateMarkdownWithEmoji | ||
Markdown( | ||
controller: controller, | ||
selectable: true, | ||
data: 'Insert emoji here😀 ', | ||
); | ||
// #enddocregion CreateMarkdownWithEmoji | ||
} | ||
|
||
/// Create a simple `Markdown` widget with an emoji extension. | ||
void createMarkdownWithEmojiExtension() { | ||
final ScrollController controller = ScrollController(); | ||
|
||
// #docregion CreateMarkdownWithEmojiExtension | ||
Markdown( | ||
controller: controller, | ||
selectable: true, | ||
data: 'Insert emoji :smiley: here', | ||
extensionSet: md.ExtensionSet( | ||
md.ExtensionSet.gitHubFlavored.blockSyntaxes, | ||
<md.InlineSyntax>[ | ||
md.EmojiSyntax(), | ||
...md.ExtensionSet.gitHubFlavored.inlineSyntaxes | ||
], | ||
), | ||
); | ||
// #enddocregion CreateMarkdownWithEmojiExtension | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters