अब मैं अपने ऐप में स्क्रॉलबार जोड़ रहा हूं, यह मेरा कोड है:
final ScrollController _scrollController = ScrollController();
return GestureDetector(
onHorizontalDragStart: _onHorizontalDragStart,
onHorizontalDragUpdate: _onHorizontalDragUpdate,
onHorizontalDragEnd: _onHorizontalDragEnd,
child: Container(
constraints: BoxConstraints(
minHeight: MediaQuery.of(context).size.height * 0.9,
),
color: Theme.of(context).scaffoldBackgroundColor,
child: CupertinoScrollbar(
isAlwaysShown: true,
controller: _scrollController,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: buildListView(item, context),
),
)));
लेकिन यूआई में, मुझे स्क्रॉलबार नहीं मिला। UI पर स्क्रॉलबार शो कैसे बनाएं? या क्रोम में एचटीएमएल जैसे निरीक्षण तत्व की तरह। यह यूआई है:
मैंने स्पंदन निरीक्षक को जगाया है, लेकिन जब मैं तत्व पर क्लिक करता हूं, तो एमुलेटर में कुछ नहीं होता है। अब मैं SingleChildScrollView
का उपयोग कर रहा हूं:
SingleChildScrollView buildListView(Item item, BuildContext context) {
return SingleChildScrollView(
controller: _scrollController,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
InkWell(
onTap: () => CommonUtils.launchUrl(item.link),
child: Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Container(
child: Text(
item.title == "" ? "Comment" : item.title,
style: Theme.of(context).textTheme.headline5!.copyWith(
fontWeight: FontWeight.w600,
),
),
),
),
),
if (item.domain != "")
Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: InkWell(
onTap: () async {
navToChannelDetail();
},
child: Text(
item.domain,
style: Theme.of(context).textTheme.caption!.copyWith(color: Theme.of(context).primaryColor),
)),
),
InkWell(
onTap: () {},
child: RichText(
text: TextSpan(
children: <TextSpan>[
TextSpan(
text: item.author,
style: Theme.of(context).textTheme.caption,
),
TextSpan(
text: " ${String.fromCharCode(8226)} ",
style: Theme.of(context).textTheme.caption,
),
TextSpan(
text: item.ago,
style: Theme.of(context).textTheme.caption,
),
],
),
),
),
if (item.content != "")
Html(
data: item.content,
style: {
"body": Style(
fontSize: FontSize(19.0),
),
},
//sonLinkTap: (url) => CommonUtils.launchUrl(url),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Padding(
padding: const EdgeInsets.only(right: 16.0),
child: Row(
children: [
if (item.isFav == 1)
IconButton(
icon: Icon(Icons.bookmark, color: Theme.of(context).primaryColor),
onPressed: () => touchFav("unfav", FavStatus.UNFAV),
),
if (item.isFav != 1)
IconButton(
icon: Icon(Icons.bookmark),
onPressed: () => touchFav("fav", FavStatus.FAV),
),
Padding(
padding: const EdgeInsets.only(left: 0.0),
child: Text(
"${item.favCount}",
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.caption!.copyWith(
color: Theme.of(context).primaryColor,
),
),
),
],
),
),
Padding(
padding: const EdgeInsets.only(bottom: 0.0),
child: Row(
children: [
if (item.isUpvote == 1)
IconButton(
icon: Icon(Icons.thumb_up, color: Theme.of(context).primaryColor),
onPressed: () => touchUpvote("unupvote", UpvoteStatus.UNUPVOTE),
),
if (item.isUpvote != 1)
IconButton(
icon: Icon(Icons.thumb_up),
onPressed: () => touchUpvote("upvote", UpvoteStatus.UPVOTE),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text(
"${item.upvoteCount}",
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.caption!.copyWith(
color: Theme.of(context).primaryColor,
),
),
),
],
),
),
],
),
IconButton(
icon: Icon(
Feather.share_2,
),
onPressed: () => handleShare(id: item.id, title: item.title, postUrl: item.link),
),
],
),
],
));
}
1
Dolphin
21 अप्रैल 2021, 11:45
1 उत्तर
सबसे बढ़िया उत्तर
आपको _scrollController
को ListView
में जोड़ना होगा
आप इसे आजमा सकते हैं, मुझे आपकी मदद करने की उम्मीद है:
return Container(
constraints: BoxConstraints(
minHeight: MediaQuery.of(context).size.height * 0.9,
),
color: Theme.of(context).scaffoldBackgroundColor,
child: CupertinoScrollbar(
isAlwaysShown: true,
controller: _scrollController,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: ListView.builder(
controller: _scrollController,
itemCount: 500,
shrinkWrap: true,
itemBuilder:(_, index){
return Text('Index Number : '+index.toString());
}),
),
));
1
Adel B-Lahlouh
21 अप्रैल 2021, 12:30
संबंधित सवाल
नए सवाल
flutter
स्पंदन Google द्वारा बनाई गई एक ओपन-सोर्स UI सॉफ़्टवेयर डेवलपमेंट किट है। इसका उपयोग Android, iOS, Linux, Mac, Windows, Google Fuchsia और वेब के लिए एक ही कोडबेस से एप्लिकेशन विकसित करने के लिए किया जाता है। स्पंदन ऐप्स डार्ट भाषा में लिखे गए हैं।
SingleChildScrollView
का उपयोग कर रहा हूं। और मैं भी जोड़ रहा हूँ_scrollController
@Adel B-Lahlouh