markdown_widget icon indicating copy to clipboard operation
markdown_widget copied to clipboard

Wrapped widget not resizing correctly when increasing textstyle fontSize.

Open xenoliss opened this issue 5 years ago • 5 comments

Describe the bug When using the example 'hightlight code' given in the ReadMe, increasing the fontSize property through the textStyle argument of preConfig cause the code being clipped after several lines.

To Reproduce Steps to reproduce the behavior:

  1. Start form the example 'hightlight code'
  2. Set testStyleProperty as TextStyle(fontSize: 18)
  3. Write about ten lines of code
  4. Notice the outputed code in the widget is getting clipped at the bottom

Expected behavior The outputed code should not be clipped

xenoliss avatar May 11 '20 11:05 xenoliss

what's your flutter version?

I'm using v1.16.2, and it seems to be ok

image

asjqkkkk avatar May 11 '20 14:05 asjqkkkk

I'm using Flutter 1.17.0 on beta channel (for web dev).

See the code below:

class ExampleWidget extends StatefulWidget {
  @override
  _ExampleWidgetState createState() => _ExampleWidgetState();
}

class _ExampleWidgetState extends State<ExampleWidget> {
  String code = '';

  @override
  Widget build(BuildContext context) {
    return Column(
      children: <Widget>[
        LimitedBox(
          maxHeight: 100,
          child: SingleChildScrollView(
            child: TextField(
              decoration: InputDecoration(
                hintText: 'Paste your code here...',
                hintStyle: TextStyle(
                  color: Colors.grey,
                  fontSize: 18,
                ),
                border: InputBorder.none,
              ),
              style: TextStyle(
                fontSize: 18,
                color: Colors.white,
              ),
              keyboardType: TextInputType.multiline,
              maxLines: null,
              onChanged: (value) {
                setState(() {
                  code = "```\n$value\n```";
                });
              },
            ),
          ),
        ),
        Container(
          height: 300,
          child: MarkdownWidget(
            childMargin: EdgeInsets.only(top: 13),
            data: code,
            styleConfig: StyleConfig(
              preConfig: PreConfig(
                textStyle: TextStyle(fontSize: 18),
                language: 'java',
                theme: theme.a11yLightTheme,
              ),
            ),
          ),
        ),
      ],
    );
  }
}

After writing some lines in the textfield, the markdown widget does not scroll enough to show the last lines. Maybe this is an expected behavior ?

xenoliss avatar May 11 '20 15:05 xenoliss

2020-05-12 00-12-39 2020-05-12 00_13_12

if you can provide some screenshot or gif, maybe the problem will be more clear

this issue looks like flutter's issue

asjqkkkk avatar May 11 '20 16:05 asjqkkkk

What I meant is that if you now remove the textStyle property you'll find the MarkdownWidget does not behave exactly identically: as long as it can expands you'll be abble to see the last line without having to press enter or to scroll.

But when you change the fontSize (like 18) even when the widget can still expand vertically, the last line will be clipped (after several lines) unless you press enter / scroll.

After all that's maybe not that problematic and I can close this issue if you think it's a normal behavior.

xenoliss avatar May 11 '20 16:05 xenoliss

PreWidget is wrapped in SinglechildScrollerView with Axis.horizontal, the normal situation should be like this

It behaves normally in v1.16.2, but incorrectly in v1.17.0, so I think it should be flutter's issue, not this package

asjqkkkk avatar May 12 '20 01:05 asjqkkkk