How to create Toast in Flutter

Can I create something similar to Toasts in Flutter? Just a tiny notification window that is not directly in the face of the user and does not lock or fade the view behind it. 31 Answers 31 UPDATE: Scaffold.of(context).showSnackBar is deprecated in Flutter 2.0.0 (stable) You can access the parent ScaffoldMessengerState using ScaffoldMessenger.of(context). Then do … Read more

Flutter: how to prevent device orientation changes and force portrait?

I would like to prevent my application from changing its orientation and force the layout to stick to “portrait”. In the main.dart, I put: void main(){ SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, DeviceOrientation.portraitDown ]); runApp(new MyApp()); } but when I use the Android Simulator rotate buttons, the layout “follows” the new device orientation… How could I solve this? Thanks … Read more

Dart SDK is not configured

I installed Flutter and set up Android Studio. Then I cloned an example of flutter on GitHub (https://github.com/flutter/flutter) and launched it in Android Studio, but it warns me “Dart SDK is not configured”, this happened to my co-worker as well. But if I create a new project in Android Studio, no problem at all. What … Read more

How to add a ListView to a Column in Flutter?

I’m trying to construct a simple login page for my Flutter app. I’ve successfully built the TextFields and log in/Sign in buttons. I want to add a horizontal ListView. When I run the code my elements disappear, if I do it without the ListView, it’s fine again. How can I do this correctly? return new … Read more

How to do Rounded Corners Image in Flutter

I am using Flutter to make a list of information about movies. Now I want the cover image on the left to be a rounded corners picture. I did the following, but it didn’t work. Thanks! getItem(var subject) { var row = Container( margin: EdgeInsets.all(8.0), child: Row( children: <Widget>[ Container( width: 100.0, height: 150.0, decoration: … Read more

Scaffold.of() called with a context that does not contain a Scaffold

As you can see, my button is inside the Scaffold‘s body. But I get this exception: Scaffold.of() called with a context that does not contain a Scaffold. import ‘package:flutter/material.dart’; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: ‘Flutter Demo’, theme: ThemeData( primarySwatch: Colors.blue, ), home: HomePage(), … Read more

Flutter – Wrap text on overflow, like insert ellipsis or fade

I’m trying to create a line in which center text has a maximum size, and if the text content is too large, it fits in size. I insert the TextOverflow.ellipsis property to shorten the text and inserting the triple points … but it is not working. main.dart import ‘package:flutter/material.dart’; void main() { runApp(new MyApp()); } … Read more

Message “flutter run: No connected devices”

I am trying to create a sample application with Flutter (fresh installation). Android Studio is also installed (fresh installation). Here is the output of flutter run flutter run No connected devices. The output of flutter doctor: Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel beta, v0.1.5, on Linux, locale en_US.UTF-8) … Read more