天道酬勤,学无止境

flutter

The argument type 'Object' can't be assigned to the parameter type 'ImageProvider<Object>'

I just updated to Dart2 and Flutter sdk: '>=2.12.0 <3.0.0' and now this if statement breaks: decoration: new BoxDecoration( shape: BoxShape.circle, color: Colors.blueAccent, border: Border.all( color: Colors.blueAccent, width: 20.0, style: BorderStyle.solid), image: new DecorationImage( fit: BoxFit.cover, image: myMarkerThumb != 'noImage' ? NetworkImage(myMarkerThumb) : AssetImage('assets/images/noImageAvailable.png'), ), ), The argument type 'Object' can't be assigned to the parameter type 'ImageProvider'. ), I'm just starting with flutter and have no idea where to look else.

2022-06-07 13:30:11    分类:问答    flutter   if-statement   typeerror   dart-2

How do detect where a user tapped on my screen, with Flutter?

问题 我想知道在我的屏幕上点击的位置的 x/y 坐标。 我找到了 GestureDetector,但它似乎并没有告诉我点击的确切位置。 到目前为止,这是我的代码: import 'package:flutter/material.dart'; void main() { runApp(new MyWidget()); } class MyWidget extends StatelessWidget { @override Widget build(BuildContext context) { return new GestureDetector( onTap: () => print('tapped!') ); } } 哪个确实注册了水龙头...但是我如何找出水龙头从哪里开始? 回答1 class MyWidget extends StatelessWidget { @override Widget build(BuildContext context) { return new GestureDetector( onTap: () => print('tapped!'), onTapDown: (TapDownDetails details) => _onTapDown(details), onTapUp: (TapUpDetails details) => _onTapUp

2022-05-17 04:09:03    分类:技术分享    dart   flutter

Vertical sliders in Flutter aligned side by side

问题 我有这些滑块,默认情况下它们显然是相互对齐的: class _Grid extends State<Grid> { var val = 5; @override build(BuildContext context){ return new Scaffold( appBar: new AppBar( title: new Text("Game"), backgroundColor: Colors.red, elevation: 1.0, ), body: new Container( child: new Column( mainAxisAlignment: MainAxisAlignment.center, children: [ new Slider( value: val.toDouble(), min: 1.0, max: 50.0, divisions: 50, label: '$val', onChanged: (double newValue) { setState(() { val = newValue.round(); }); }, ), new Slider( value: val.toDouble(), min: 1.0, max: 50.0, divisions: 50, label: '$val', onChanged: (double

2022-05-17 03:01:17    分类:技术分享    dart   flutter

Why im getting this error Warning: Operand of null-aware operation '??' has type 'Color' which excludes null

Im using this package flutter_datetime_picker: ^1.5.1 And this is my code String _date = "Please pick Age"; Widget _buildage() { return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Enter Age', style: kLabelStyle, ), SizedBox(height: 10.0), Container( decoration: kBoxDecorationStyle, alignment: Alignment.centerLeft, height: 70.0, child: Container( child: TextFormField( initialValue: "haaas", validator: (val) { if (val.isEmpty) { return 'Enter yout Age'; } if (val.length < 4) { return 'Enter a username minimun 4 chars long'; } return null; }, onChanged: (val) {

2022-05-03 11:53:26    分类:问答    flutter   date   dart   datetimepicker

Flutter onPressed() vs onTap()

I've been using Flutter for about 8 weeks. It's awesome, no question. However, there has been something bugging me since I've started, and that is, why do some widgets have an onTap method whilst others have onPressed? Google has not been able to give me any answers. If this is not relevant or on-topic enough for Stack Overflow, sorry about that, please point me to the right community to ask.

2022-05-03 09:02:21    分类:问答    flutter

The following assertion was thrown building StreamBuilder<QuerySnapshot>(dirty, state: _StreamBuilderBaseState<QuerySnapshot, AsyncSnapshot

I am getting this error in my multivendor applicaiton. When i add a new Product in the application. It goes to unpublished section and then you have to publish it from there. When i add a single product there is no problem ( I guess becuase it didnt happen with a single product.) But when i add the second product and go to unpublished page i get this error. ''' The following assertion was thrown building StreamBuilder<QuerySnapshot>(dirty, state: _StreamBuilderBaseState<QuerySnapshot, AsyncSnapshot<QuerySnapshot>>#c1af9): A non-null String must be provided to a Text widget. 'package:flutter

2022-05-03 09:00:39    分类:问答    android   firebase   flutter   dart   visual-studio-code

Space bar not working for a TextField in iPhone(Safari as well as Chrome) in Flutter Webapp

I have a Flutter Web app deployed on Firebase. On AndroidPhone/Laptop/Macbook everything is working fine whether it may be on Safari or Chrome. But on iOS, the space button does nothing when inputting text in a TextField. The issue is pretty similar to Flutter #79082, but this time it's on iPhone(iOS) only! Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel master, 2.3.0-13.0.pre.73, on Microsoft Windows [Version 10.0.19042.985], locale en-US) [√] Android toolchain - develop for Android devices (Android SDK version 30.0.3) [√] Chrome - develop for the web [√]

2022-05-03 08:56:09    分类:问答    ios   flutter   safari   flutter-web

Flutter preview icons showing broken asset image on code completion

When i first installed the flutter and dart extensions the icon preview was working alright, but when i developed in an environment where there was no wi-fi the icon preview broke. (Not sure that was the problem) I've tried reinstalling all flutter and dart related extensions but the problem still persists. I'd appreciate any suggestions P.D.: Working on VsCode 1.58.0 and MacOs 11.4

2022-05-03 08:27:36    分类:问答    flutter   dart   visual-studio-code

FutureBuilder runs twice

I have problems with FutureBuilder starting twice. First it fetch the data correctly, returning my StartScreen, then after few seconds, the StartScreen rebuilds and I noticed that the FutureBuilder fires again. Here is my code and it's pretty simple, so I wonder what may the problem be?!? class MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); } class _MyAppState extends State<MyApp> { FirebaseUser user; @override void initState() { // TODO: implement initState super.initState(); getNewestlocation(); } @override void dispose() { super.dispose(); } @override

2022-05-03 08:26:21    分类:问答    flutter   dart

animate show or hide widgets with flutter

i have something like this : import 'package:flutter/material.dart'; class MyWidget extends StatefulWidget { @override State<StatefulWidget> createState() { return _MyWidgetState(); } } class _MyWidgetState extends State<MyWidget> { bool loading = true; @override Widget build(BuildContext context) { if(loading) { return Container( color: Theme.of(context).scaffoldBackgroundColor, child: Center( child: SizedBox( width: 24, height: 24, child: GestureDetector( onTap: _toggle, child: CircularProgressIndicator(), ), ), ), ); } else { return Container( child: Center( child: GestureDetector( onTap:

2022-05-03 08:24:45    分类:问答    flutter