Flutter

convert JSON String to the list object in flutter

点点圈 提交于 2021-01-28 07:28:00
问题 I'm still new to the dart flutter. now I'm trying to pull data from the REST API. following the script that I have made: class ChatCard { final String chatdetail_id; final String chatdetail_userfullname; final String chatdetail_userurlphoto; final String chatdetail_message; final int chatdetail_isread; final String chatdetail_datetime; ChatCard({ this.chatdetail_id, this.chatdetail_userfullname, this.chatdetail_userurlphoto, this.chatdetail_message, this.chatdetail_isread, this.chatdetail

Flutter color not chaning on change of index

為{幸葍}努か 提交于 2021-01-28 07:09:01
问题 I want to change the color on the tap of the container. So I just for loop to show container and change color when index is the same. But the issue is index is changing but the color is not. I have checked by the print value of currentIndex is changing but don't know why the color isn't changing I am using a stateful widget Code List categories = [ {'CatID': 0, 'CatName': 'All'}, {'CatID': 1, 'CatName': 'Computer Hardware'}, {'CatID': 2, 'CatName': 'Computer Software'}, {'CatID': 3, 'CatName'

Cannot localize strings in Flutter TabBarView

允我心安 提交于 2021-01-28 06:53:59
问题 When I try to localize a string in a TabBarView I get this error: NoSuchMethodError: The method 'translate' was called on null. Receiver: null. Tried calling: translate("username). I use this line of code to translate a key to a localized string: AppLocalizations.of(context).translate('username') This works great in all the other screens of my app except this one. Does anyone know why it's not working and how to solve it? Some things I already tried: pass the context of the main screen (the

how to change desktop windows application icon for flutter?

こ雲淡風輕ζ 提交于 2021-01-28 06:52:34
问题 I using the desktop flutter and i searched for a way to do that i couldnt find any articles about that sp ii want to know how to change the launcher app icon for windows desktop and also for mac and linux. 回答1: To change the icon you just need to replace the icon file in your project: Windows: windows/runner/resources/app_icon.ico macOS: macos/Runner/Assets.xcassets/AppIcon.appiconset Linux doesn't have an icon set up in the template yet; you can follow this issue for updates. 来源: https:/

Unit test - How to mock parameters of third-party-library class Dio in flutter

浪尽此生 提交于 2021-01-28 06:30:23
问题 I am trying to test a simple repository class which make a network call using the Dio package that is a dependency injection. Requirement of the Http.post is to send a Map object to a URL with the headers of 'Content-Type': 'application/json . You can see this below: class AuthenticateUserRemoteDataSourceImpl implements AuthenticateUserRepository { final Dio httpClient; AuthenticateUserRemoteDataSourceImpl({@required this.httpClient}); @override Future<Either<Failure, AuthenticateUser>>

How can i refresh the widget on the the page A, when i return from page B?

橙三吉。 提交于 2021-01-28 06:30:16
问题 I have a stateful Page A that contains a widget which is present in a seperate stateful class. The widget fetches a number from sharedPreferences in its initState method and show it and when i click on the widget, it routes to Page B, Page B contains a function that change the number in the sharedPreferences. when i go back i dont see the changes but when i reopen the app or switch to a different tab and come back, i do. 回答1: In page A, when you go to page B use, Navigator.pushNamed(context,

Async request using BLoC in Flutter

梦想的初衷 提交于 2021-01-28 06:24:13
问题 I would like download the data, but also use the application all the time. Can you tell me if it's right solution? The case is we press button download and call funtion bloc.dispatch(Event.download()); In mapEventToState in _Download event we reqest data. But we don't wait for response because we don't want to block others events which are changing view. So I create Future and after getting response I call event _UpdateData() where I process downloaded data and generate state with them. It's

How do I remove a widget in response to user input?

吃可爱长大的小学妹 提交于 2021-01-28 06:07:05
问题 I have a chip. How do I get the chip to disappear when the user has deleted it? I do not understand the code at all from Flutter Docs. I've tried everything. Chip( deleteIcon: Icon(Icons.close, size: 15,), label: Text('Delete me!'), deleteButtonTooltipMessage: 'erase', onDeleted: () {setState(() {print("I want to erase this chip, and eat chips");}); }, ) The docs suggest that this chip (Chip) can be erased. But they don't give much in the way of examples. 回答1: I am assuming that you have this

Flutter video_player not playing video saved to application directory

回眸只為那壹抹淺笑 提交于 2021-01-28 06:03:22
问题 UPDATE: I have confirmed the file is there and works, just not using the video_player. It just never initializes and when I debug from xcode, it does not throw and errors. I am using the image_picker plugin and have modified it to pick videos as well. All works fine on initial selection of video and playing int he video_player. All work on iOS right now. However I base64 encode the video and send to server via JSON. If I decode on server and play the video via http all works fine, however

FLUTTER How to implement Digest Authentification

微笑、不失礼 提交于 2021-01-28 05:58:45
问题 to implement a normal HTTP Request is very easy. But to implement a Digest Authentification I do not really know how to implement. In the best case you can discribe it for Flutter but I do not mind if it is in another language. Thank You! 回答1: The Dart HttpClient supports digest. If you know the realm in advance, call addCredentials before making the request. If not, implement the authenticate callback which will pass the scheme and realm back to you. You should then call addCredentials from