How to deal with unwanted widget build?

For various reasons, sometimes the build method of my widgets is called again. I know that it happens because a parent updated. But this causes undesired effects. A typical situation where it causes problems is when using FutureBuilder this way: @override Widget build(BuildContext context) { return FutureBuilder( future: httpCall(), builder: (context, snapshot) { // create … Read more

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 run CocoaPods on Apple Silicon (M1)

I have a Flutter project that I’m trying to run on iOS. It runs normally on my Intel-based Mac, but on my new Apple Silicon-based M1 Mac it fails to install pods. LoadError – dlsym(0x7f8926035eb0, Init_ffi_c): symbol not found – /Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1/lib/ffi_c.bundle /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require’ /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require’ /Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1/lib/ffi.rb:6:in `rescue in <top (required)>’ /Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1/lib/ffi.rb:3:in `<top (required)>’ /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require’ … 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