Flutter

change the datetime format in flutter, to leave it only with the date

非 Y 不嫁゛ 提交于 2021-02-07 10:15:41
问题 I would like to know how I can change the datetime format in flutter, to leave it only with the date. I also want to know if there is another widget that only contains the date. Thanks 回答1: You can use DateFormat from intl package. With it you can custom to any format that you need. Add to pubspec.yaml dependencies: intl: ^0.15.7 On Dart code: import 'package:intl/intl.dart'; final dateFormatter = DateFormat('yyyy-MM-dd'); final dateString = dateFormatter.format(DateTime.now()); Then you can

App Update is rejected from google play due to Background Location access (But I didn't use any background location Permission)

寵の児 提交于 2021-02-07 09:29:29
问题 Currently, I am working on a Courier service app using Flutter. My app need Location permission in foreground to find nearby Courier services. I didn't use any background location permission in my app. But, when I try to upload my updated app (Previous version of my app is already in Play Store), it shows I took background location permission. Here is a screenshot of play console app summary of updated version of my app: And here is another screenshot of my previous version of app which is

Flutter Custom Title Dropdown (Material Page Filter)

纵饮孤独 提交于 2021-02-07 07:26:47
问题 Following the concept of the app bar "page filter" I'd like to put a DropdownButton as the title of the AppBar . I tried, but it doesn't look good. https://material.io/guidelines/layout/structure.html#structure-app-bar class MyHomePage extends StatefulWidget { MyHomePage({Key key, this.title}) : super(key: key); final String title; @override _MyHomePageState createState() => new _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { String _value = 'one'; @override void

Handling grapheme clusters in Dart

℡╲_俬逩灬. 提交于 2021-02-07 07:20:32
问题 From what I can tell Dart does not have support for grapheme clusters, though there is talk of supporting it: Dart Strings should support Unicode grapheme cluster operations #34 Minimal Unicode grapheme cluster support #49 Until it is implemented, what are my options for iterating through grapheme clusters? For example, if I have a string like this: String family = '\u{1F468}\u{200D}\u{1F469}\u{200D}\u{1F467}'; // 👨‍👩‍👧 String myString = 'Let me introduce my $family to you.'; and there is a

How to store list of object data in sqlite on Flutter?

别说谁变了你拦得住时间么 提交于 2021-02-07 07:20:30
问题 How to store a list of object data in SQLite on Flutter? Json data coming with API. { "images": [ { "id": 10, "name": "img1" }, { "id": 11, "name": "img2" } ] } 回答1: use flutter sqlite package make helper class for db operations and model class example here parse json and insert or update data 来源: https://stackoverflow.com/questions/55232650/how-to-store-list-of-object-data-in-sqlite-on-flutter

Implementing MQTT in Flutter

倖福魔咒の 提交于 2021-02-07 07:19:43
问题 I am new to Flutter (coming from Android background) and want to implement MQTT client in flutter. This is what i want: MQTT client which should be "alive" when the app is open/not killed by OS. I don't want to run it in background (without the app open, i know there is issue doing it in iOS, read it somewhere) but while the app is open. Updating UI/State based on messages coming in subscribed topics. I looked into pub and found 2 packages, mqtt and mqtt_client, they look like non-Flutter

How can I round the corners of a slider in Flutter

匆匆过客 提交于 2021-02-07 06:58:09
问题 I'm using the basic slider, and I found how to update just the parts of the slider theme data that I want to change like trackHeight, but unfortunately I'm not sure how to update the field for "trackShape". Here is what I do in the main app to update track height for example: final SliderThemeData tweakedSliderTheme = Theme.of(context).sliderTheme.copyWith( trackHeight: 22.0, //trackShape: RectangularSliderTrackShape(), // How do I update this?? ); I did try using ClipRRect() around the

preload assets images before build

荒凉一梦 提交于 2021-02-07 06:50:15
问题 am trying to set background image of my container to image from assets like this: return new Container( decoration: new BoxDecoration( image: new DecorationImage( image: new AssetImage(images[index]), fit: BoxFit.cover, ), ), but this will take some time to load and return blank whilte screen till image load .. so i tried to preload images before build like this: @override void initState() { precacheImage(new AssetImage(images[1]), context); precacheImage(new AssetImage(images[2]), context);

Multiple rows in body of flutter application

时间秒杀一切 提交于 2021-02-07 06:46:26
问题 I am trying to create a screen in flutter that has 3 rows stacked on top of each other but I keep getting syntax errors. I have tried multiple containers in the body, Rows etc and keep getting syntax errors, is what im trying to do impossible? I would think Rows would be stackable, or at least containers in a body. Here is the code: import 'package:flutter/material.dart'; class Index extends StatelessWidget { @override Widget build(BuildContext context) { // TODO: implement build return new

Shared_Preferences for Flutter Web?

佐手、 提交于 2021-02-07 06:25:05
问题 Shared_preferences (https://pub.dev/packages/shared_preferences) doesn't seem to work for Flutter for Web. I have the following function that's called when a button is pressed. getEmail() async { print("reached 1st line"); SharedPreferences prefs = await SharedPreferences.getInstance(); print("reached 2nd line"); String _confirmedEmail = prefs.getString('_confirmedEmail') ?? ""; ) It prints "reached 1st line" but not "reached 2nd line", which means the program doesn't go past the await