接受一个 ThemeData 对象theme:ThemeData(primarySwatch:Colors.blue),// 应用的首页home:Scaffold(appBar:AppBar(backgroundColor:Colors.blue,title:constText('首页'),centerTitle:true,),body:Stack(alignment:Alignment.center,children:<Widget>[Container(width:300,height:300,color:Colors.red,),Container(width...
比如,你可以这么做: @override Widget build(BuildContext context) { final size = MediaQuery.of(context).size; final height = size.height; final width = size.width; return Scaffold( appBar: AppBar( title: const Text("Responsive Layout"), ), body: Container( color: Colors.pinkAccent, child:...
方案一:直接使用MaterialButton 我们看下MaterialButton中提供了2个属性:minWidth和height,我们直接设置这2个属性的宽度或者高度就可以,如果想宽度占满全屏可以直接设置成double.infinity,如下: MaterialButton( onPressed: (){},child:Text("宽度占满了"),minWidth:double.infinity,height:50.0,color:Colors.green,text...
import'package:flutter/material.dart';voidmain(){runApp(MyApp());}classMyAppextendsStatelessWidget{@overrideWidgetbuild(BuildContextcontext){returnMaterialApp(home:Scaffold(appBar:AppBar(title:Text('Screen Adaptation Example')),body:Center(child:Container(width:200,// 逻辑像素宽度height:100,// 逻辑像...
1.4.2 布局组件 // Container - 容器组件Container(width:200,height:200,padding:EdgeInsets.all(16),margin:EdgeInsets.symmetric(vertical:8),decoration:BoxDecoration(color:Colors.blue,borderRadius:BorderRadius.circular(8),boxShadow:[BoxShadow(color:...
"),//appbar的title),body:Center(//脚手架的第二个组成是body 给body一个center组件做内容child:Container(height:400.0,width:300.0,//color: Colors.pinkAccent,margin:EdgeInsets.symmetric(horizontal:010.0),decoration:newBoxDecoration(gradient:constLinearGradient(colors:[Colors.lightBlue,Colors.green],begin...
classHomePageextendsStatelessWidget{constHomePage({super.key});@overrideWidgetbuild(BuildContext context){finalsize=MediaQuery.of(context).size;returnContainer(width:300,height:300,color:Colors.red,child:constAlign(alignment:Alignment.center,child:Text("你好 Flutter"),));}} ...
draggable_container v1.0.7+2 A Very Smooth Draggable Widget Container. Each children is Draggable, Deletable and Fixable. Support SliverGridDelegate! License: MIT License Platform: android, ios, windows, linux, macos, web Published: 2021-04-03T20:23:04.511923Z Total: 1 w_popup_menu v1.0...
所以对于设置 GestureDetector 的 Container,如果没有设置 color 属性,那么点击空白不会回调。 2. 设置 GestureDetector 的 behavior 属性(推荐方式) 其实如果你需要空白区域也响应点击,只需要设置一下 GestureDetector 的 behavior 属性即可。 behavior默认值为HitTestBehavior.deferToChild,我们这里将其设置为HitTestBehavior...
Container( width: double.infinity, height: double.infinity, child: new IndexedStack( index: 0, alignment: Alignment.center, children: <Widget>[ Image.network("https://www.itying.com/images/flutter/list1.jpg",fit: BoxFit.cover,), Image.network("https://www.itying.com/images/flutter/list2...