Issue
Does anybody know how to solve this error here's my code and the imports the error is in the "File" the error is as follows:
The name 'File' is defined in the libraries 'dart:html' and 'dart:io'.
@override
State createState() => ChatScreenState(receiverId: receiverId, receiverAvatar: receiverAvatar);
}
class ChatScreenState extends State<ChatScreen>
{
final String receiverId;
final String receiverAvatar;
ChatScreenState({
Key key,
@required this.receiverId,
@required this.receiverAvatar,
});
final TextEditingController textEditingController = TextEditingController();
final ScrollController listScrollController = ScrollController();
final FocusNode focusNode = FocusNode();
bool isDisplaySticker;
bool isLoading;
File imageFile;
String imageUrl;
String chatId;
SharedPreferences preferences;
String id;
var listMessage;
@override
void initState() {
// TODO: implement initState
super.initState();
focusNode.addListener(onFocusChange);
isDisplaySticker = false;
isLoading = false;
chatId = "";
readLocal();
}
I also imported this
import 'dart:async';
import 'dart:html';
import 'dart:io';
import 'package:file/file.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:flutter/material.dart';
import 'package:telegramchatapp/Widgets/FullImageWidget.dart';
import 'package:telegramchatapp/Widgets/ProgressWidget.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:image_picker/image_picker.dart';
import 'package:intl/intl.dart';
import 'package:shared_preferences/shared_preferences.dart';
Solution
Please check you need dart.html
or not.
If you need both packages, you can use a typecast operator as
.
//import
import 'dart:io' as io;
import 'dart:html';
//Usage
io.File imageFile;
File htmlFile;
Answered By - Mardel
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.