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

This exception happens because you are using the context of the widget that instantiated Scaffold. Not the context of a child of Scaffold. You can solve this by just using a different context : Scaffold( appBar: AppBar( title: Text(‘SnackBar Playground’), ), body: Builder( builder: (context) => Center( child: RaisedButton( color: Colors.pink, textColor: Colors.white, onPressed: () … Read more

How to create number input field in Flutter?

You can specify the number as keyboardType for the TextField using: keyboardType: TextInputType.number Check my main.dart file import ‘package:flutter/material.dart’; import ‘package:flutter/services.dart’; void main() => runApp(new MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { // TODO: implement build return new MaterialApp( home: new HomePage(), theme: new ThemeData(primarySwatch: Colors.blue), ); } } class HomePage … Read more

Message “flutter run: No connected devices”

Flutter supports both iOS and Android device/simulators. In the terminal, run the flutter devices command to verify that Flutter recognizes your connected Android device. Here is a reference document on how you can set up a device/simulator to run your application. For, Android (on a Mac system) Set up your Android device To prepare to … Read more

How to run CocoaPods on Apple Silicon (M1)

2022 September Update If you can use Homebrew to manage cocoapods. # Uninstall the local cocoapods gem sudo gem uninstall cocoapods # Reinstall cocoapods via Homebrew brew install cocoapods 2021 Solution # STEP 1: Install ffi sudo arch -x86_64 gem install ffi # STEP 2: Re-install dependencies arch -x86_64 pod install Additional Information #1 For … Read more

How do you detect the host platform from Dart code?

import ‘dart:io’ show Platform; if (Platform.isAndroid) { // Android-specific code } else if (Platform.isIOS) { // iOS-specific code } All options include: Platform.isAndroid Platform.isFuchsia Platform.isIOS Platform.isLinux Platform.isMacOS Platform.isWindows You can also detect if you are running on the web using kIsWeb, a global constant indicating if the application was compiled to run on the web: … Read more

How can I dismiss the on screen keyboard?

For Flutter version 2 or latest : Since Flutter 2 with null safety this is the best way: FocusManager.instance.primaryFocus?.unfocus(); Note: using old ways leads to some problems like keep rebuild states; For Flutter version < 2 : As of Flutter v1.7.8+hotfix.2, the way to go is: FocusScope.of(context).unfocus(); Comment on PR about that: Now that #31909 … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)