我有一个创建了一个主页与应用程序栏,底部导航栏,和一个下拉菜单。当我用它创建一个容器盒时,它没有出现在我的屏幕上。要么它覆盖了屏幕,要么它超过了像素,并走到了最右边。有人给予我一个解决方案和代码,并告诉我在哪里添加它请!(我已经添加了两个图像也下面一个我如何想和另一个我如何得到)
Expanded(child: Container(
margin: EdgeInsets.all(10),
padding: EdgeInsets.all(10),
alignment: Alignment.center,
decoration: BoxDecoration(
color: Colors.indigo,
borderRadius: BorderRadius.all(
Radius.circular(10.0)),
),
child: Text("\$27693.78"),
),
),
THIS IS THE CODE I GAVE FOR CONTAINER, THE WHOLE CODE FOR THE PAGE IS GIVEN BELOW
import 'package:flutter/material.dart';
class dashboard extends StatefulWidget {
const dashboard({super.key});
@override
State<dashboard> createState() => _dashboardState();
}
class _dashboardState extends State<dashboard> {
int index=0;
final screens = [
Center(child: Text('DASHBOARD', style: TextStyle(fontSize: 25))),
Center(child: Text('POS', style: TextStyle(fontSize: 25))),
Center(child: Text('ITEMS', style: TextStyle(fontSize: 25))),
Center(child: Text('LIMITED STOCKS', style: TextStyle(fontSize: 25))),
];
int _value = 1;
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(appBar:
AppBar(
backgroundColor: Colors.white,
title: Text(''),
actions: <Widget>[
Icon(
Icons.shopping_cart_outlined,
color: Colors.indigo,
),
Padding(padding: EdgeInsets.all(20)),
Icon(
Icons.list,
color: Colors.indigo,
),
Padding(padding: EdgeInsets.all(10)),
],
),
body :Row (
children: <Widget>[Row
(children:
[Image.asset('assets/increase.png', width: 30,),
('Revenue Statistics',
style: TextStyle(
color: Colors.black,fontSize: 20,fontWeight: FontWeight.bold
),
),],),
Padding(padding: const EdgeInsets.only(left: 50, bottom: 25,)
),
Expanded(child: DropdownButton(
value: _value,
items: [
DropdownMenuItem(
child: Text('Overall'),
value: 1,
),
DropdownMenuItem(
child: Text('OverallA'),
value: 2,
),
],
onChanged: ( value){
setState(() {
_value = _value;
});
},
hint: Text('Select item'),
),
),
Padding(padding: EdgeInsets.only(left: 1)),
DecoratedBox(decoration:BoxDecoration(
borderRadius:BorderRadius.circular(5),
),
),
Expanded(child: Container(
margin:EdgeInsets.all(10),
padding:EdgeInsets.all(10),
alignment:Alignment.center,
decoration:BoxDecoration
(color:Colors.indigo,
borderRadius: BorderRadius.all(
Radius.circular(10.0)),
),
child: Text("\$27693.78"),
),
),
],
),
bottomNavigationBar:
NavigationBarTheme(
data: NavigationBarThemeData(
indicatorColor: Colors.indigo,
labelTextStyle: MaterialStateProperty.all(
TextStyle(fontSize: 14,fontWeight: FontWeight.w500,color: Colors.grey),
),
),child:
selectedIndex: index,
onDestinationSelected: (index)=>
setState(() => this.index = index),
destinations: [
NavigationDestination(
icon: Icon(Icons.dashboard),
label: 'Dashboard',
),
NavigationDestination(
icon: Icon(Icons.point_of_sale),
label: 'pos',
),
NavigationDestination(
icon: Icon(Icons.list),
label: 'items',
),
NavigationDestination(
icon: Icon(Icons.inventory),
label:
'limitedstocks',
),
],
),),
floatingActionButton: FloatingActionButton(
onPressed: (){},
child: Icon(
Icons.qr_code_scanner,
color: Colors.white,
),
backgroundColor: Colors.indigo,
tooltip: 'Scan QR',
elevation: 5,
),
floatingActionButtonLocation:FloatingActionButtonLocation.centerFloat,
),
);
}
}
1条答案
按热度按时间xj3cbfub1#
以下是更新的代码:
请停止使用填充部件之间添加空间,您可以使用SizedBox,如果您想给予填充和部件,然后添加挂起的小部件,并在孩子中添加小部件。
类名称应该是CamelCase。