text stringlengths 1 372 |
|---|
during a build, flutter places assets into a special archive |
called the asset bundle, which apps read from at runtime. |
when an asset’s path is specified in the assets’ section of pubspec.yaml, |
the build process looks for any files |
with the same name in adjacent subdirectories. |
these files are also included in the asset bundle |
along with the specified asset. flutter uses asset variants |
when choosing resolution-appropriate images for your app. |
in react native, you would add a static image by placing the image file |
in a source code directory and referencing it. |
in flutter, add a static image to your app |
using the image.asset constructor in a widget’s build method. |
<code_start> |
image.asset('assets/background.png'); |
<code_end> |
for more information, see adding assets and images in flutter. |
<topic_end> |
<topic_start> |
how do i load images over a network? |
in react native, you would specify the uri in the |
source prop of the image component and also provide the |
size if needed. |
in flutter, use the image.network constructor to include |
an image from a URL. |
<code_start> |
image.network('https://docs.flutter.dev/assets/images/docs/owl.jpg'); |
<code_end> |
<topic_end> |
<topic_start> |
how do i install packages and package plugins? |
flutter supports using shared packages contributed by other developers to the |
flutter and dart ecosystems. this allows you to quickly build your app without |
having to develop everything from scratch. packages that contain |
platform-specific code are known as package plugins. |
in react native, you would use yarn add {package-name} or |
npm install --save {package-name} to install packages |
from the command line. |
in flutter, install a package using the following instructions: |
<code_start> |
import 'package:flutter/material.dart'; |
<code_end> |
for more information, see using packages and |
developing packages & plugins. |
you can find many packages shared by flutter developers in the |
flutter packages section of pub.dev. |
<topic_end> |
<topic_start> |
flutter widgets |
in flutter, you build your UI out of widgets that describe what their view |
should look like given their current configuration and state. |
widgets are often composed of many small, |
single-purpose widgets that are nested to produce powerful effects. |
for example, the container widget consists of |
several widgets responsible for layout, painting, positioning, and sizing. |
specifically, the container widget includes the LimitedBox, |
ConstrainedBox, align, padding, DecoratedBox, and transform widgets. |
rather than subclassing container to produce a customized effect, you can |
compose these and other simple widgets in new and unique ways. |
the center widget is another example of how you can control the layout. |
to center a widget, wrap it in a center widget and then use layout |
widgets for alignment, row, columns, and grids. |
these layout widgets do not have a visual representation of their own. |
instead, their sole purpose is to control some aspect of another |
widget’s layout. to understand why a widget renders in a |
certain way, it’s often helpful to inspect the neighboring widgets. |
for more information, see the flutter technical overview. |
for more information about the core widgets from the widgets package, |
see flutter basic widgets, |
the flutter widget catalog, |
or the flutter widget index. |
<topic_end> |
<topic_start> |
views |
<topic_end> |
<topic_start> |
what is the equivalent of the view container? |
in react native, view is a container that supports layout with flexbox, |
style, touch handling, and accessibility controls. |
in flutter, you can use the core layout widgets in the widgets |
library, such as container, column, |
row, and center. |
for more information, see the layout widgets catalog. |
<topic_end> |
<topic_start> |
what is the equivalent of FlatList or SectionList? |
a list is a scrollable list of components arranged vertically. |
in react native, FlatList or SectionList are used to render simple or |
sectioned lists. |
ListView is flutter’s most commonly used scrolling widget. |
the default constructor takes an explicit list of children. |
ListView is most appropriate for a small number of widgets. |
for a large or infinite list, use ListView.builder, |
which builds its children on demand and only builds |
those children that are visible. |
<code_start> |
var data = [ |
'hello', |
'world', |
]; |
return ListView.builder( |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.