To remove the package css_colors from an app: Use the pub remove command from inside the project directory flutter pub remove css_colors The Installing tab, available on any package page on pub.dev, is a handy reference for these steps.
Category: Dart
Using packages – Adding a package dependency to an app
To add the package css_colors to an app: Depend on it Open the pubspec.yaml file located inside the app folder, and add css_colors: ^1.0.0 under dependencies. Install it From the terminal: Run flutter pub get. OR From VS Code: Click Get Packages located in right side of the action ribbon at the top of pubspec.yaml… Continue reading Using packages – Adding a package dependency to an app
Using packages – Adding a package dependency to an app using flutter pub add
To add the package css_colors to an app: Use the pub add command from inside the project directory flutter pub add css_colors Import it Add a corresponding import statement in the Dart code. Stop and restart the app, if necessary If the package brings platform-specific code (Kotlin/Java for Android, Swift/Objective-C for iOS), that code must… Continue reading Using packages – Adding a package dependency to an app using flutter pub add
Using packages – Searching for packages
Packages are published to pub.dev. The Flutter landing page on pub.dev displays top packages that are compatible with Flutter (those that declare dependencies generally compatible with Flutter), and supports searching among all published packages. The Flutter Favorites page on pub.dev lists the plugins and packages that have been identified as packages you should first consider… Continue reading Using packages – Searching for packages
Navigate to a new screen and back :
Interactive example import ‘package:flutter/material.dart’; void main() { runApp(const MaterialApp( title: ‘Navigation Basics’, home: FirstRoute(), )); } class FirstRoute extends StatelessWidget { const FirstRoute({super.key}); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text(‘First Route’), ), body: Center( child: ElevatedButton( child: const Text(‘Open route’), onPressed: () { Navigator.push( context, MaterialPageRoute(builder: (context) => const SecondRoute()),… Continue reading Navigate to a new screen and back :
Navigate to a new screen and back : Return to the first route using Navigator.pop() #
How do you close the second route and return to the first? By using the Navigator.pop() method. The pop() method removes the current Route from the stack of routes managed by the Navigator. To implement a return to the original route, update the onPressed() callback in the SecondRoute widget: // Within the SecondRoute widget onPressed:… Continue reading Navigate to a new screen and back : Return to the first route using Navigator.pop() #
Navigate to a new screen and back : Navigate to the second route using Navigator.push()
To switch to a new route, use the Navigator.push() method. The push() method adds a Route to the stack of routes managed by the Navigator. Where does the Route come from? You can create your own, or use a MaterialPageRoute, which is useful because it transitions to the new route using a platform-specific animation. In… Continue reading Navigate to a new screen and back : Navigate to the second route using Navigator.push()
Navigate to a new screen and back : Create two routes
First, create two routes to work with. Since this is a basic example, each route contains only a single button. Tapping the button on the first route navigates to the second route. Tapping the button on the second route returns to the first route. class FirstRoute extends StatelessWidget { const FirstRoute({super.key}); @override Widget build(BuildContext context)… Continue reading Navigate to a new screen and back : Create two routes
Shortcuts widget
To apply a set of keyboard shortcuts to a large section of the tree, use the Shortcuts widget: // Define a class for each type of shortcut action you want class CreateNewItemIntent extends Intent { const CreateNewItemIntent(); } Widget build(BuildContext context) { return Shortcuts( // Bind intents to key combinations shortcuts: const <ShortcutActivator, Intent>{ SingleActivator(LogicalKeyboardKey.keyN,… Continue reading Shortcuts widget
Keyboard accelerators
In addition to tab traversal, desktop and web users are accustomed to having various keyboard shortcuts bound to specific actions. Whether it’s the Delete key for quick deletions or Control+N for a new document, be sure to consider the different accelerators your users expect. The keyboard is a powerful input tool, so try to squeeze… Continue reading Keyboard accelerators