我想使用Stack
和Positioned
小部件,认为这将是一个响应式设计的默认情况下,我甚至尝试了Sizer
插件,但由于某种原因,我无法创建一个真正的响应式设计,我的小部件在不同的屏幕上到处都是
请看一下我的代码
@override
Widget build(BuildContext context) {
super.build(context);
return Stack(
children: [
Googlelutter(mapKey: _mapKey, osmController: osmController),
Positioned(
top: 60.0,
left: 0.0,
right: 0.0,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: EdgeInsets.symmetric(horizontal: 16.0),
child: Consumer<AppData>(
builder: (ctx, dsc, child) => (ElevatedButton(
style: ElevatedButton.styleFrom(
shape: const RoundedRectangleBorder(
borderRadius:
BorderRadius.all(Radius.circular(50))),
backgroundColor: dsc.driverStatusClr),
// color: dsc.driverStatusClr,
onPressed: () async {
if (isDriverAvailable != true) {
isDriverAvailable = true;
makeDriverOnlineNow();
getLocationLiveUpdates();
Provider.of<AppData>(context, listen: false)
.buttonOnline(Colors.green.shade300, "Online");
await UserSimplePrefences.setButtonStatus(false);
// });
displayToastMessage("You are Online now", context);
} else {
Provider.of<AppData>(context, listen: false)
.buttonOnline(Colors.black54, "Offline");
driverOffline();
IsolateNameServer.removePortNameMapping(_isolateName);
BackgroundLocator.unRegisterLocationUpdate();
displayToastMessage("You are Offline now", context);
isDriverAvailable = false;
await UserSimplePrefences.setButtonStatus(true);
onStop();
}
},
child: Padding(
padding: EdgeInsets.all(17),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
dsc.driverStatusTxt,
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold,
color: Colors.white),
),
Icon(
Icons.phone_android,
color: Colors.white,
size: 26,
)
],
),
),
)),
),
),
],
),
),
Positioned(
top: 700.0,
right: 22.0,
child: GestureDetector(
onTap: () {
osmController.currentLocation();
},
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(22.0),
boxShadow: [
BoxShadow(
color: Colors.black,
blurRadius: 6.0,
spreadRadius: 0.5,
offset: Offset(
0.7,
0.7,
),
)
]),
child: CircleAvatar(
backgroundColor: Colors.white,
child: Icon(
Icons.location_on,
color: Colors.black,
),
radius: 20.0,
),
),
),
),
Positioned(
top: 100.0,
right: 22.0,
child: GestureDetector(
onTap: () async {
//FirebaseAuth.instance.signOut();
await osmController.enableTracking();
},
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(22.0),
boxShadow: [
BoxShadow(
color: Colors.black,
blurRadius: 6.0,
spreadRadius: 0.5,
offset: Offset(
0.7,
0.7,
),
)
]),
child: CircleAvatar(
backgroundColor: Colors.white,
child: Icon(
Icons.track_changes,
color: Colors.black,
),
radius: 20.0,
),
),
),
),
],
);
}
然后告诉我该怎么修
1条答案
按热度按时间4c8rllxm1#
就像这样......相对于设备的高度和宽度。
}