flutter-layout

Best practice for effectively scale this UI according to different screen sizes in Flutter

旧时模样 提交于 2020-05-24 05:21:14
问题 I'm doing a UI in flutter and right now it look great on my emulator but I'm afraid it will break if screen size is different. What is the best practice to prevent this, especially using gridview. Here is the UI I'm trying to do (only the left part for now) : The code I have right now that is working. Each item is in a Container and 2 of them are a Gridview : Expanded( child: Container( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ SizedBox(height: 100),

How to animate Alert dialog position in Flutter?

▼魔方 西西 提交于 2020-05-23 13:00:53
问题 By this simple code I can show dialog on bottom of screen like with this screenshot: But I have three simple issue: set margin on bottom of dialog such as 20.0 on showing dialog using controller.reverse() on dismiss dialog dismiss dialog on click on outside of dialog Full source code: 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

How to make this type of layout using grid layout in flutter

走远了吗. 提交于 2020-05-23 10:56:29
问题 Multiple grid layouts in one screen 回答1: Just a ListView with GridViews inside, and don't forget the shrinkWrap true for the GridViews class MultipleGridView extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( body: ListView( children: <Widget>[ Text("Title 1"), GridView.builder( physics: NeverScrollableScrollPhysics(), shrinkWrap: true, gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 5, crossAxisSpacing: 5.0, mainAxisSpacing: 5.0

Reload data when using FutureBuilder

非 Y 不嫁゛ 提交于 2020-05-23 08:13:09
问题 I am loading data when widget is loading like the code below. Once the UI is fully loaded, I like to add one refresh button to reload the data again. How can I refresh the view ? class _MyHomePageState extends State<MyHomePage> { @override Widget build(BuildContext context) { var futureBuilder = new FutureBuilder( future: _getData(), builder: (BuildContext context, AsyncSnapshot snapshot) { switch (snapshot.connectionState) { case ConnectionState.none: case ConnectionState.waiting: return new

How can we change appbar background color in flutter

橙三吉。 提交于 2020-05-22 20:37:10
问题 I am trying to set a common theme for app so I need to change appbar color as a color that indicates hex code #0f0a1a const MaterialColor toolbarColor = const MaterialColor( 0xFF151026, const <int, Color>{0: const Color(0xFF151026)}); I try this piece of code to make a custom color but fails. How can I do this from themeData ? 回答1: declare your Color like this const PrimaryColor = const Color(0xFF151026); and then in the MaterialApp level( will change the AppBar Color in the whole app )

How can we change appbar background color in flutter

大兔子大兔子 提交于 2020-05-22 20:32:14
问题 I am trying to set a common theme for app so I need to change appbar color as a color that indicates hex code #0f0a1a const MaterialColor toolbarColor = const MaterialColor( 0xFF151026, const <int, Color>{0: const Color(0xFF151026)}); I try this piece of code to make a custom color but fails. How can I do this from themeData ? 回答1: declare your Color like this const PrimaryColor = const Color(0xFF151026); and then in the MaterialApp level( will change the AppBar Color in the whole app )

How get moving text in widget with given width

若如初见. 提交于 2020-05-18 00:53:32
问题 I am building a radio app. Like in Spotify, there is a bar with the current title and artist, the text should be in one line and in a given width. How can I let the text move from right to left and back? When using a self-made animation, I want to have a fixed speed of the moving text, so I need the time and the width of the text widget. Is there a package/built-in option to do this? Or do I have to use a self-made animation? If so, how can I get the text widget width? Controller and

Unable to place the widgets in their correct position in FLUTTER

与世无争的帅哥 提交于 2020-05-17 07:03:18
问题 I have created a login page with using CustomBorder both from top to bottom, I am unable to set the position of bottom CustomBorder . Below is the code that I have tried and please also refer to the corresponding Images for more information. import 'dart:math'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; //import 'package:flutter/services.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:matchstix/styles/textStyle.dart

Unable to place the widgets in their correct position in FLUTTER

谁说我不能喝 提交于 2020-05-17 07:03:05
问题 I have created a login page with using CustomBorder both from top to bottom, I am unable to set the position of bottom CustomBorder . Below is the code that I have tried and please also refer to the corresponding Images for more information. import 'dart:math'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; //import 'package:flutter/services.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:matchstix/styles/textStyle.dart

Make SliverAppBar scrollable when TabBarView child is scrolled

白昼怎懂夜的黑 提交于 2020-05-17 06:32:49
问题 I have home screen with bottom navigation consist of two items which all have ListView inside with infinite list and I want SliverAppBar to be scrollable when user scrolls in one of the list. Here is what I have so far class HomeScreen extends StatelessWidget { @override Widget build(BuildContext context) { return DefaultTabController( length: 2, child: new Scaffold( body: CustomScrollView( slivers: <Widget>[ SliverAppBar( snap: false, floating: false, pinned: true, expandedHeight: 160.0,