flutter-layout

Add a prefix to every line in a multiline Text Input in Flutter?

北城余情 提交于 2021-01-28 18:54:53
问题 I wanted to know if there was a way of adding a prefix (like "- ") to every line in a multiline Text Input in Flutter. For example: Hello World! Would become: -Hello -World! This is my code: TextField( maxLines: null, controller: _elementsController, textCapitalization: TextCapitalization.sentences, style: TextStyle( fontSize: 18.0, ), decoration: InputDecoration( contentPadding: EdgeInsets.all(0.0), labelText: 'Elements', ), ), 回答1: U can add a - everytime a new line is created. Add this in

ShaderMask LinearGradient's stops strange behavior

冷暖自知 提交于 2021-01-28 12:35:14
问题 I want to fade both side (edges) of a content. I use a ShaderMask along with a LinearGradient , it works great except that I don't understand why my stops are not centered correctly, I use stops: [0.0, 0.05, 0.95, 1.0] so that it should be faded 0.05 on each side, but I get the following (I added a Container gradient with same configuration for comparison): With debug paint mode : I use exactly the same stops for the Container and for the ShaderMask but get different results. Of course I can

ShaderMask LinearGradient's stops strange behavior

北城以北 提交于 2021-01-28 12:30:40
问题 I want to fade both side (edges) of a content. I use a ShaderMask along with a LinearGradient , it works great except that I don't understand why my stops are not centered correctly, I use stops: [0.0, 0.05, 0.95, 1.0] so that it should be faded 0.05 on each side, but I get the following (I added a Container gradient with same configuration for comparison): With debug paint mode : I use exactly the same stops for the Container and for the ShaderMask but get different results. Of course I can

async/await to do CircularProgressIndicator in a Login Page in Flutter

时光总嘲笑我的痴心妄想 提交于 2021-01-28 11:40:46
问题 I am facing problems with the CircularProgressIndicator in a login page. I would like to do this. When the users tap in "log in" button I want that the app makes a CircularProgressIndicator and kick the raisedButton Text and add the CircularProgessIdnicator, and after that my app get the data from my webservice I want to stop the CircularProgessIndicator. Any Tips? thanks. Actual Code (you can compile it without problems just add http: ^0.12.0 in dependencies). Photos of the actual system:

What is the equivalent code in flutter for “ mAdapter.notifyDataSetChanged();”;

邮差的信 提交于 2021-01-28 08:35:42
问题 Befor HTTP response show loading and after https response create tab view. I successfully create tab view but my problem is after HTTP request unable to update the view in the android studio with java we use `mAdapter.notifyDataSetChanged(); mActivity.runOnUiThread(new Runnable() { @Override public void run() { } });` code for doing this. what is the equivalent code in the flutter? 回答1: If you want update any widget in flutter you should call setState((){}) class MyApp extends StatefulWidget

Text widget softWrap not working in nested row-column-row in Flutter

谁都会走 提交于 2021-01-28 04:32:20
问题 I am trying to wrap the text ' Awesome somthing very long text which should ideally soft warp ' in the blow code. Tried using Flexible and Expanded , did not work. It's getting tough to have softWrap working in nested row column scenarios :( import 'package:flutter/material.dart'; import 'package:sample/models/Reward.dart'; class RewardDetailsView extends StatelessWidget { final Reward _reward; RewardDetailsView(this._reward); @override Widget build(BuildContext context) { return Scaffold(

How do i add more items on scroll in the listview?

落花浮王杯 提交于 2021-01-28 01:19:29
问题 This code here currently loads all the brews that are stored in the Firestore collection.. How can i load initially just 10 brews and then later on when the user scrolls down and reaches to the end of the list of 10 brews..it should load 10 more after the last brew..and the brews should be sorted according to the timestamp. class BrewList extends StatefulWidget { @override _BrewListState createState() => _BrewListState(); } class _BrewListState extends State<BrewList> { List<Brew> brews = [];

How to highlight only numbers and special characters inside Text in Flutter?

試著忘記壹切 提交于 2021-01-27 23:08:16
问题 I'm trying to highlight any numbers & special characters like '%' from a String that comes dynamically from JSON. This is my current implementation but I can't understand how to change it dynamically. RichText( overflow: TextOverflow.ellipsis, textAlign: TextAlign.center, maxLines: 4, text: TextSpan( children: <TextSpan>[ TextSpan( text: 'Hey I\'m', style: TextStyle( color: kDarkBlue, fontSize: 21)), TextSpan( text: '1234 ', style: TextStyle( fontWeight: FontWeight.w800, fontSize: 24)),

Flutter: Is there a widget to flex toggle buttons

时光毁灭记忆、已成空白 提交于 2021-01-27 20:09:31
问题 So I'm the ToggleButtons introduced in 1.9.1 like this: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Padding(padding: EdgeInsets.only(top: 8),), Text('Sort By: '), Align( alignment: Alignment.topLeft, child: ToggleButtons( borderColor: Color(0xffED7D31), selectedBorderColor: Color(0xffED7D31), selectedColor: Color(0xffAD7651), fillColor: Color(0xffFBE5D6), color: Color(0xffBF987E), children: <Widget>[ ...state.sortBy

Flutter Web: Stack and Flare Issue

随声附和 提交于 2021-01-27 19:40:53
问题 I was trying to create a simple web page on Flutter Web (dev channel - v1.13.2) and this weird issue occured. When I tried to place a Flare animation in stack widget which have 2 additional widget, a background and a centered text respectively, the Flare didn't seems to appear. But when I remove the background container, flare works and positioned perfectly. Here is the code; import 'package:flutter/material.dart'; import "package:flare_flutter/flare_actor.dart"; void main() => runApp(MyApp()