-
Notifications
You must be signed in to change notification settings - Fork 26.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[flutter_markdown] "scrollController.position.maxScrollExtent" is not a fixed value #98813
Comments
Hi @guchengxi1994, Thanks for filing the issue. Your code sample contains a lot of unknown/dependent variables I narrowed down your code sample by removing such variables and I could not reproduce the issue the maxScrollExtent was always a constant value. I verified this issue on code sampleimport 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: 'markdown sample',
home: HomePage(),
);
}
}
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
final controller = ScrollController();
@override
Widget build(BuildContext context) {
return Material(
child: BaseMarkdownPreviewPage(
from: DataFrom.string,
mdData: _notes,
));
}
}
const String _notes = """
# Basic Markdown Demo
---
The Basic Markdown Demo shows the effect of the four Markdown extension sets
on formatting basic and extended Markdown tags.
## Overview
The Dart [markdown](https://pub.dev/packages/markdown) package parses Markdown
into HTML. The flutter_markdown package builds on this package using the
abstract syntax tree generated by the parser to make a tree of widgets instead
of HTML elements.
The markdown package supports the basic block and inline Markdown syntax
specified in the original Markdown implementation as well as a few Markdown
extensions. The markdown package uses extension sets to make extension
management easy. There are four pre-defined extension sets; none, Common Mark,
GitHub Flavored, and GitHub Web. The default extension set used by the
flutter_markdown package is GitHub Flavored.
The Basic Markdown Demo shows the effect each of the pre-defined extension sets
has on a test Markdown document with basic and extended Markdown tags. Use the
Extension Set dropdown menu to select an extension set and view the Markdown
widget's output.
## Comments
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
for the formatted Markdown view in the demo.
""";
enum DataFrom { net, asset, string, file }
// ignore: must_be_immutable
class BaseMarkdownPreviewPage extends StatefulWidget {
BaseMarkdownPreviewPage({Key? key, this.mdData, required this.from})
: super(key: key);
final DataFrom from;
String? mdData;
@override
State<BaseMarkdownPreviewPage> createState() =>
_BaseMarkdownPreviewPageState();
}
class _BaseMarkdownPreviewPageState extends State<BaseMarkdownPreviewPage> {
late String markdownData;
// ignore: prefer_typing_uninitialized_variables
var _loadDataFuture;
ScrollController scrollController = ScrollController();
GlobalKey<State<Markdown>> _globalKey = GlobalKey();
@override
void initState() {
super.initState();
if (widget.from == DataFrom.string) {
_loadDataFuture = loadDataFromString();
} else if (widget.from == DataFrom.asset) {
_loadDataFuture = loadDataFromAsset();
} else if (widget.from == DataFrom.net) {
_loadDataFuture = justAMoment();
} else {}
scrollController.addListener(() {
print("maxScrollExtent:" +
scrollController.position.maxScrollExtent.toString());
print("offset:" + scrollController.offset.toString());
});
WidgetsBinding.instance!.addPostFrameCallback((timeStamp) {
print(context.size?.height);
});
}
justAMoment() async {
await Future.delayed(const Duration(milliseconds: 1));
}
loadDataFromAsset() async {
var _data = await rootBundle.loadString(widget.mdData!);
setState(() {
markdownData = _data;
});
}
loadDataFromString() async {
await Future.delayed(const Duration(milliseconds: 1)).then((value) {
if (widget.mdData != null) {
setState(() {
markdownData = widget.mdData!;
});
} else {
setState(() {
markdownData = _notes;
});
}
});
}
@override
void dispose() {
scrollController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: null,
// ignore: avoid_unnecessary_containers
body: FutureBuilder(
future: _loadDataFuture,
builder: (context, snap) {
if (snap.connectionState == ConnectionState.done) {
if (widget.from != DataFrom.net) {
return Markdown(
key: _globalKey,
controller: scrollController,
data: markdownData,
onTapLink: (text, href, title) async {},
);
} else {
return TextButton(
onPressed: () async {}, child: const Text('click to launch'));
}
} else {
return const Center(child: Text('label.loadingSt'));
}
},
),
);
}
}
logs
flutter doctor -v
|
I copied your code and it worked fine, then I made more tests .
I think the issue may be related to markdown rendener or something else. My flutter_markdown version is 0.6.9 and here are my flutter doctor infomation.
|
@guchengxi1994 I am sorry, I still couldn;t reproduce it. I did add your markdown text to the string but yet could not reproduce it. code sampleimport 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: 'markdown sample',
home: HomePage(),
);
}
}
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
final controller = ScrollController();
@override
Widget build(BuildContext context) {
return Material(
child: BaseMarkdownPreviewPage(
from: DataFrom.string,
mdData: _notes,
));
}
}
const String _notes = """
# Basic Markdown Demo
---
The Basic Markdown Demo shows the effect of the four Markdown extension sets
on formatting basic and extended Markdown tags.
## Overview
The Dart [markdown](https://pub.dev/packages/markdown) package parses Markdown
into HTML. The flutter_markdown package builds on this package using the
abstract syntax tree generated by the parser to make a tree of widgets instead
of HTML elements.
The markdown package supports the basic block and inline Markdown syntax
specified in the original Markdown implementation as well as a few Markdown
extensions. The markdown package uses extension sets to make extension
management easy. There are four pre-defined extension sets; none, Common Mark,
GitHub Flavored, and GitHub Web. The default extension set used by the
flutter_markdown package is GitHub Flavored.
The Basic Markdown Demo shows the effect each of the pre-defined extension sets
has on a test Markdown document with basic and extended Markdown tags. Use the
Extension Set dropdown menu to select an extension set and view the Markdown
widget's output.
***
# Title 1
## Title 2
### Title 3
#### Title 4
##### Title 5
###### Title 6
***
## Comments
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
for the formatted Markdown view in the demo.
""";
enum DataFrom { net, asset, string, file }
// ignore: must_be_immutable
class BaseMarkdownPreviewPage extends StatefulWidget {
BaseMarkdownPreviewPage({Key? key, this.mdData, required this.from})
: super(key: key);
final DataFrom from;
String? mdData;
@override
State<BaseMarkdownPreviewPage> createState() =>
_BaseMarkdownPreviewPageState();
}
class _BaseMarkdownPreviewPageState extends State<BaseMarkdownPreviewPage> {
late String markdownData;
// ignore: prefer_typing_uninitialized_variables
var _loadDataFuture;
ScrollController scrollController = ScrollController();
GlobalKey<State<Markdown>> _globalKey = GlobalKey();
@override
void initState() {
super.initState();
if (widget.from == DataFrom.string) {
_loadDataFuture = loadDataFromString();
} else if (widget.from == DataFrom.asset) {
_loadDataFuture = loadDataFromAsset();
} else if (widget.from == DataFrom.net) {
_loadDataFuture = justAMoment();
} else {}
scrollController.addListener(() {
print("maxScrollExtent:" +
scrollController.position.maxScrollExtent.toString());
print("offset:" + scrollController.offset.toString());
});
WidgetsBinding.instance!.addPostFrameCallback((timeStamp) {
print(context.size?.height);
});
}
justAMoment() async {
await Future.delayed(const Duration(milliseconds: 1));
}
loadDataFromAsset() async {
var _data = await rootBundle.loadString(widget.mdData!);
setState(() {
markdownData = _data;
});
}
loadDataFromString() async {
await Future.delayed(const Duration(milliseconds: 1)).then((value) {
if (widget.mdData != null) {
setState(() {
markdownData = widget.mdData!;
});
} else {
setState(() {
markdownData = _notes;
});
}
});
}
@override
void dispose() {
scrollController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: null,
// ignore: avoid_unnecessary_containers
body: FutureBuilder(
future: _loadDataFuture,
builder: (context, snap) {
if (snap.connectionState == ConnectionState.done) {
if (widget.from != DataFrom.net) {
return Markdown(
key: _globalKey,
controller: scrollController,
data: markdownData,
onTapLink: (text, href, title) async {},
);
} else {
return TextButton(
onPressed: () async {}, child: const Text('click to launch'));
}
} else {
return const Center(child: Text('label.loadingSt'));
}
},
),
);
}
}
Thanks |
This is quite strange. Here are my codes. code sampleimport 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
class MyAppTest2 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: 'markdown sample',
home: HomePage(),
);
}
}
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
final controller = ScrollController();
@override
Widget build(BuildContext context) {
return Material(
child: BaseMarkdownPreviewPage(
from: DataFrom.string,
mdData: _notes,
));
}
}
const String _notes = """
# Basic Markdown Demo
---
The Basic Markdown Demo shows the effect of the four Markdown extension sets
on formatting basic and extended Markdown tags.
## Overview
The Dart [markdown](https://pub.dev/packages/markdown) package parses Markdown
into HTML. The flutter_markdown package builds on this package using the
abstract syntax tree generated by the parser to make a tree of widgets instead
of HTML elements.
The markdown package supports the basic block and inline Markdown syntax
specified in the original Markdown implementation as well as a few Markdown
extensions. The markdown package uses extension sets to make extension
management easy. There are four pre-defined extension sets; none, Common Mark,
GitHub Flavored, and GitHub Web. The default extension set used by the
flutter_markdown package is GitHub Flavored.
The Basic Markdown Demo shows the effect each of the pre-defined extension sets
has on a test Markdown document with basic and extended Markdown tags. Use the
Extension Set dropdown menu to select an extension set and view the Markdown
widget's output.
## Comments
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
for the formatted Markdown view in the demo.
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
for the formatted Markdown view in the demo.
***
# Title 1
## Title 2
### Title 3
#### Title 4
##### Title 5
###### Title 6
***
""";
enum DataFrom { net, asset, string, file }
// ignore: must_be_immutable
class BaseMarkdownPreviewPage extends StatefulWidget {
BaseMarkdownPreviewPage({Key? key, this.mdData, required this.from})
: super(key: key);
final DataFrom from;
String? mdData;
@override
State<BaseMarkdownPreviewPage> createState() =>
_BaseMarkdownPreviewPageState();
}
class _BaseMarkdownPreviewPageState extends State<BaseMarkdownPreviewPage> {
late String markdownData;
// ignore: prefer_typing_uninitialized_variables
var _loadDataFuture;
ScrollController scrollController = ScrollController();
GlobalKey<State<Markdown>> _globalKey = GlobalKey();
@override
void initState() {
super.initState();
if (widget.from == DataFrom.string) {
_loadDataFuture = loadDataFromString();
} else if (widget.from == DataFrom.asset) {
_loadDataFuture = loadDataFromAsset();
} else if (widget.from == DataFrom.net) {
_loadDataFuture = justAMoment();
} else {}
scrollController.addListener(() {
print("maxScrollExtent:" +
scrollController.position.maxScrollExtent.toString());
print("offset:" + scrollController.offset.toString());
});
WidgetsBinding.instance!.addPostFrameCallback((timeStamp) {
print(context.size?.height);
});
}
justAMoment() async {
await Future.delayed(const Duration(milliseconds: 1));
}
loadDataFromAsset() async {
var _data = await rootBundle.loadString(widget.mdData!);
setState(() {
markdownData = _data;
});
}
loadDataFromString() async {
await Future.delayed(const Duration(milliseconds: 1)).then((value) {
if (widget.mdData != null) {
setState(() {
markdownData = widget.mdData!;
});
} else {
setState(() {
markdownData = _notes;
});
}
});
}
@override
void dispose() {
scrollController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: null,
// ignore: avoid_unnecessary_containers
body: FutureBuilder(
future: _loadDataFuture,
builder: (context, snap) {
if (snap.connectionState == ConnectionState.done) {
if (widget.from != DataFrom.net) {
return Markdown(
key: _globalKey,
controller: scrollController,
data: markdownData,
onTapLink: (text, href, title) async {},
);
} else {
return TextButton(
onPressed: () async {}, child: const Text('click to launch'));
}
} else {
return const Center(child: Text('label.loadingSt'));
}
},
),
);
}
} Besides, I tested it on web, not an android simulator.Using |
I'm having problems with I also tried to scroll directly to the index of the SliverList, and that also failed. my repo My idea is to save each widget height in the SliverList to a list by getting it, and then accumulate it from the first widget until the result is greater than the current view's offset, then consider the last index as the index value that can be observed on the current view. If the current view does not change state after initialization, then the exact index can still be fetched, and once the |
Thanks for the code sample @guchengxi1994, I was able to reproduce the issue on stable and the master channel. I can confirm adding the below markdown to string reproduces the issue. ***
# Title 1
## Title 2
### Title 3
#### Title 4
##### Title 5
###### Title 6
***
code sampleimport 'package:flutter/material.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
void main() {
runApp(MyAppTest2());
}
class MyAppTest2 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: 'markdown sample',
home: HomePage(),
);
}
}
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
final controller = ScrollController();
@override
Widget build(BuildContext context) {
return const Material(child: BaseMarkdownPreviewPage());
}
}
const String _notes = """
# Basic Markdown Demo
---
The Basic Markdown Demo shows the effect of the four Markdown extension sets
on formatting basic and extended Markdown tags.
## Overview
The Dart [markdown](https://pub.dev/packages/markdown) package parses Markdown
into HTML. The flutter_markdown package builds on this package using the
abstract syntax tree generated by the parser to make a tree of widgets instead
of HTML elements.
The markdown package supports the basic block and inline Markdown syntax
specified in the original Markdown implementation as well as a few Markdown
extensions. The markdown package uses extension sets to make extension
management easy. There are four pre-defined extension sets; none, Common Mark,
GitHub Flavored, and GitHub Web. The default extension set used by the
flutter_markdown package is GitHub Flavored.
The Basic Markdown Demo shows the effect each of the pre-defined extension sets
has on a test Markdown document with basic and extended Markdown tags. Use the
Extension Set dropdown menu to select an extension set and view the Markdown
widget's output.
## Comments
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
for the formatted Markdown view in the demo.
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
Since GitHub Flavored is the default extension set, it is the initial setting
for the formatted Markdown view in the demo.
Removing the below lines fixes the markdown maxScrollExtent issue
***
# Title 1
## Title 2
### Title 3
#### Title 4
##### Title 5
###### Title 6
***
""";
enum DataFrom { net, asset, string, file }
// ignore: must_be_immutable
class BaseMarkdownPreviewPage extends StatefulWidget {
const BaseMarkdownPreviewPage({Key? key}) : super(key: key);
@override
State<BaseMarkdownPreviewPage> createState() =>
_BaseMarkdownPreviewPageState();
}
class _BaseMarkdownPreviewPageState extends State<BaseMarkdownPreviewPage> {
late String markdownData;
ScrollController scrollController = ScrollController();
@override
void initState() {
super.initState();
scrollController.addListener(() {
print("maxScrollExtent:" +
scrollController.position.maxScrollExtent.toString());
print("offset:" + scrollController.offset.toString());
});
}
@override
void dispose() {
scrollController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
// ignore: avoid_unnecessary_containers
body: Markdown(
controller: scrollController,
data: _notes,
onTapLink: (text, href, title) async {},
));
}
}
logs
flutter doctor -v
|
set the scrollview cacheExtent to a large value (eg : double.maxFinite) can fix this issue,but maybe affecting performance. |
I get similar problems, too. The init maxScrollExtent not equals the scrollcontroller's listener maxScrollExtent. But when setting the ListView cacheExtent to double.maxFinite, it works well. |
I was facing the same issue, I ended up looking for another better library. This one worked for me https://pub.dev/packages/markdown_widget |
I was using flutter_markdown in my app and i want to get the markdown height with a ScrollController, but the scrollController.position.maxScrollExtent is not a fixed value. Here are my codes:
code sample
I add a listener in scrollercontroller to get the maxScrollExtent,but the result is not fixed.
The text was updated successfully, but these errors were encountered: