forked from flutter/packages
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[flutter_markdown] Ensure customize nested bullet list style. (flutte…
…r#6384) See flutter/flutter#145670 .
- Loading branch information
1 parent
bb82cb7
commit 5d15437
Showing
7 changed files
with
186 additions
and
6 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
84 changes: 84 additions & 0 deletions
84
packages/flutter_markdown/example/lib/demos/custom_bullet_list_demo.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,84 @@ | ||
// 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. | ||
|
||
// TODO(goderbauer): Restructure the examples to avoid this ignore, https://github.com/flutter/flutter/issues/110208. | ||
// ignore_for_file: avoid_implementing_value_types | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_markdown/flutter_markdown.dart'; | ||
import '../shared/markdown_demo_widget.dart'; | ||
|
||
// ignore_for_file: public_member_api_docs | ||
|
||
const String _markdownData = ''' | ||
# Custom Ordered List Demo | ||
## Unordered List | ||
- first | ||
- second | ||
- first | ||
- first | ||
- second | ||
- first | ||
- second | ||
## Ordered List | ||
1. first | ||
2. second | ||
1. first | ||
1. first | ||
2. second | ||
1. first | ||
1. second | ||
'''; | ||
|
||
const String _notes = ''' | ||
# Custom Bullet List Demo | ||
--- | ||
## Overview | ||
This is the custom bullet list demo. This demo shows how to customize the bullet list style. | ||
This demo example is being preserved for reference purposes. | ||
'''; | ||
|
||
class CustomBulletListDemo extends StatelessWidget | ||
implements MarkdownDemoWidget { | ||
const CustomBulletListDemo({super.key}); | ||
|
||
static const String _title = 'Custom Bullet List Demo'; | ||
|
||
@override | ||
String get title => CustomBulletListDemo._title; | ||
|
||
@override | ||
String get description => 'Shows how to customize the bullet list style.'; | ||
|
||
@override | ||
Future<String> get data => Future<String>.value(_markdownData); | ||
|
||
@override | ||
Future<String> get notes => Future<String>.value(_notes); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
body: SafeArea( | ||
child: Markdown( | ||
data: _markdownData, | ||
bulletBuilder: (MarkdownBulletParameters parameters) => FittedBox( | ||
fit: BoxFit.scaleDown, | ||
child: switch (parameters.style) { | ||
BulletStyle.unorderedList => const Text('・'), | ||
BulletStyle.orderedList => | ||
Text('${parameters.nestLevel}-${parameters.index + 1}.'), | ||
}, | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
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
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
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