Flutter API Fetch and Sending Data from One screen to another screen

You should try to declare constructor the first page accept the id and push this id to second page or screen like this below code is first page Navigator.push( context, MaterialPageRoute( builder: (context) => ABC.withId( id, ), ), ) the create constructor inside second page screen class ABC extends StatefulWidget { @override _ABCState createState() => … Read more

Unable to find bundled Java version. MacBook Air M1

I fix it by changing Contents folder location. from /Applications/Android Studio Preview.app/Contents/jre/Contents to /Applications/Android Studio Preview.app/Contents/jre/jdk/Contents after close the android studio preview I face a problem with start it again. but in general flutter doctor works with no Issues.

Getting permission to the external storage (file_provider plugin)

Beside needing to add WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE to your android/app/src/main/AndroidManifest.xml <manifest xmlns:android=”http://schemas.android.com/apk/res/android” package=”com.xxx.yyy”> <uses-permission android:name=”android.permission.WRITE_EXTERNAL_STORAGE”/> <uses-permission android:name=”android.permission.READ_EXTERNAL_STORAGE”/> … </manifest> You also need Runtime Request Permission, by using simple_permissions package: import ‘package:simple_permissions/simple_permissions.dart’; PermissionStatus permissionResult = await SimplePermissions.requestPermission(Permission. WriteExternalStorage); if (permissionResult == PermissionStatus.authorized){ // code of read or write file in external storage (SD card) } Note: … Read more

Flutter Back button with return data

The easier way is to wrap the body in WillPopScope, in this way it will work with the Back Button on the Top AND the Android Back Button on the Bottom. Here an example where both back buttons return false: final return = Navigator.of(context).push(MaterialPageRoute<bool>( builder: (BuildContext context) { return Scaffold( appBar: AppBar( title: Text(“New Page”), … Read more

Flutter: There should be exactly one item with [DropdownButton]’s value

Well, since no problem has an exact same solution. I was facing the same issue with my code. Here is How I fixed this. CODE of my DropdownButton: DropdownButton( items: _salutations .map((String item) => DropdownMenuItem<String>(child: Text(item), value: item)) .toList(), onChanged: (String value) { setState(() { print(“previous ${this._salutation}”); print(“selected $value”); this._salutation = value; }); }, value: … Read more

How to implement a Custom dialog box in flutter?

Use Dialog class which is a parent class to AlertDialog class in Flutter. Dialog widget has a argument , “shape” which you can use to shape the Edges of the Dialog box. Here is a code sample: Dialog errorDialog = Dialog( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12.0)), //this right here child: Container( height: 300.0, width: 300.0, child: Column( … Read more

How to detect swipe in flutter

Use GestureDetector.onPanUpdate: GestureDetector( onPanUpdate: (details) { // Swiping in right direction. if (details.delta.dx > 0) {} // Swiping in left direction. if (details.delta.dx < 0) {} }, child: YourWidget(), ) To cover all the area (passing the parent constraints to the widget), you can include SizedBox.expand. SizedBox.expand( child: GestureDetector( onPanUpdate: (details) { // Swiping in … Read more

What does the shrinkWrap property do in Flutter?

Usually a ListView (as well as GridView, PageView and CustomScrollView) tries to fill all the available space given by the parent element, even when the list items would require less space. With shrinkWrap: true, you can change this behavior so that the ListView only occupies the space it needs (it will still scroll when there … Read more