How to apply theme on MaterialButton or RaisedButton?

One way to do it is to Define buttonTheme in theme in MaterialApp: E.g: void main() { runApp(MaterialApp( home: Home(), theme: ThemeData( accentColor: Colors.redAccent, buttonTheme: ButtonThemeData( buttonColor: Colors.blueAccent, shape: RoundedRectangleBorder(), textTheme: ButtonTextTheme.accent, …. )), )); } class Home extends StatelessWidget { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(“Button Theme”), backgroundColor:, body: … Read more

How to save and download text file in Flutter web application

This method is based on manipulations with an HTML document. Some additional packages should be imported: import ‘dart:convert’; import ‘dart:html’ as html; // or package:universal_html/prefer_universal/html.dart Code snippet: final text=”this is the text file”; // prepare final bytes = utf8.encode(text); final blob = html.Blob([bytes]); final url = html.Url.createObjectUrlFromBlob(blob); final anchor = html.document.createElement(‘a’) as html.AnchorElement ..href = … Read more

Error: ‘ModalBottomSheetRoute’ is imported from both

The reason behind the error is says both material/bottom_sheet.dart and bottom_sheet_route exports the ModalBottomSheetRoute. ‘ModalBottomSheetRoute’ is imported from both ‘package:flutter/src/material/bottom_sheet.dart’ and ‘package:modal_bottom_sheet/src/bottom_sheet_route.dart’. In order to fix this issue we have to hide one of the ModalBottomSheetRoute. since we need this to be imported from bottom_sheet_route we need to hide it from material This is the … Read more

flutter –flow-control-collections are needed, but are they?

Hey, I had the same issue this morning but found a fix. 1) Keep the analysis_options.yaml in your root folder with this code: analyzer: enable-experiment: – control-flow-collections 2) Don’t use brackets {} in between your for loops Ex: <Widget>[ for (final category in categories) CategoryWidget(category: category) ], 3) Important step which is probably why it’s … Read more

LockScreen widget in Flutter?

At the time of this writing, there are no known plugins that do that. There are two options moving forward, based on timeline for when you need this functionality: Wait for someone to create a plugin that does this Create the plugin yourself. Follow the Apple Docs and write a custom Flutter plugin (and then … Read more

Calling a method with Provider.of(context) inside of dispose() method cause “Looking up a deactivated widget’s ancestor is unsafe.”

It seems like you are trying to close something which is defined in your AppProvider class. If AppProvider class is extending ChangeNotifier, the change notifier class provides dispose method, you can override it and then call the close function inside the AppProvider class only.

Flutter how to get cursor in text field to stop moving to the beginning?

You do not have to do controller..text = text; inside onChanged because the controller’s text automatically changes once you connect it to TextField. The reason is once you set some text to controller, it re-applies the text thus moving the cursor at front. In your case : TextField( decoration: InputDecoration( border: InputBorder.none ), controller: controller, … Read more

How can Flutter handle dpi text and image size differences

Flutter supports loading of assets by automatically choosing DPI dependent resources, see for how the mechanism works. Flutter should scale text according to devicePixelRatio value. Here is an example app showing you how that works: import ‘package:flutter/material.dart’; void main() { runApp(new MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return … Read more

Unresolved reference: FlutterActivity

I got the solution for this. If you want to write native code or edit existing native code you have to open the “android” part of your project specifically. You can do that be going to : File -> Open ….. Then browse to your current project and select its “android” folder and open it … Read more