Image 减少颤振中的前导和标题之间的间距
我正试图减少前导和标题之间的空间,即注释图像和注释标题 我的代码是:Image 减少颤振中的前导和标题之间的间距,image,flutter,size,padding,flutter-drawer,Image,Flutter,Size,Padding,Flutter Drawer,我正试图减少前导和标题之间的空间,即注释图像和注释标题 我的代码是: drawer: Drawer( child: ListView( padding: EdgeInsets.zero, children: [ Container( height: 110, child: DrawerHeader( child: Text(
drawer: Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: [
Container(
height: 110,
child: DrawerHeader(
child: Text(
'My Secret Diary',
style: TextStyle(
fontSize: 35,
fontWeight: FontWeight.bold,
fontFamily: 'madelyn'),
),
decoration: BoxDecoration(
color: Colors.greenAccent,
),
),
),
Container(
//decoration : BoxDecoration( border: Border.all(color: Colors.black, width: 1)),
child: ListTile(
selectedTileColor: Colors.blue,
leading: Image.asset('assets/images/notes.png' , width: 25, height: 25, fit: BoxFit.cover,),
title: Text(
'Notes',
style: TextStyle(fontFamily: 'alkes', fontSize: 18),
),
),
)
],
),
),
全部代码:
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
// This makes the visual density adapt to the platform that you run
// the app on. For desktop platforms, the controls will be smaller and
// closer together (more dense) than on mobile platforms.
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Notes'),
);
}
}
class MyHomePage extends StatelessWidget {
MyHomePage({Key key, this.title}) : super(key: key);
// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.
// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".
final String title;
GlobalKey<ScaffoldState> _scaffoldkey = GlobalKey<ScaffoldState>();
@override
Widget build(BuildContext context) {
// TODO: implement build
return Scaffold(
key: _scaffoldkey,
drawer: Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: [
Container(
height: 110,
child: DrawerHeader(
child: Text(
'My Secret Diary',
style: TextStyle(
fontSize: 35,
fontWeight: FontWeight.bold,
fontFamily: 'madelyn'),
),
decoration: BoxDecoration(
color: Colors.greenAccent,
),
),
),
Container(
//decoration : BoxDecoration( border: Border.all(color: Colors.black, width: 1)),
child: ListTile(
selectedTileColor: Colors.blue,
leading: Image.asset('assets/images/notes.png' , width: 25, height: 25, fit: BoxFit.cover,),
title: Text(
'Notes',
style: TextStyle(fontFamily: 'alkes', fontSize: 18),
),
),
)
],
),
),
body: ListView(
children: <Widget>[
SizedBox(height: 20.0),
Padding(
padding: EdgeInsets.symmetric(horizontal: 15.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
GestureDetector(
child: Container(
height: 35.0,
width: 35.0,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/hamburger.png')),
borderRadius: BorderRadius.circular(10.0),
),
),
onTap: () {
_scaffoldkey.currentState.openDrawer();
},
),
SizedBox(width: 20.0),
Text(
'Notes',
style: TextStyle(
fontSize: 28.0,
fontWeight: FontWeight.bold,
fontFamily: 'futuram'),
)
],
),
),
],
),
);
throw UnimplementedError();
}
}
导入“包装:颤振/材料.省道”;
void main(){
runApp(MyApp());
}
类MyApp扩展了无状态小部件{
//此小部件是应用程序的根。
@凌驾
小部件构建(构建上下文){
返回材料PP(
标题:“颤振演示”,
主题:主题数据(
//这是应用程序的主题。
//
//尝试使用“flutter run”运行应用程序。您将看到
//应用程序有一个蓝色工具栏。然后,在不退出应用程序的情况下,重试
//将下面的primarySwatch更改为Colors.green,然后调用
//“热重新加载”(在运行“颤振运行”的控制台中按“r”,
//或者只需将更改保存到颤振IDE中的“热重新加载”。
//请注意,计数器没有重置回零;应用程序
//未重新启动。
主样本:颜色。蓝色,
//这使视觉密度适应您运行的平台
//上的应用程序。对于桌面平台,控件将更小且更简单
//比移动平台更紧密(密度更高)。
视觉密度:视觉密度。自适应平台密度,
),
主页:我的主页(标题:“备注”),
);
}
}
类MyHomePage扩展了无状态小部件{
MyHomePage({Key,this.title}):超级(Key:Key);
//此小部件是应用程序的主页。它是有状态的,表示
//它有一个状态对象(定义如下),其中包含影响
//看起来怎么样。
//此类是状态的配置。它保存值(在此
//案例名称)由家长(在本例中为应用程序小部件)提供,以及
//由State的build方法使用。小部件子类中的字段包括
//始终标记为“最终”。
最后的字符串标题;
GlobalKey _scaffoldkey=GlobalKey();
@凌驾
小部件构建(构建上下文){
//TODO:实现构建
返回脚手架(
钥匙:_scaffoldkey,
抽屉(
子:ListView(
填充:EdgeInsets.zero,
儿童:[
容器(
身高:110,
儿童:抽屉阅读器(
子:文本(
“我的秘密日记”,
样式:TextStyle(
尺码:35,
fontWeight:fontWeight.bold,
fontFamily:“madelyn”),
),
装饰:盒子装饰(
颜色:Colors.greenAccent,
),
),
),
容器(
//装饰:框装饰(边框:border.all(颜色:Colors.black,宽度:1)),
孩子:ListTile(
selectedTileColor:Colors.blue,
前导:Image.asset('assets/images/notes.png',宽度:25,高度:25,适合度:BoxFit.cover,),
标题:正文(
“注意事项”,
样式:TextStyle(fontFamily:'alkes',fontSize:18),
),
),
)
],
),
),
正文:ListView(
儿童:[
尺寸箱(高度:20.0),
填充物(
填充:边缘组。对称(水平:15.0),
孩子:排(
mainAxisAlignment:mainAxisAlignment.start,
儿童:[
手势检测器(
子:容器(
身高:35.0,
宽度:35.0,
装饰:盒子装饰(
图像:装饰图像(
图片:AssetImage('assets/images/hamburger.png'),
边界半径:边界半径。圆形(10.0),
),
),
onTap:(){
_scaffoldkey.currentState.openDrawer();
},
),
尺寸箱(宽度:20.0),
正文(
“注意事项”,
样式:TextStyle(
字体大小:28.0,
fontWeight:fontWeight.bold,
fontFamily:‘futuram’,
)
],
),
),
],
),
);
抛出未实现的错误();
}
}
在Align
小部件中包装您的listile
标题
ListTile(
selectedTileColor: Colors.blue,
leading: Image.asset('assets/images/notes.png' , width: 25, height: 25, fit: BoxFit.cover,),
title: Align(
alignment: Alignment(-5.0, 0), // change -5.0 to your preferred value
child: Text(
'Notes',
style: TextStyle(fontFamily: 'alkes', fontSize: 18),
),
),
// ...
),