Reputation: 5032
hello I tried to make a geofencing responsive, I have a stack of google map url and a circle. this code is OK :
new Card(
elevation: 2.0,
child: new Stack(
alignment: AlignmentDirectional.center,
children: <Widget>[
new Container(
child: new Image.network(staticMapUri.toString()),
),
new Container(
alignment: new FractionalOffset(0.0, 0.0),
decoration: new BoxDecoration(
shape: BoxShape.circle,
color: Colors.lightBlue.withOpacity(0.5),
),
child:
new AspectRatio(
aspectRatio: MediaQuery.of(context).size.longestSide/GPS2,
child :
FractionalTranslation(
translation: Offset(0.0, 0.0),
child: new Container(
),
),
),
),
new Container(
//padding: const EdgeInsets.only(bottom:10.0),
margin: new EdgeInsets.all(140.0),
child : Icon(Icons.location_on, color: Colors.white, size: 25.0),
),
],
),
),
But I search to replace GPS2 to be dynamics with slider value so here is the code :
new Slider(
value: valperimetre,
onChanged: (double e) => change(e),
activeColor: Colors.lightBlue,
inactiveColor :Colors.grey,
divisions: 10,
label: "$valperimetre""m",
max : 500.0,
min: 0.0,
),
new Card(
elevation: 2.0,
child: new Stack(
alignment: AlignmentDirectional.center,
children: <Widget>[
new Container(
child: new Image.network(staticMapUri.toString()),
),
new Container(
alignment: new FractionalOffset(0.0, 0.0),
decoration: new BoxDecoration(
shape: BoxShape.circle,
color: Colors.lightBlue.withOpacity(0.5),
),
child:
new AspectRatio(
aspectRatio: MediaQuery.of(context).size.longestSide/valperimetre,
child :
FractionalTranslation(
translation: Offset(0.0, 0.0),
child: new Container(
),
),
),
),
new Container(
//padding: const EdgeInsets.only(bottom:10.0),
margin: new EdgeInsets.all(140.0),
child : Icon(Icons.location_on, color: Colors.white, size: 25.0),
),
],
),
),
but currently I have this error :" if I rebuild the app normaly : failed assertion:line 399 pos 15:'aspectRatio.isFinite': is not true." If I replace valperimetre by 100.0, after rebuild app, and after I replace 100.0 by valperimetre and I hotreload it's OK.
Upvotes: 0
Views: 414
Reputation: 831
Try Putting this condition check inside your code.
//your code here
child:(valperimetre == 0.0 || valperimetre == null) ?
Container()
:new AspectRatio(
aspectRatio: MediaQuery.of(context).size.longestSide/valperimetre,
//your code here
Upvotes: 1