flutter-layout

How to set border radius to bottom app bar in a flutter app?

早过忘川 提交于 2019-12-24 23:26:24
问题 I want to set the borderRadius to an Bottom Navigation App Bar as its shown in the image. I have tried to put Bottom Navigation App Bar to a ClipRRect borderRadius and in a Container decoration but it didn't worked. So how can I apply the topLeft, and topRight border radius to my bottom navigation bar. Kindly help to let me know how can I do it? main.dart void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp(

Flutter hot reloading is not working to display changes

こ雲淡風輕ζ 提交于 2019-12-24 18:54:16
问题 I have two files, main.dart and sections.dart . I have defined a few widgets in section.dart and used them in main.dart file, when I run flutter run command changes are displayed on screen, but when I press R to hot reload, nothing changes on screen. main.dart: import 'package:flutter/material.dart'; import 'sections.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false

Flutter invalid refrence to 'this' expression

陌路散爱 提交于 2019-12-24 18:50:25
问题 i am trying to add item in list when i click on add button, all code is ok, but i am getting error invalid reference to this expression. i am using stateful widget. List<Widget> _listSection = []; body: Container( child: Stack( children: [ FloatingActionButton( onPressed: () { _listSection.add( listSectionMethod( "title three", "hello from click", Icons.forward), ); setState(() {}); }, ), ], ), ), ), ); } } Widget listSection = Container( margin: EdgeInsets.only(top: 210), child: ListView(

Share dimensions between widgets

拈花ヽ惹草 提交于 2019-12-24 16:42:34
问题 In Flutter we can use Themes to share colors and font styles. https://flutter.io/docs/cookbook/design/themes Is there an existing best practice that we can use in a similar manner share values such as margins, paddings and widths or heights? Preferably something that helps stick to the material design guidelines. 回答1: Defining custom widgets The easiest and probably most elegant approach is to define custom widgets, like a MyRaisedButton that internally uses the RaisedButton with the right

Flutter Set State onPressed on RaisedButton

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-24 15:29:07
问题 I am building a quiz app which reveals the explanation for the correct answer after the user submits their chosen answer. There are two buttons on the layout -- "Next Question" & "Submit Answer." In the initial state, the "Next Question" button is subtle as it is not clickable and only the "Submit Answer" buttons is clickable. Click Here to View the Layout of the Initial State When the "Submit Answer" button is clicked, two actions should happen: 1. The "Submit Answer" button then becomes

Specific min and max size for expanded widgets in Column

情到浓时终转凉″ 提交于 2019-12-24 08:59:14
问题 I have a Column with a set of Expanded widgets. Is there a way to control the range in which they expand? I want one widget to expand only to a certain size and make the rest available to other widgets. EDIT: Because I got two probably misleading answers, I’d like to clarify. I want something like this: Expanded(flex: 1, minSize: 50, maxSize: 200, child: ...) That means that this expanded widget takes a flex of 1, but should never be smaller than 50 and bigger than 200. 回答1: You are looking

Flutter expand Container to fill remaining space of Row

我们两清 提交于 2019-12-24 03:52:28
问题 I have one image in a row and a text next to that image. I want the row to expand fully and image takes as its size, then remain full area should be taken by Container. Here is my code snippet: Row( children: <Widget>[ Container( margin: EdgeInsets.fromLTRB(10, 50, 10, 8), decoration: BoxDecoration( color: Colors.white, boxShadow: [ BoxShadow( color: Color.fromARGB(100, 0, 0, 0), blurRadius: 5, ), ], ), child: Row( mainAxisSize: MainAxisSize.max, children: <Widget>[ Column(children: <Widget>[

How to make a Widget to be as small as it can (wrap_content in Android)?

那年仲夏 提交于 2019-12-24 03:45:39
问题 I have a rendering issue with render tree similar to Column > PageView > Column , where the last Column is inside a page of the PageView . The PageView isn't being rendered correctly, so I get an exception ( Horizontal viewport was given unbounded height. ) as the framework can't calculate its sizes, I can fix it by wrapping it into a Flexible or an Expanded , but I don't want the PageView to take the whole screen, I want it to be as small as possible and on the center on the screen. Here's a

How can I color part of a text for UI in dart/flutter?

孤街浪徒 提交于 2019-12-23 22:25:02
问题 How can I change the color of part of a text? I'm trying to make it so the text says " Don't have an account? Register now! " but I want to add a color to the Register now! part. How can I do this if possible? image 回答1: Use RichText https://docs.flutter.io/flutter/widgets/RichText-class.html RichText( text: TextSpan( text: "Don't have an account? ", style: TextStyle(color: Colors.black, fontSize: 40), children: <TextSpan>[ TextSpan(text: ' Register now!', style: TextStyle(color: Colors.red))

how to give my list view width to full screen width and how to make it auto scroll

↘锁芯ラ 提交于 2019-12-23 04:28:05
问题 how to give my list view width to full screen width and how to make it auto scroll after few second ... void scrollAfter(ScrollController scrollController, {int seconds}) { Future.delayed(Duration(seconds: seconds), () { var offset = 550.0; var scrollDuration = Duration(seconds: 2); scrollController.animateTo(offset, duration: scrollDuration, curve: Curves.ease); }); } @override Widget build(BuildContext context) { var scrollController = ScrollController(); scrollAfter(scrollController,