Google I/O 刚过去,有没有想法入 Flutter 呢?Samples 收录了大量 Flutter 编写的示例,你可以学习下来 pick Flutter 的最佳实践。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
Eric Windmill fadd9b3ce7
remove cupertino gallery from ci
3 weeks ago
.gemini Cupertino gallery app (#2715) 3 months ago
.github CI fixes (#2825) 3 weeks ago
.prompts Dart 3.9 / Flutter 3.35 [first LLM release] (#2714) 9 months ago
add_to_app refactor: clean up unused imports, remove TODO comments, and format code across samples 3 weeks ago
analysis_defaults Dart 3.9 / Flutter 3.35 [first LLM release] (#2714) 9 months ago
android_splash_screen Upgrade android_splash_screen Gradle configuration (#2779) 3 weeks ago
animations refactor: remove window_size plugin and manual window configuration from samples 3 weeks ago
asset_transformation feat: initialize multi-platform Flutter project for asset transformation sample 3 weeks ago
background_isolate_channels Dart 3.9 / Flutter 3.35 [first LLM release] (#2714) 9 months ago
compass_app Dispose email and password controllers in the login screen (#2741) 3 weeks ago
cupertino_gallery refactor: clean up unused imports, remove TODO comments, and format code across samples 3 weeks ago
date_planner refactor: clean up unused imports, remove TODO comments, and format code across samples 3 weeks ago
desktop_photo_search refactor: clean up unused imports, remove TODO comments, and format code across samples 3 weeks ago
docs Dart 3.9 / Flutter 3.35 [first LLM release] (#2714) 9 months ago
dynamic_theme Upgrade Android Gradle build tools for dynamic_theme (#2799) 3 weeks ago
form_app refactor: clean up unused imports, remove TODO comments, and format code across samples 3 weeks ago
google_maps Dart 3.9 / Flutter 3.35 [first LLM release] (#2714) 9 months ago
ios_app_clip Dart 3.9 / Flutter 3.35 [first LLM release] (#2714) 9 months ago
material_3_demo refactor: clean up unused imports, remove TODO comments, and format code across samples 3 weeks ago
navigation_and_routing refactor: clean up unused imports, remove TODO comments, and format code across samples 3 weeks ago
pedometer Replace `pub run` usages with `dart run` (#2777) 3 months ago
platform_channels 3.38 / 3.10 (#2742) 6 months ago
platform_design 3.38 / 3.10 (#2742) 6 months ago
platform_view_swift Dart 3.9 / Flutter 3.35 [first LLM release] (#2714) 9 months ago
simple_shader Dart 3.9 / Flutter 3.35 [first LLM release] (#2714) 9 months ago
testing_app 3.38 / 3.10 (#2742) 6 months ago
tool CI fixes (#2825) 3 weeks ago
veggieseasons Retire VeggieSeasons (really this time) (#2724) 9 months ago
web_embedding Bump @angular/compiler-cli from 20.3.17 to 21.2.0 in /web_embedding/ng-flutter (#2813) 2 months ago
.gitattributes Add a .gitattributes file (#929) 5 years ago
.gitignore Dart 3.9 / Flutter 3.35 [first LLM release] (#2714) 9 months ago
AUTHORS Add game_template (#1180) 4 years ago
CONTRIBUTING.md docs: fix typos in CONTRIBUTING.md (#2800) 3 weeks ago
LICENSE Adding Rally App to Flutter Samples (#135) 7 years ago
PATENTS Initial commit 8 years ago
README.md refactor: remove legacy code_sharing and place_tracker 3 weeks ago
devtools_options.yaml Dart 3.9 / Flutter 3.35 [first LLM release] (#2714) 9 months ago
plan.md remove cupertino gallery from ci 3 weeks ago
pubspec.yaml remove cupertino gallery from ci 3 weeks ago

README.md

Flutter samples

Build Status

A collection of open source samples that illustrate best practices for Flutter.

Contributing

We appreciate fixes and necessary improvements to existing samples. But in most cases, we're not currently adding new samples to this repository while we rethink sample code in the new LLM world.

Please read the contributor's guide if you have contributions.

Googler's, you can freely add samples to the flutter/demos repository.

Index

Quickstarts

  • asset_transformation - Demonstrates how to transform images' color scales and formats.
  • background_isolate_channels - Demonstrates how to use long-lived isolates.
  • cupertino_gallery - A gallery of Cupertino widgets, demonstrating iOS-style UI components in Flutter.
  • date_planner - An in-progress exploration of an iOS-style Date Planner app, similar to the SwiftUI Tutorial app.
  • desktop_photo_search - Demonstrates desktop features in both Material and FluentUI design systems.
  • dynamic_theme - A developer sample demonstrating how to call on-device Flutter APIs based on output from the Gemini API.
  • form_app - A sample demonstrating different types of forms and best practices.
  • google_maps - Demonstrates the Google Maps for Flutter plugin.
  • navigation_and_routing - A sample that shows how to use go_router API to handle common navigation scenarios.
  • pedometer - A demo of a plugin that leverages FFIgen & JNIgen to call platform APIs directly from Dart code.
  • platform_design - This sample project shows a Flutter app that maximizes application code reuse while adhering to different design patterns on Android and iOS.
  • simple_shader - A simple Flutter fragment shaders sample project.
  • testing_app - A sample app that shows different types of testing in Flutter.
  • web_embedding - This directory contains examples of how to embed Flutter in web apps (without iframes).
    • element_embedding_demo - Modifies the index.html of a flutter app so it is launched in a custom hostElement. This is the most basic embedding example.
    • ng-flutter - A simple Angular app (and component) that replicates the above example, but in an Angular style.

Native platform samples

  • add-to-app - Collection of samples that demonstrate embedding Flutter a view into a native app.
    • fullscreen — Embeds a full screen instance of Flutter into an existing iOS or Android app.
    • prebuilt_module — Embeds a full screen instance of Flutter as a prebuilt library that can be loaded into an existing iOS or Android app.
    • plugin — Embeds a full screen Flutter instance that is using plugins into an existing iOS or Android app.
    • books — Mimics a real world use-case of embedding Flutter into an existing Android app and demonstrates using Pigeon to communicate between Flutter and the host application.
    • multiple_flutters — Shows the usage of the Flutter Engine Group APIs to embed multiple instances of Flutter into an existing app with low memory cost.
    • android_view — Shows how to integrate a Flutter add-to-app module at a view level for Android.
  • android_splash_screen
  • ios_app_clip
  • platform_channels - A sample app which demonstrates how to use MethodChannel, EventChannel, BasicMessageChannel and MessageCodec in Flutter.
  • platform_view_swift - A Flutter sample app that combines a native iOS UIViewController with a full-screen Flutter view.

Demo galleries

Demo apps

Flutter sample code

Samples are correct and concise code that developers can quickly understand and easily reuse with minimal side effects. Samples teach developers how to be successful using Flutter and Dart. They are maintained on an ongoing basis to reflect changing APIs and best practices.

Types of samples

There are two types of sample code in this repository:

  • Quickstarts provide a starting point to extend. They answer the question, "What is the minimal amount of code needed to implement this feature?"
  • Demo apps are meant to be built and ran. They demo the product, not how to write code.

A majority of samples in this repository are quickstarts.

Usage

Every sample in this repo is fully runnable. To run an example, use flutter run inside that example's directory. See the getting started guide to install the flutter tool.

[!IMPORTANT] If you want to run an add-to-app sample, there are additional requirements. We suggest reading the add-to-app documentation.

Interested in contributing?

See the contributor's guide!

Questions or issues?

If you have a general question about one of these samples or how to adapt its techniques for one of your own apps, try one of these resources:

If you run into a bug in one of the samples, please file an issue in the flutter/samples issue tracker.