InkWell not showing ripple effect

I think adding color to the container is covering over the ink effect https://api.flutter.dev/flutter/material/InkWell/InkWell.html This code seems to work body: new Center( child: new Container( child: new Material( child: new InkWell( onTap: (){print(“tapped”);}, child: new Container( width: 100.0, height: 100.0, ), ), color: Colors.transparent, ), color: Colors.orange, ), ), just click the middle square. Edit: … Read more

Controlling State from outside of a StatefulWidget

There are multiple ways to interact with other stateful widgets. 1. findAncestorStateOfType The first and most straightforward is through context.findAncestorStateOfType method. Usually wrapped in a static method of the Stateful subclass like this : class MyState extends StatefulWidget { static of(BuildContext context, {bool root = false}) => root ? context.findRootAncestorStateOfType<_MyStateState>() : context.findAncestorStateOfType<_MyStateState>(); @override _MyStateState createState() … Read more

Force Flutter navigator to reload state when popping

There’s a couple of things you could do here. @Mahi’s answer while correct could be a little more succinct and actually use push rather than showDialog as the OP was asking about. This is an example that uses Navigator.push: import ‘package:flutter/material.dart’; class SecondPage extends StatelessWidget { @override Widget build(BuildContext context) { return Container( color: Colors.green, … Read more

How to know if a widget is visible within a viewport?

https://pub.dev/packages/visibility_detector provides this functionality with its VisibilityDetector widget that can wrap any other Widget and notify when the visible area of the widget changed: VisibilityDetector( key: Key(“unique key”), onVisibilityChanged: (VisibilityInfo info) { debugPrint(“${info.visibleFraction} of my widget is visible”); }, child: MyWidgetToTrack()); )

Flutter: How to set and lock screen orientation on-demand

First import the services package: import ‘package:flutter/services.dart’; This will give you access to the SystemChrome class, which “Controls specific aspects of the operating system’s graphical interface and how it interacts with the application.” When you load the Widget, do something like this: @override void initState(){ super.initState(); SystemChrome.setPreferredOrientations([ DeviceOrientation.landscapeRight, DeviceOrientation.landscapeLeft, ]); } then when I leave … Read more

How to change the application launcher icon on Flutter?

Flutter Launcher Icons has been designed to help quickly generate launcher icons for both Android and iOS: https://pub.dartlang.org/packages/flutter_launcher_icons Add the package to your pubspec.yaml file (within your Flutter project) to use it Within pubspec.yaml file specify the path of the icon you wish to use for the app and then choose whether you want to … Read more