text stringlengths 1 372 |
|---|
<topic_end> |
<topic_start> |
updating package dependencies |
when running flutter pub get |
for the first time after adding a package, |
flutter saves the concrete package version found in the pubspec.lock |
lockfile. this ensures that you get the same version again |
if you, or another developer on your team, run flutter pub get. |
to upgrade to a new version of the package, |
for example to use new features in that package, |
run flutter pub upgrade |
to retrieve the highest available version of the package |
that is allowed by the version constraint specified in |
pubspec.yaml. |
note that this is a different command from |
flutter upgrade or flutter update-packages, |
which both update flutter itself. |
<topic_end> |
<topic_start> |
dependencies on unpublished packages |
packages can be used even when not published on pub.dev. |
for private packages, or for packages not ready for publishing, |
additional dependency options are available: |
finally, use the ref argument to pin the dependency to a |
specific git commit, branch, or tag. for more details, see |
package dependencies. |
<topic_end> |
<topic_start> |
examples |
the following examples walk through the necessary steps for |
using packages. |
<topic_end> |
<topic_start> |
example: using the css_colors package |
the css_colors package |
defines color constants for CSS colors, so use the constants |
wherever the flutter framework expects the color type. |
to use this package: |
create a new project called cssdemo. |
open pubspec.yaml, and add the css-colors dependency: |
run flutter pub get in the terminal, |
or click get packages in VS code. |
open lib/main.dart and replace its full contents with: |
<code_start> |
import 'package:css_colors/css_colors.dart'; |
import 'package:flutter/material.dart'; |
void main() { |
runApp(const MyApp()); |
} |
class MyApp extends StatelessWidget { |
const MyApp({super.key}); |
@override |
widget build(BuildContext context) { |
return const MaterialApp( |
home: DemoPage(), |
); |
} |
} |
class DemoPage extends StatelessWidget { |
const DemoPage({super.key}); |
@override |
widget build(BuildContext context) { |
return scaffold(body: container(color: CSSColors.orange)); |
} |
} |
<code_end> |
<topic_end> |
<topic_start> |
example: using the url_launcher package to launch the browser |
the url_launcher plugin package enables opening |
the default browser on the mobile platform to display |
a given URL, and is supported on android, iOS, web, |
windows, linux, and macOS. |
this package is a special dart package called a |
plugin package (or plugin), |
which includes platform-specific code. |
to use this plugin: |
create a new project called launchdemo. |
open pubspec.yaml, and add the url_launcher dependency: |
run flutter pub get in the terminal, |
or click get packages get in VS code. |
open lib/main.dart and replace its full contents with the |
following: |
<code_start> |
import 'package:flutter/material.dart'; |
import 'package:path/path.dart' as p; |
import 'package:url_launcher/url_launcher.dart'; |
void main() { |
runApp(const MyApp()); |
} |
class MyApp extends StatelessWidget { |
const MyApp({super.key}); |
@override |
widget build(BuildContext context) { |
return const MaterialApp( |
home: DemoPage(), |
); |
} |
} |
class DemoPage extends StatelessWidget { |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.