id
stringlengths
14
17
text
stringlengths
23
1.11k
source
stringlengths
35
114
569481dcb67d-0
Effects Cookbook Effects Create a download button Create a nested navigation flow Create a photo filter carousel Create a scrolling parallax effect Create a shimmer loading effect Create a staggered menu animation Create a typing indicator Create an expandable FAB Create gradient chat bubbles Drag a UI elem...
https://docs.flutter.dev/cookbook/effects/index.html
5edcbedc41f9-0
Create a download button Create a photo filter carousel Create a nested navigation flow Cookbook Effects Create a nested navigation flow Prepare for navigation Display an app bar for the setup flow Generate nested routes Interactive example Apps accumulate dozens and then hundreds of routes over time. Some of...
https://docs.flutter.dev/cookbook/effects/nested-nav/index.html
5edcbedc41f9-1
Consider an Internet of Things (IoT) setup flow for a wireless light bulb that you control with your app. This setup flow consists of 4 pages: find nearby bulbs, select the bulb that you want to add, add the bulb, and then complete the setup. You could orchestrate this behavior from your top-level Navigator widget. H...
https://docs.flutter.dev/cookbook/effects/nested-nav/index.html
5edcbedc41f9-2
Prepare for navigation This IoT app has two top-level screens, along with the setup flow. Define these route names as constants so that they can be referenced within code. The home and settings screens are referenced with static names. The setup flow pages, however, use two paths to create their route names: a /set...
https://docs.flutter.dev/cookbook/effects/nested-nav/index.html
5edcbedc41f9-3
Implement onGenerateRoute to return the appropriate widget for each of the three top-level paths. Notice that the home and settings routes are matched with exact route names. However, the setup flow route condition only checks for a prefix. If the route name contains the setup flow prefix, then the rest of the route ...
https://docs.flutter.dev/cookbook/effects/nested-nav/index.html
5edcbedc41f9-4
The app bar displays a back arrow and exits the setup flow when the back arrow is pressed. However, exiting the flow causes the user to lose all progress. Therefore, the user is prompted to confirm whether they want to exit the setup flow. Prompt the user to confirm exiting the setup flow, and ensure that the prompt ...
https://docs.flutter.dev/cookbook/effects/nested-nav/index.html
5edcbedc41f9-5
Generate nested routes The setup flow’s job is to display the appropriate page within the flow. Add a Navigator widget to SetupFlow, and implement the onGenerateRoute property. The _onGenerateRoute function works the same as for a top-level Navigator. A RouteSettings object is passed into the function, which include...
https://docs.flutter.dev/cookbook/effects/nested-nav/index.html
5edcbedc41f9-6
Interactive example Run the app: On the Add your first bulb screen, click the FAB, shown with a plus sign, +. This brings you to the Select a nearby device screen. A single bulb is listed. Click the listed bulb. A Finished! screen appears. Click the Finished button to return to the first screen. Create a download ...
https://docs.flutter.dev/cookbook/effects/nested-nav/index.html
77a6d5fd7e8a-0
Create a photo filter carousel Create a shimmer loading effect Create a scrolling parallax effect Cookbook Effects Create a scrolling parallax effect Create a list to hold the parallax items Display items with text and a static image Implement the parallax effect Interactive example When you scroll a list of ...
https://docs.flutter.dev/cookbook/effects/parallax-scrolling/index.html
77a6d5fd7e8a-1
The following animation shows the app’s behavior: Create a list to hold the parallax items To display a list of parallax scrolling images, you must first display a list. Create a new stateless widget called ParallaxRecipe. Within ParallaxRecipe, build a widget tree with a SingleChildScrollView and a Column, which fo...
https://docs.flutter.dev/cookbook/effects/parallax-scrolling/index.html
77a6d5fd7e8a-2
Implement a stateless widget called LocationListItem that consists of the previously mentioned visuals. For now, use a static Image widget for the background. Later, you’ll replace that widget with a parallax version. Next, add the list items to your ParallaxRecipe widget. You now have a typical, scrollable list of c...
https://docs.flutter.dev/cookbook/effects/parallax-scrolling/index.html
77a6d5fd7e8a-3
The parallax effect depends on the list item’s current position within its ancestor Scrollable. As the list item’s scroll position changes, the position of the list item’s background image must also change. This is an interesting problem to solve. The position of a list item within the Scrollable isn’t available until...
https://docs.flutter.dev/cookbook/effects/parallax-scrolling/index.html
77a6d5fd7e8a-4
In cases where you need control over the layout, painting, and hit testing, consider defining a custom RenderBox. Wrap your background Image widget with a Flow widget. Introduce a new FlowDelegate called ParallaxFlowDelegate. A FlowDelegate controls how its children are sized and where those children are painted...
https://docs.flutter.dev/cookbook/effects/parallax-scrolling/index.html
77a6d5fd7e8a-5
The bounds of the individual list item The size of the image after it’s scaled down to fit in the list item To look up the bounds of the Scrollable, you pass a ScrollableState into your FlowDelegate. To look up the bounds of your individual list item, you pass your list item’s BuildContext into your FlowDelegate. T...
https://docs.flutter.dev/cookbook/effects/parallax-scrolling/index.html
77a6d5fd7e8a-6
First, calculate the pixel position of a list item within its ancestor Scrollable. Use the pixel position of the list item to calculate its percentage from the top of the Scrollable. A list item at the top of the scrollable area should produce 0%, and a list item at the bottom of the scrollable area should produce 10...
https://docs.flutter.dev/cookbook/effects/parallax-scrolling/index.html
77a6d5fd7e8a-7
You need one final detail to achieve the parallax effect. The ParallaxFlowDelegate repaints when the inputs change, but the ParallaxFlowDelegate doesn’t repaint every time the scroll position changes. Pass the ScrollableState’s ScrollPosition to the FlowDelegate superclass so that the FlowDelegate repaints every time ...
https://docs.flutter.dev/cookbook/effects/parallax-scrolling/index.html
35525a794e24-0
Create a nested navigation flow Create a scrolling parallax effect Create a photo filter carousel Cookbook Effects Create a photo filter carousel Add a selector ring and dark gradient Create a filter carousel item Implement the filter carousel Interactive example Everybody knows that a photo looks better with...
https://docs.flutter.dev/cookbook/effects/photo-filter-carousel/index.html
35525a794e24-1
Create a new stateful widget called FilterSelector that you’ll use to implement the selector. Add the FilterSelector widget to the existing widget tree. Position the FilterSelector widget on top of the photo, at the bottom and centered. Within the FilterSelector widget, display a selector ring on top of a dark grad...
https://docs.flutter.dev/cookbook/effects/photo-filter-carousel/index.html
35525a794e24-2
Create a filter carousel item Each filter item in the carousel displays a circular image with a color applied to the image that corresponds to the associated filter color. Define a new stateless widget called FilterItem that displays a single list item. Implement the filter carousel Filter items scroll to the left ...
https://docs.flutter.dev/cookbook/effects/photo-filter-carousel/index.html
35525a794e24-3
Scrollable widget with a viewportBuilder, and place a Flow widget inside the delegate property that allows you to position child widgets wherever you want, based on the current Configure your widget tree to make space for the PageView. Build each FilterItem widget within the PageView widget based on the given ...
https://docs.flutter.dev/cookbook/effects/photo-filter-carousel/index.html
35525a794e24-4
Calculate an appropriate scale and opacity for each FilterItem widget within the AnimatedBuilder and apply those values. Each FilterItem widget now shrinks and fades away as it moves farther from the center of the screen. Add a method to change the selected filter when a FilterItem widget is tapped. Configure each F...
https://docs.flutter.dev/cookbook/effects/photo-filter-carousel/index.html
8ee8a55b05b5-0
Create a scrolling parallax effect Create a staggered menu animation Create a shimmer loading effect Cookbook Effects Create a shimmer loading effect Draw the shimmer shapes Paint the shimmer gradient Paint one big shimmer Animate the shimmer Loading times are unavoidable in application development. From a us...
https://docs.flutter.dev/cookbook/effects/shimmer-loading/index.html
8ee8a55b05b5-1
The following animation shows the app’s behavior: This recipe begins with the content widgets defined and positioned. There is also a Floating Action Button (FAB) in the bottom-right corner that toggles between a loading mode and a loaded mode so that you can easily validate your implementation. Draw the shimmer shap...
https://docs.flutter.dev/cookbook/effects/shimmer-loading/index.html
8ee8a55b05b5-2
On the other hand, consider the text that appears beneath the rounded rectangle images. You won’t know how many lines of text exist until the text loads. Therefore, there is no point in trying to draw a rectangle for every line of text. Instead, while the data is loading, you draw a couple of very thin rounded rectang...
https://docs.flutter.dev/cookbook/effects/shimmer-loading/index.html
8ee8a55b05b5-3
Your UI now renders itself differently depending on whether it’s loading or loaded. By temporarily commenting out the image URLs, you can see the two ways your UI renders. The next goal is to paint all of the colored areas with a single gradient that looks like a shimmer. Paint the shimmer gradient The key to the ef...
https://docs.flutter.dev/cookbook/effects/shimmer-loading/index.html
8ee8a55b05b5-4
Wrap your CardListItem widgets with a ShimmerLoading widget. When your shapes are loading, they now display the shimmer gradient that is returned from the shaderCallback. This is a big step in the right direction, but there’s a problem with this gradient display. Each CircleListItem widget and each CardListItem widg...
https://docs.flutter.dev/cookbook/effects/shimmer-loading/index.html
8ee8a55b05b5-5
To be more precise, rather than assume that the shimmer should take up the entire screen, there should be some area that shares the shimmer. Maybe that area takes up the entire screen, or maybe it doesn’t. The way to solve this kind of problem in Flutter is to define another widget that sits above all of the ShimmerLo...
https://docs.flutter.dev/cookbook/effects/shimmer-loading/index.html
8ee8a55b05b5-6
Animate the shimmer The shimmer gradient needs to move in order to give the appearance of a shimmering shine. The LinearGradient has a property called transform that can be used to transform the appearance of the gradient, for example, to move it horizontally. The transform property accepts a GradientTransform insta...
https://docs.flutter.dev/cookbook/effects/shimmer-loading/index.html
8ee8a55b05b5-7
Expose the _shimmerController from ShimmerState as a Listenable. In ShimmerLoading, listen for changes to the ancestor ShimmerState’s shimmerChanges property, and repaint the shimmer gradient. Congratulations! You now have a full-screen, animated shimmer effect that turns on and off as the content loads. Note: Th...
https://docs.flutter.dev/cookbook/effects/shimmer-loading/index.html
3ca106db67a6-0
Create a shimmer loading effect Create a typing indicator Create a staggered menu animation Cookbook Effects Create a staggered menu animation Create the menu without animations Prepare for animations Animate the list items and button Interactive example A single app screen might contain multiple animations. ...
https://docs.flutter.dev/cookbook/effects/staggered-menu-animation/index.html
3ca106db67a6-1
Create the menu without animations The drawer menu displays a list of titles, followed by a Get started button at the bottom of the menu. Define a stateful widget called Menu that displays the list and button in static locations. Prepare for animations Control of the animation timing requires an AnimationControll...
https://docs.flutter.dev/cookbook/effects/staggered-menu-animation/index.html
3ca106db67a6-2
In this case, all the animations are delayed by 50 ms. After that, list items begin to appear. Each list item’s appearance is delayed by 50 ms after the previous list item begins to slide in. Each list item takes 250 ms to slide from right to left. After the last list item begins to slide in, the button at the bottom ...
https://docs.flutter.dev/cookbook/effects/staggered-menu-animation/index.html
3ca106db67a6-3
The desired animation times are shown in the following diagram: To animate a value during a subsection of a larger animation, Flutter provides the Interval class. An Interval takes a start time percentage and an end time percentage. That Interval can then be used to animate a value between those start and end times, ...
https://docs.flutter.dev/cookbook/effects/staggered-menu-animation/index.html
3ca106db67a6-4
Each list item slides from right to left and fades in at the same time. Use the list item’s Interval and an easeOut curve to animate the opacity and translation values for each list item. Use the same approach to animate the opacity and scale of the bottom button. This time, use an elasticOut curve to give the button...
https://docs.flutter.dev/cookbook/effects/staggered-menu-animation/index.html
3af7c9f2c09b-0
Create a staggered menu animation Create an expandable FAB Create a typing indicator Cookbook Effects Create a typing indicator Define the typing indicator widget Make room for the typing indicator Animate the speech bubbles Animate the flashing circles Interactive example Modern chat apps display indicators...
https://docs.flutter.dev/cookbook/effects/typing-indicator/index.html
3af7c9f2c09b-1
Define the typing indicator widget The typing indicator exists within its own widget so that it can be used anywhere in your app. As with any widget that controls animations, the typing indicator needs to be a stateful widget. The widget accepts a boolean value that determines whether the indicator is visible. This s...
https://docs.flutter.dev/cookbook/effects/typing-indicator/index.html
3af7c9f2c09b-2
The height of the typing indicator could be the natural height of the speech bubbles within the typing indicator. However, the speech bubbles expand with an elastic curve. This elasticity would be too visually jarring if it quickly pushed all the conversation messages up or down. Instead, the height of the typing indi...
https://docs.flutter.dev/cookbook/effects/typing-indicator/index.html
3af7c9f2c09b-3
The animation that controls the height uses different animation curves depending on its direction. When the animation moves forward, it needs to quickly make space for the speech bubbles. For this reason, the forward curve runs the entire height animation within the first 40% of the overall appearance animation. When ...
https://docs.flutter.dev/cookbook/effects/typing-indicator/index.html
3af7c9f2c09b-4
Each bubble appears by animating its scale from 0% to 100%, and each bubble does this at slightly different times so that it looks like each bubble appears after the one before it. This is called a staggered animation. Paint the three bubbles in the desired positions from the lower left. Then, animate the scale of the...
https://docs.flutter.dev/cookbook/effects/typing-indicator/index.html
3af7c9f2c09b-5
Each circle calculates its color using a sine (sin) function so that the color changes gradually at the minimum and maximum points. Additionally, each circle animates its color within a specified interval that takes up a portion of the overall animation time. The position of these intervals generates the visual effect ...
https://docs.flutter.dev/cookbook/effects/typing-indicator/index.html
c3f7df168026-0
Retrieve the value of a text field Add Material touch ripples Focus and text fields Cookbook Forms Focus and text fields Focus a text field as soon as it’s visible Focus a text field when a button is tapped 1. Create a FocusNode 2. Pass the FocusNode to a TextField 3. Give focus to the TextField when a button i...
https://docs.flutter.dev/cookbook/forms/focus/index.html
c3f7df168026-1
Managing focus is a fundamental tool for creating forms with an intuitive flow. For example, say you have a search screen with a text field. When the user navigates to the search screen, you can set the focus to the text field for the search term. This allows the user to start typing as soon as the screen is visible, w...
https://docs.flutter.dev/cookbook/forms/focus/index.html
c3f7df168026-2
Focus a text field when a button is tapped Rather than immediately shifting focus to a specific text field, you might need to give focus to a text field at a later point in time. In the real world, you might also need to give focus to a specific text field in response to an API call or a validation error. In this exam...
https://docs.flutter.dev/cookbook/forms/focus/index.html
c3f7df168026-3
Since focus nodes are long-lived objects, manage the lifecycle using a State object. Use the following instructions to create a FocusNode instance inside the initState() method of a State class, and clean it up in the dispose() method: 2. Pass the FocusNode to a TextField Now that you have a FocusNode, pass it to a s...
https://docs.flutter.dev/cookbook/forms/focus/index.html
9819f966f5a4-0
Forms Cookbook Forms Build a form with validation Create and style a text field Focus and text fields Handle changes to a text field Retrieve the value of a text field
https://docs.flutter.dev/cookbook/forms/index.html
851a93473d17-0
Create an expandable FAB Focus and text fields Retrieve the value of a text field Cookbook Forms Retrieve the value of a text field 1. Create a TextEditingController 2. Supply the TextEditingController to a TextField 3. Display the current value of the text field Interactive example In this recipe, learn how ...
https://docs.flutter.dev/cookbook/forms/retrieve-input/index.html
851a93473d17-1
Important: Call dispose of the TextEditingController when you’ve finished using it. This ensures that you discard any resources used by the object. 2. Supply the TextEditingController to a TextField Now that you have a TextEditingController, wire it up to a text field using the controller property: 3. Display th...
https://docs.flutter.dev/cookbook/forms/retrieve-input/index.html
e14db9e7fb96-0
Create and style a text field Retrieve the value of a text field Handle changes to a text field Cookbook Forms Handle changes to a text field 1. Supply an onChanged() callback to a TextField or a TextFormField 2. Use a TextEditingController Create a TextEditingController Connect the TextEditingController to a t...
https://docs.flutter.dev/cookbook/forms/text-field-changes/index.html
e14db9e7fb96-1
Supply an onChanged() callback to a TextField or a TextFormField. Use a TextEditingController. 1. Supply an onChanged() callback to a TextField or a TextFormField The simplest approach is to supply an onChanged() callback to a TextField or a TextFormField. Whenever the text changes, the callback is invoked. In this...
https://docs.flutter.dev/cookbook/forms/text-field-changes/index.html
e14db9e7fb96-2
Create a function to print the latest value. Listen to the controller for changes. Create a TextEditingController Create a TextEditingController: Note: Remember to dispose of the TextEditingController when it’s no longer needed. This ensures that you discard any resources used by the object. Connect the Text...
https://docs.flutter.dev/cookbook/forms/text-field-changes/index.html
e14db9e7fb96-3
Listen to the controller for changes Finally, listen to the TextEditingController and call the _printLatestValue() method when the text changes. Use the addListener() method for this purpose. Begin listening for changes when the _MyCustomFormState class is initialized, and stop listening when the _MyCustomFormState i...
https://docs.flutter.dev/cookbook/forms/text-field-changes/index.html
14f96c16047e-0
Build a form with validation Handle changes to a text field Create and style a text field Cookbook Forms Create and style a text field TextField TextFormField Interactive example Text fields allow users to type text into an app. They are used to build forms, send messages, create search experiences, and more. ...
https://docs.flutter.dev/cookbook/forms/text-input/index.html
14f96c16047e-1
To retrieve the value when it changes, see the Handle changes to a text field recipe. TextFormField TextFormField wraps a TextField and integrates it with the enclosing Form. This provides additional functionality, such as validation and integration with other FormField widgets. Interactive example For more informa...
https://docs.flutter.dev/cookbook/forms/text-input/index.html
e728004b0c49-0
Drag a UI element Create and style a text field Build a form with validation Cookbook Forms Build a form with validation 1. Create a Form with a GlobalKey 2. Add a TextFormField with validation logic 3. Create a button to validate and submit the form How does this work? Interactive example Apps often require...
https://docs.flutter.dev/cookbook/forms/validation/index.html
e728004b0c49-1
Create a Form with a GlobalKey. Add a TextFormField with validation logic. Create a button to validate and submit the form. 1. Create a Form with a GlobalKey First, create a Form. The Form widget acts as a container for grouping and validating multiple form fields. When creating the form, provide a GlobalKey. This...
https://docs.flutter.dev/cookbook/forms/validation/index.html
e728004b0c49-2
2. Add a TextFormField with validation logic Although the Form is in place, it doesn’t have a way for users to enter text. That’s the job of a TextFormField. The TextFormField widget renders a material design text field and can display validation errors when they occur. Validate the input by providing a validator() f...
https://docs.flutter.dev/cookbook/forms/validation/index.html
e728004b0c49-3
When the user attempts to submit the form, check if the form is valid. If it is, display a success message. If it isn’t (the text field has no content) display the error message. How does this work? To validate the form, use the _formKey created in step 1. You can use the _formKey.currentState() method to access the ...
https://docs.flutter.dev/cookbook/forms/validation/index.html
7af096deb78c-0
Handle taps Display images from the internet Implement swipe to dismiss Cookbook Gestures Implement swipe to dismiss 1. Create a list of items Create a data source Convert the data source into a list 2. Wrap each item in a Dismissible widget 3. Provide “leave behind” indicators Interactive example The “swipe...
https://docs.flutter.dev/cookbook/gestures/dismissible/index.html
7af096deb78c-1
Wrap each item in a Dismissible widget. Provide “leave behind” indicators. 1. Create a list of items First, create a list of items. For detailed instructions on how to create a list, follow the Working with long lists recipe. Create a data source In this example, you want 20 sample items to work with. To keep it s...
https://docs.flutter.dev/cookbook/gestures/dismissible/index.html
7af096deb78c-2
After the user has swiped away the item, remove the item from the list and display a snackbar. In a real app, you might need to perform more complex logic, such as removing the item from a web service or database. Update the itemBuilder() function to return a Dismissible widget: 3. Provide “leave behind” indicators ...
https://docs.flutter.dev/cookbook/gestures/dismissible/index.html
7af096deb78c-3
@@ -16,6 +16,8 @@ 16 16 ScaffoldMessenger.of(context) 17 17 .showSnackBar(SnackBar(content: Text('$item dismissed'))); 18 18 }, 19 + // Show a red background as the item is swiped away. 20 + background: Container(color: Colors.red), 19 21 child: ListTile( 20 22 title: Text(...
https://docs.flutter.dev/cookbook/gestures/dismissible/index.html
1a26ce5e03ad-0
Add Material touch ripples Implement swipe to dismiss Handle taps Cookbook Gestures Handle taps Notes Interactive example You not only want to display information to users, you want users to interact with your app. Use the GestureDetector widget to respond to fundamental actions, such as tapping and dragging. ...
https://docs.flutter.dev/cookbook/gestures/handling-taps/index.html
1a26ce5e03ad-1
Although this example creates a custom button, Flutter includes a handful of button implementations, such as: ElevatedButton, TextButton, and CupertinoButton. Interactive example Add Material touch ripples Implement swipe to dismiss
https://docs.flutter.dev/cookbook/gestures/handling-taps/index.html
e61a53daea2d-0
Gestures Cookbook Gestures Add Material touch ripples Handle taps Implement swipe to dismiss
https://docs.flutter.dev/cookbook/gestures/index.html
13230da44f69-0
Retrieve the value of a text field Handle taps Add Material touch ripples Cookbook Gestures Add Material touch ripples Interactive example Widgets that follow the Material Design guidelines display a ripple animation when tapped. Flutter provides the InkWell widget to perform this effect. Create a ripple effect...
https://docs.flutter.dev/cookbook/gestures/ripples/index.html
05ef46d0bafe-0
Fade in images with a placeholder Use lists Work with cached images Cookbook Images Work with cached images Adding a placeholder Complete example In some cases, it’s handy to cache images as they’re downloaded from the web, so they can be used offline. For this purpose, use the cached_network_image package. No...
https://docs.flutter.dev/cookbook/images/cached-images/index.html
836ed7deb43d-0
Display images from the internet Work with cached images Fade in images with a placeholder Cookbook Images Fade in images with a placeholder In-Memory Complete example From asset bundle Complete example When displaying images using the default Image widget, you might notice they simply pop onto the screen as ...
https://docs.flutter.dev/cookbook/images/fading-in-images/index.html
836ed7deb43d-1
Complete example From asset bundle You can also consider using local assets for placeholders. First, add the asset to the project’s pubspec.yaml file (for more details, see Adding assets and images): + - assets/loading.gif Then, use the FadeInImage.assetNetwork() constructor: Complete example Display images fr...
https://docs.flutter.dev/cookbook/images/fading-in-images/index.html
e9bbcf82964e-0
Images Cookbook Images Display images from the internet Fade in images with a placeholder Work with cached images
https://docs.flutter.dev/cookbook/images/index.html
2fd7977db626-0
Implement swipe to dismiss Fade in images with a placeholder Display images from the internet Cookbook Images Display images from the internet Bonus: animated gifs Placeholders and caching Interactive example Displaying images is fundamental for most mobile apps. Flutter provides the Image widget to display di...
https://docs.flutter.dev/cookbook/images/network-image/index.html
2fd7977db626-1
Fade in images with a placeholder Work with cached images Interactive example Implement swipe to dismiss Fade in images with a placeholder
https://docs.flutter.dev/cookbook/images/network-image/index.html
bc3a44873072-0
Cookbook Animation Design Effects Forms Gestures Images Lists Maintenance Navigation Networking Persistence Plugins Testing Integration Unit Widget This cookbook contains recipes that demonstrate how to solve common problems while writing Flutter apps. Each recipe is self-contained and can be used as a ...
https://docs.flutter.dev/cookbook/index.html
bc3a44873072-1
Display a snackbar Export fonts from a package Update the UI based on orientation Use a custom font Use themes to share colors and font styles Work with tabs Effects Create a download button Create a nested navigation flow Create a photo filter carousel Create a scrolling parallax effect Create a shimmer loa...
https://docs.flutter.dev/cookbook/index.html
bc3a44873072-2
Retrieve the value of a text field Gestures Add Material touch ripples Handle taps Implement swipe to dismiss Images Display images from the internet Fade in images with a placeholder Work with cached images Lists Create a grid list Create a horizontal list Create lists with different types of items Place ...
https://docs.flutter.dev/cookbook/index.html
bc3a44873072-3
Set up app links for Android Set up universal links for iOS Return data from a screen Send data to a new screen Networking Fetch data from the internet Make authenticated requests Parse JSON in the background Send data to the internet Update data over the internet Delete data on the internet Work with WebSoc...
https://docs.flutter.dev/cookbook/index.html
bc3a44873072-4
Mock dependencies using Mockito Widget An introduction to widget testing Find widgets Handle scrolling Tap, drag, and enter text
https://docs.flutter.dev/cookbook/index.html
50010c6b7544-0
Work with cached images Create a horizontal list Use lists Cookbook Lists Use lists Create a ListView Interactive example Displaying lists of data is a fundamental pattern for mobile apps. Flutter includes the ListView widget to make working with lists a breeze. Create a ListView Using the standard ListView c...
https://docs.flutter.dev/cookbook/lists/basic-list/index.html
5c117b2fe6d0-0
Create lists with different types of items Work with long lists Place a floating app bar above a list Cookbook Lists Place a floating app bar above a list 1. Create a CustomScrollView 2. Use SliverAppBar to add a floating app bar 3. Add a list of items using a SliverList Interactive example To make it easier f...
https://docs.flutter.dev/cookbook/lists/floating-app-bar/index.html
5c117b2fe6d0-1
Moving the app bar from a Scaffold widget into a CustomScrollView allows you to create an app bar that scrolls offscreen as you scroll through a list of items contained inside the CustomScrollView. This recipe demonstrates how to use a CustomScrollView to display a list of items with an app bar on top that scrolls off...
https://docs.flutter.dev/cookbook/lists/floating-app-bar/index.html
5c117b2fe6d0-2
For this example, create a CustomScrollView that contains a SliverAppBar and a SliverList. In addition, remove any app bars that you provide to the Scaffold widget. 2. Use SliverAppBar to add a floating app bar Next, add an app bar to the CustomScrollView. Flutter provides the SliverAppBar widget which, much like the...
https://docs.flutter.dev/cookbook/lists/floating-app-bar/index.html
5c117b2fe6d0-3
Add a flexibleSpace widget that fills the available expandedHeight. Tip: Play around with the various properties you can pass to the SliverAppBar widget, and use hot reload to see the results. For example, use an Image widget for the flexibleSpace property to create a background image that shrinks in size as...
https://docs.flutter.dev/cookbook/lists/floating-app-bar/index.html
5c117b2fe6d0-4
Interactive example Create lists with different types of items Work with long lists
https://docs.flutter.dev/cookbook/lists/floating-app-bar/index.html
8f2674c9ac1b-0
Create a horizontal list Create lists with different types of items Create a grid list Cookbook Lists Create a grid list Interactive example In some cases, you might want to display your items as a grid rather than a normal list of items that come one after the next. For this task, use the GridView widget. The ...
https://docs.flutter.dev/cookbook/lists/grid-lists/index.html
6db9d15dbd28-0
Use lists Create a grid list Create a horizontal list Cookbook Lists Create a horizontal list Interactive example You might want to create a list that scrolls horizontally rather than vertically. The ListView widget supports horizontal lists. Use the standard ListView constructor, passing in a horizontal scroll...
https://docs.flutter.dev/cookbook/lists/horizontal-list/index.html
b72eaba32151-0
Lists Cookbook Lists Create a grid list Create a horizontal list Create lists with different types of items Place a floating app bar above a list Use lists Work with long lists
https://docs.flutter.dev/cookbook/lists/index.html
cebb648bb1da-0
Place a floating app bar above a list Report errors to a service Work with long lists Cookbook Lists Work with long lists 1. Create a data source 2. Convert the data source into widgets Interactive example Children’s extent The standard ListView constructor works well for small lists. To work with lists that ...
https://docs.flutter.dev/cookbook/lists/long-lists/index.html
cebb648bb1da-1
For this example, generate a list of 10,000 Strings using the List.generate constructor. 2. Convert the data source into widgets To display the list of strings, render each String as a widget using ListView.builder(). In this example, display each String on its own line. Interactive example Children’s extent To sp...
https://docs.flutter.dev/cookbook/lists/long-lists/index.html
ba32ebc3231f-0
Create a grid list Place a floating app bar above a list Create lists with different types of items Cookbook Lists Create lists with different types of items 1. Create a data source with different types of items Types of items Create a list of items 2. Convert the data source into a list of widgets Interactive...
https://docs.flutter.dev/cookbook/lists/mixed-list/index.html
ba32ebc3231f-1
Types of items To represent different types of items in a list, define a class for each type of item. In this example, create an app that shows a header followed by five messages. Therefore, create three classes: ListItem, HeadingItem, and MessageItem. Create a list of items Most of the time, you would fetch data f...
https://docs.flutter.dev/cookbook/lists/mixed-list/index.html
ba32ebc3231f-2
Interactive example Create a grid list Place a floating app bar above a list
https://docs.flutter.dev/cookbook/lists/mixed-list/index.html
86d7fc6a8769-0
Work with long lists Animate a widget across screens Report errors to a service Cookbook Maintenance Report errors to a service 1. Get a DSN from Sentry 2. Import the Sentry package 3. Initialize the Sentry SDK What does that give me? 4. Capture errors programatically Learn more Complete example While one ...
https://docs.flutter.dev/cookbook/maintenance/error-reporting/index.html
86d7fc6a8769-1
How can you determine how often your users experiences bugs? Whenever an error occurs, create a report containing the error that occurred and the associated stacktrace. You can then send the report to an error tracking service, such as Bugsnag, Fabric, Firebase Crashlytics, Rollbar, or Sentry. The error tracking servi...
https://docs.flutter.dev/cookbook/maintenance/error-reporting/index.html
86d7fc6a8769-2
To get a DSN, use the following steps: Create an account with Sentry. Log in to the account. Create a new Flutter project. Copy the code snippet that includes the DSN. 2. Import the Sentry package Import the sentry_flutter package into the app. The sentry package makes it easier to send error reports to the Sentr...
https://docs.flutter.dev/cookbook/maintenance/error-reporting/index.html
86d7fc6a8769-3
What does that give me? This is all you need for Sentry to capture unhandled errors in Dart and native layers. This includes Swift, Objective-C, C, and C++ on iOS, and Java, Kotlin, C, and C++ on Android. 4. Capture errors programatically Besides the automatic error reporting that Sentry generates by importing and i...
https://docs.flutter.dev/cookbook/maintenance/error-reporting/index.html
63688096c27b-0
Maintenance Cookbook Maintenance Report errors to a service
https://docs.flutter.dev/cookbook/maintenance/index.html
c092d5894025-0
Report errors to a service Navigate to a new screen and back Animate a widget across screens Cookbook Navigation Animate a widget across screens 1. Create two screens showing the same image 2. Add a Hero widget to the first screen 3. Add a Hero widget to the second screen Interactive example It’s often helpfu...
https://docs.flutter.dev/cookbook/navigation/hero-animations/index.html
c092d5894025-1
Add a Hero widget to the second screen. 1. Create two screens showing the same image In this example, display the same image on both screens. Animate the image from the first screen to the second screen when the user taps the image. For now, create the visual structure; handle animations in the next steps. Note: T...
https://docs.flutter.dev/cookbook/navigation/hero-animations/index.html
c092d5894025-2
3. Add a Hero widget to the second screen To complete the connection with the first screen, wrap the Image on the second screen with a Hero widget that has the same tag as the Hero in the first screen. After applying the Hero widget to the second screen, the animation between screens just works. Note: This code is...
https://docs.flutter.dev/cookbook/navigation/hero-animations/index.html
f669fabee511-0
Navigation Cookbook Navigation Animate a widget across screens Navigate to a new screen and back Navigate with named routes Pass arguments to a named route Return data from a screen Send data to a new screen Set up app links for Android Set up universal links for iOS
https://docs.flutter.dev/cookbook/navigation/index.html
98f6e20a03d5-0
Navigate to a new screen and back Pass arguments to a named route Navigate with named routes Cookbook Navigation Navigate with named routes 1. Create two screens 2. Define the routes 3. Navigate to the second screen 4. Return to the first screen Interactive example Note: Named routes are no longer recommen...
https://docs.flutter.dev/cookbook/navigation/named-routes/index.html