flutter-layout

Dynamically created checkbox in flutter not changing the state on clicked

三世轮回 提交于 2020-02-05 03:50:06
问题 I am creating a checkbox field every time i press a button. but the generated checkbox is not changing the state when pressed, instead the next checkbox which is generated comes with the changed state. I have attached the video of how it is working currently (https://imgur.com/a/75vE5cj ) my entire code goes like this : class ToDoNotes extends StatelessWidget { @override Widget build(BuildContext context) { SizeConfig().init(context); return new MaterialApp( title: 'notes', theme: new

Sizing a container to exact half the screen size in flutter

大兔子大兔子 提交于 2020-02-03 08:56:45
问题 I am trying to get a container to be exactly half the screen height[after considering the AppBar height] and half the screen width. This is what I came up with... class App extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(), body: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Flexible( child: Container( width: MediaQuery.of(context).size.width / 2, color: Colors.red, ), ), Flexible( flex: 1, child: Container()

Sizing a container to exact half the screen size in flutter

狂风中的少年 提交于 2020-02-03 08:55:06
问题 I am trying to get a container to be exactly half the screen height[after considering the AppBar height] and half the screen width. This is what I came up with... class App extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(), body: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Flexible( child: Container( width: MediaQuery.of(context).size.width / 2, color: Colors.red, ), ), Flexible( flex: 1, child: Container()

How to define discrete animation in Flutter?

半城伤御伤魂 提交于 2020-02-02 12:34:48
问题 Is it possible to create an animation in flutter that doesn't continously change its value, but only with a given time gaps? I have the following code working right now, but i'm sure there is a better solution out there. int aniValue = 0; bool lock = false; _asyncFunc() async { if(lock) return; else lock = true; await new Future.delayed(const Duration(milliseconds: 50), () { ++aniValue; if (aniValue == 41) { aniValue = 0; } }); lock = false; setState(() {}); _asyncFunc(); } 回答1: It is

How to define discrete animation in Flutter?

杀马特。学长 韩版系。学妹 提交于 2020-02-02 12:34:26
问题 Is it possible to create an animation in flutter that doesn't continously change its value, but only with a given time gaps? I have the following code working right now, but i'm sure there is a better solution out there. int aniValue = 0; bool lock = false; _asyncFunc() async { if(lock) return; else lock = true; await new Future.delayed(const Duration(milliseconds: 50), () { ++aniValue; if (aniValue == 41) { aniValue = 0; } }); lock = false; setState(() {}); _asyncFunc(); } 回答1: It is

when i use margin ,it work fine,container is going up but its taking a lot of space on screen,there are two blue line

怎甘沉沦 提交于 2020-01-26 04:40:09
问题 Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Container( margin: EdgeInsets.only(bottom: 400.0), child: Center( child: Padding( padding: EdgeInsets.symmetric(horizontal: 10.0), child: Text( _text, style: TextStyle(color: Colors.white), ), ), ), ), ... 来源: https://stackoverflow.com/questions/59777112/when-i-use-margin-it-work-fine-container-is-going-up-but-its-taking-a-lot-of-sp

How can I add a Button on bottom of SliverAppBar and make it overlap on ExtentList?

試著忘記壹切 提交于 2020-01-25 06:52:30
问题 I've try to put a Column(a Container inside) in SliverAppBar bottom property as a button, but it can't overlap the ExtentList ,just overflow the bottom margin. I want to make it overlapped just like Spotify App do. this is Spotify Sample: https://imgur.com/VrZRY4c this is what I've tried: https://imgur.com/4bNZw8j My code: class _MenuListState extends State<MenuList> { @override Widget build(BuildContext context) { return Scaffold( body: CustomScrollView( slivers: <Widget>[ SliverPadding(

How to keep the widget's state in Scaffold.drawer in Flutter?

拥有回忆 提交于 2020-01-25 00:05:15
问题 I want to keep the widget's state in Scaffold.drawer . The Scaffold.drawer is a custom widget, which has a RaiseButton in it. When click the button, the text in the button changed. But when the drawer is closed, and reopen the drawer, the changed text is reseted. I have use " with AutomaticKeepAliveClientMixin<> " in my custom Drawer , but it does't work. import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build

Flutter TextField width should match width of contained text

左心房为你撑大大i 提交于 2020-01-24 17:33:29
问题 In flutter, TextField doesn't have an intrinsic width; it only knows how to size itself to the full width of its parent container. How do I set the width to the width of the contained text. I tried putting the TextField inside a container As outlined here How to update flutter TextField's height and width? new Container( width: 100.0, child: new TextField() ) I expect the width of the TextField to match the width of the text it contains. The TextField should grow wider as text is typed, and

Flutter: Keyboard overflow with My Dialog

本小妞迷上赌 提交于 2020-01-24 12:43:05
问题 I'am trying to add TextField to a Dialog, but when the Keyboard appears, it gives an overflow. My dialog Image When the Keyboard shows up Here How a part my code looks Like: AlertDialog( content: new ListView( shrinkWrap: true, children: <Widget>[ Text( "How Would You Rate Our App?", style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold), textAlign: TextAlign.center, ) 回答1: You can simply use SingleChildScrollView: AlertDialog( content: SingleChildScrollView( scrollDirection: Axis