Repository: flutter
Issue: Feature: Use Language Identifier when customizing properties `syntaxHighlighter`
Labels: c: new feature,package,c: proposal,team-ecosystem,P3,p: flutter_markdown,triaged-ecosystem

## Related Problem
Issue flutter/flutter_markdown#227
and
[StackOverflow - How to add code syntax highlighter to flutter markdown](https://stackoverflow.com/questions/59592640/how-to-add-code-syntax-highlighter-to-flutter-markdown)

# Possible solution

depends on [`highlight`](https://pub.dev/packages/highlight) and of course [`flutter_markdown`](https://pub.dev/packages/flutter_markdown).

**First**, before pass the data to `Markdown` parse a language identifier using RegExp.
 
**Second**, marking the language with a identical `LANG_MARKER` such as `L@NG!`.

this is an example code.

``` dart
  String parseSyntaxLanguage(String data) {
    String parsed = data;
    RegExp codeSign = new RegExp(r'`{3} *');
    RegExp pattern = new RegExp(r'`{3} *[\w]+');
    for (RegExpMatch match in pattern.allMatches(this.data)) {
      String lang = match.group(0).split(codeSign)[1]; // parse a language identifier
      parsed = parsed.replaceFirst(match.group(0), '```\n$LANG_MARKER$lang$LANG_MARKER');
    } // CAUTION "\n" newline is required!
    return parsed;
  }
```

**Third**, Make a syntax highlighter extends `SyntaxHighlighter`

this is an example code.

``` dart
import 'package:flutter/material.dart';
import 'package:flutter/painting.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:highlight/highlight.dart' show highlight, Node;

class LangSyntaxHighlighter extends SyntaxHighlighter {
  final String language;
  final String _rootKey = 'root';
  final String _defaultLang = 'dart';
  final String _defaultFontFamily = 'monospace';
  final Color _defaultFontColor = Color(0xfffdfeff);
  final Map<String, TextStyle> theme; // User's code theme

  LangSyntaxHighlighter(this.theme);

  @override
  TextSpan format(String source) {
    String lang;
    if (source.startsWith(LANG_MARKER)) {
      int idx = source.indexOf(LANG_MARKER, LANG_MARKER.length);
      lang = source.substring(LANG_MARKER.length, idx);
      source = source.substring(idx + LANG_MARKER.length);
    }
    TextStyle _textStyle = TextStyle(
      fontFamily: this._defaultFontFamily,
      color: this.theme[this._rootKey].color ?? this._defaultFontColor,
    );
    return TextSpan(
      style: _textStyle,
      children: this._convert(highlight
          .parse(source, autoDetection: true, language: lang ?? this._defaultLang)
          .nodes),
    );
  }

  List<TextSpan> _convert(List<Node> nodes) {
    List<TextSpan> spans = [];
    var currentSpans = spans;
    List<List<TextSpan>> stack = [];

    _traverse(Node node) {
      if (node.value != null) {
        currentSpans.add(node.className == null
            ? TextSpan(text: node.value)
            : TextSpan(text: node.value, style: theme[node.className]));
      } else if (node.children != null) {
        List<TextSpan> tmp = [];
        currentSpans.add(TextSpan(children: tmp, style: theme[node.className]));
        stack.add(currentSpans);
        currentSpans = tmp;

        node.children.forEach((n) {
          _traverse(n);
          if (n == node.children.last)
            currentSpans = stack.isEmpty ? spans : stack.removeLast();
        });
      }
    }

    for (var node in nodes) _traverse(node);
    return spans;
  }
}
```

**Last**, combine the syntax highlighter and parser.

``` dart
Widget build(BuildContext context) {
    Future<Widget> parseMarkdown = new Future(() {
      return MarkdownBody(
          data: parseSyntaxLanguage(this.data), // markdown source
          syntaxHighlighter: LangSyntaxHighlighter(),
          styleSheet: MarkdownStyleSheet(
    
         ...


```

----

I'm not sure if this is suitable for feature request.
However, I hope this issue helps someone :)