Reputation: 31
This error comes while I try to make body of scaffold scrollable and I have add flutter_html package in my pubspecs.yaml at that time.
I think the problem is from the new inserted package but not confirmed. Can you please help me in solving this problem?
Error: The argument type 'void Function(DragStartDetails, DragUpdateDetails)' can't be assigned to the parameter type 'void Function(TapDragUpdateDetails)?'.
gesture_detector_builder.dart:197
- 'DragStartDetails' is from 'package:flutter/src/gestures/drag_details.dart'
('../../flutter/packages/flutter/lib/src/gestures/drag_details.dart').
drag_details.dart:1- 'DragUpdateDetails' is from 'package:flutter/src/gestures/drag_details.dart'
('../../flutter/packages/flutter/lib/src/gestures/drag_details.dart').
drag_details.dart:1- 'TapDragUpdateDetails' is from 'package:flutter/src/widgets/tap_and_drag_gestures.dart' ('../../flutter/packages/flutter/lib/src/widgets/tap_and_drag_gestures.dart').
tap_and_drag_gestures.dart:1
onDragSelectionUpdate: onDragSelectionUpdate,
^Error: The argument type 'void Function(DragEndDetails)' can't be assigned to the parameter type 'void Function(TapDragEndDetails)?'.
gesture_detector_builder.dart:198
- 'DragEndDetails' is from 'package:flutter/src/gestures/drag_details.dart' ('../../flutter/packages/flutter/lib/src/gestures/drag_details.dart').
drag_details.dart:1- 'TapDragEndDetails' is from 'package:flutter/src/widgets/tap_and_drag_gestures.dart' ('../../flutter/packages/flutter/lib/src/widgets/tap_and_drag_gestures.dart').
tap_and_drag_gestures.dart:1
onDragSelectionEnd: onDragSelectionEnd,
^
Failed to compile application
This is the error I am getting in debug console when trying to run app Can you know why this error occurs? Because it appears unexpectedly and I don't know why it happens.
This is my code in which I lastly editing:
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:newstv/controlller/news_controller.dart';
import 'package:newstv/screens/card_widget.dart';
import '../colors.dart';
class NewsScreen extends StatefulWidget {
const NewsScreen({super.key});
@override
State<NewsScreen> createState() => _NewsScreenState();
}
class _NewsScreenState extends State<NewsScreen> {
NewsController newsController = Get.put(NewsController());
var refreshKey = GlobalKey<RefreshIndicatorState>();
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
appBar: AppBar(
backgroundColor: ThemeCode.background,
elevation: 0,
title:
// column column starts here
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
'Voice of Neemuch',
style: TextStyle(
fontSize: 19,
color: ThemeCode.redcolor,
),
),
Text(
'We with you',
style: TextStyle(
color: ThemeCode.black,
fontSize: 15),
)
],
),
// column ends here
actions: [
IconButton(
onPressed: () {},
icon: Icon(
Icons.search,
color: ThemeCode.black,
size: 35,
),
),
const SizedBox(
width: 20,
)
],
),
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Wrap(
alignment: WrapAlignment.center,
children: [
Padding(
padding: const EdgeInsets.only(
left: 7,
right: 7,
top: 4,
bottom: 4),
child: ColoredBox(
color: Colors.amberAccent,
child: Padding(
padding:
const EdgeInsets.all(8.0),
child: Wrap(
alignment: WrapAlignment.center,
children: [
const Text(
'Contact for news and Advertisement'),
const SizedBox(
width: 4,
),
const Icon(
Icons.phonelink_sharp),
const SizedBox(
width: 4,
),
TextButton(
onPressed: () {},
child: const Text(
'91 4543******'))
],
),
),
),
),
//List view builder ode goes here
Obx(() {
if (newsController
.isDataLoading.value) {
return const Center(
child:
CircularProgressIndicator(),
);
} else if (newsController.newsModel!
.responseData.isEmpty) {
return const Center(
child: Text('Data not available'),
);
}
return RefreshIndicator(
key: refreshKey,
onRefresh: () =>
newsController.getApi(),
child: ListView.builder(
scrollDirection: Axis.vertical,
physics:
const AlwaysScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: newsController
.newsModel
?.responseData
.length,
itemBuilder:
(BuildContext context,
int index) {
return CardWidget(
model: newsController
.newsModel!
.responseData[index]);
}),
);
})
],
),
],
)));
}
}
this is my card file
// ignore_for_file: non_constant_identifier_names
import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:get/get.dart';
import 'package:newstv/colors.dart';
import 'package:newstv/configs/config.dart';
import 'package:newstv/controlller/news_controller.dart';
import '../models/news_model.dart';
import 'news_detailpage.dart';
class CardWidget extends StatelessWidget {
CardWidget({super.key, required this.model});
final ResponseDatum? model;
final NewsController newsController =
Get.put(NewsController());
@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
margin: const EdgeInsets.symmetric(horizontal: .0),
child: Card(
elevation: 4.0,
child: ListTile(
title: Stack(
alignment: Alignment.bottomLeft,
children: [
BackgroundImage(),
Container(
alignment: Alignment.center,
color: ThemeCode.textBackground,
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 5),
child: Text(
model!.postTitle,
style:
TextStyle(color: ThemeCode.black),
maxLines: 1,
overflow: TextOverflow.ellipsis,
softWrap: true,
),
)),
],
),
subtitle: Padding(
padding:
const EdgeInsets.symmetric(vertical: 10),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Date',
style:
TextStyle(color: ThemeCode.black)),
const SizedBox(
height: 6,
),
Html(
data: model!.postDescription,
style: {
'p, div, span,h1, h2,h3,h4,h5,h6 ':
Style(color: ThemeCode.lightBlack)
},
),
const SizedBox(
height: 3,
),
const Divider(
color: Colors.black,
thickness: 1,
),
],
),
),
onTap: () {
Get.to(PostDetailPage(
data: model,
));
},
),
),
);
}
BackgroundImage() {
return Obx(
() => newsController.isDataLoading.value
? const Center(
child: CircularProgressIndicator(),
)
: Container(
width: Get.width * 1,
height: 300,
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage(
Config.imageURL + model!.postImage),
fit: BoxFit.cover,
)),
),
);
}
}
Upvotes: 1
Views: 123
Reputation: 346
I guess the versions you are using:
I verified the problem you said by this version, please upgrade the flutter_html version to v3.x
.
Although the version called Pre-release
, it can solve this problem you said.
more: https://github.com/Sub6Resources/flutter_html/releases
Upvotes: 1