text
stringlengths
6
13.6M
id
stringlengths
13
176
metadata
dict
__index_level_0__
int64
0
1.69k
You can also create a `.vscode/launch.json` file in your Flutter module project. This enables you to attach using the **Run > Start Debugging** command or `F5`: ```json { name: "Flutter: Attach", request: "attach", type: "dart", } ```
website/src/_includes/docs/debug/vscode-flutter-attach-json.md/0
{ "file_path": "website/src/_includes/docs/debug/vscode-flutter-attach-json.md", "repo_id": "website", "token_count": 83 }
1,412
## Check your development setup {% include docs/help-link.md location='win-doctor' %} {% assign devos = include.devos %} {% assign target = include.target %} {% assign compiler = include.compiler %} {% case devos %} {% when 'Windows' -%} {% assign terminal='PowerShell' %} {% assign prompt='C:\>' %} {% when "macOS" -%} {% assign terminal='your Terminal' %} {% assign prompt='$' %} {% else -%} {% assign terminal='a shell' %} {% assign prompt='$' %} {% endcase -%} {% case target %} {% when 'macOS','Windows','Linux' %} {% assign work-target = target | append: ' desktop' %} {% when 'desktop' %} {% assign work-target = devos | append: ' desktop' %} {% else %} {% assign work-target = target | append: ' on ' | append: devos %} {% endcase %} {% case work-target %} {% when 'macOS desktop','Web on macOS','iOS on macOS' %} {% assign compiler = 'Xcode' %} {% when 'Android on Windows','Android on macOS','Android on Linux' %} {% assign compiler = 'Android Studio' %} {% when 'Linux desktop','Web on Linux' %} {% assign compiler = 'one of the Linux libraries' %} {% when 'Windows desktop','Web on Windows' %} {% assign compiler = 'Visual Studio' %} {% endcase %} ### Run Flutter doctor The `flutter doctor` command validates that all components of a complete Flutter development environment for {{devos}}. 1. Open {{terminal}}. 1. To verify your installation of all the components, run the following command. ```terminal {{prompt}} flutter doctor ``` As you chose to develop for {{target}}, you do not need _all_ components. If you followed this guide, the result of your command should resemble: {% include docs/install/flutter-doctor-success.md config=include.config devos=devos -%} ### Troubleshoot Flutter doctor issues When the `flutter doctor` command returns an error, it could be for Flutter, VS Code, {{compiler}}, the connected device, or network resources. If the `flutter doctor` command returns an error for any of these components, run it again with the verbose flag. ```terminal {{prompt}} flutter doctor -v ``` Check the output for other software you might need to install or further tasks to perform. If you change the configuration of your Flutter SDK or its related components, run `flutter doctor` _again_ to verify the installation. ## Start developing {{work-target}} apps with Flutter Congratulations! Now that you have installed all prerequisites and the Flutter SDK, you should be able to start developing Flutter apps for {{work-target}}.
website/src/_includes/docs/install/flutter-doctor.md/0
{ "file_path": "website/src/_includes/docs/install/flutter-doctor.md", "repo_id": "website", "token_count": 774 }
1,413
{% assign target = include.target %} {% assign xcode = '[Xcode][] ' | append: site.appnow.xcode | append: ' to debug and compile native Swift or ObjectiveC code.' %} {% assign cocoapods = '[CocoaPods][] ' | append: site.appnow.cocoapods | append: ' to compile enable Flutter plugins in your native apps.' %} {% capture android %} [Android Studio][] {{site.appmin.android_studio}} to debug and compile Java or Kotlin code for Android. Flutter requires the full version of Android Studio. {% endcapture %} {% assign chrome = "[Google Chrome][] to debug JavaScript code for web apps." %} {% assign git-main = '[Git][] ' | append: site.appmin.git_mac | append: ' or later to manage source code.' %} {% assign git-xcode = "The Xcode installation includes " %} {% capture git-other %} To check if you have `git` installed, type `git version` in your Terminal. If you need to install `git`, type `brew install git`. {% endcapture %} {% case target %} {% when 'desktop','iOS' %} * {{xcode}} {{git-xcode}} {{git-main}} * {{cocoapods}} {% when 'Android' %} * {{android}} * {{git-main}} {{- git-other}} {% when 'web' -%} * {{chrome}} * {{git-main}} {{- git-other}} {% endcase %} [Git]: https://formulae.brew.sh/formula/git [Android Studio]: https://developer.android.com/studio/install#mac [Xcode]: {{site.apple-dev}}/xcode/ [CocoaPods]: https://cocoapods.org/ [Google Chrome]: https://www.google.com/chrome/dr/download/
website/src/_includes/docs/install/reqs/macos/software.md/0
{ "file_path": "website/src/_includes/docs/install/reqs/macos/software.md", "repo_id": "website", "token_count": 493 }
1,414
{% comment %} My reason for making this note an include is so that it's easier to search for it and to replace the master API links with stable API links once changes land. This has become an issue now that we maintain breaking changes docs for future releases on our site. - sz {% endcomment %} {{site.alert.note}} The following link(s) take you to the [latest docs][] on the master channel. You can find the docs for the stable channel at [api.flutter.dev][]. {{site.alert.end}} [api.flutter.dev]: {{site.api}} [latest docs]: {{site.main-api}}
website/src/_includes/docs/main-api.md/0
{ "file_path": "website/src/_includes/docs/main-api.md", "repo_id": "website", "token_count": 171 }
1,415
{% for entry in include.children -%} {% if include.active_entries and forloop.index == include.active_entries[2] -%} {% assign isActive = true -%} {% assign class = 'nav-link active' -%} {% else -%} {% assign isActive = false -%} {% assign class = 'nav-link' -%} {% endif -%} {% if entry == 'divider' -%} <div class="dropdown-divider"></div> {%- elsif entry.children -%} {% assign class = class | append: ' collapsible' -%} {% if isActive or entry.expanded -%} {% assign expanded = 'true' -%} {% assign show = 'show' -%} {% else -%} {% assign class = class | append: ' collapsed' -%} {% assign expanded = 'false' -%} {% assign show = '' -%} {% endif -%} {% assign id = include.parent_id | append: '-' | append: forloop.index -%} {% assign href = entry.permalink -%} {% unless href -%} {% assign href = '#' | append: id -%} {% endunless -%} <li class="nav-item"> <a class="{{class}}" data-toggle="collapse" data-target="#{{id}}" href="{{href}}" role="button" aria-expanded="{{expanded}}" aria-controls="{{id}}" >{{entry.title}} </a> <ul class="nav flex-column flex-nowrap collapse {{show}}" id="{{id}}"> {% if isActive -%} {% include sidenav-level-4.html parent_id=id children=entry.children active_entries=active_entries -%} {% else -%} {% include sidenav-level-4.html parent_id=id children=entry.children -%} {% endif -%} </ul> </li> {%- elsif entry.permalink -%} {% if entry.permalink contains '://' -%} {% assign isExternal = true -%} {% else -%} {% assign isExternal = false -%} {% endif -%} <li class="nav-item"> <a class="{{class}}" href="{{entry.permalink}}" {%- if isExternal %} target="_blank" rel="noopener" {%- endif -%} >{{entry.title}}</a> </li> {% endif -%} {% endfor -%}
website/src/_includes/sidenav-level-3.html/0
{ "file_path": "website/src/_includes/sidenav-level-3.html", "repo_id": "website", "token_count": 779 }
1,416
# Defines a tag that renders a code sample with multiple languages. # # This custom tag was written by the Flutter team for the Flutter website. # # Example Android usage: # # {% samplecode sample-title %} # {% sample Java %} # <?code-excerpt "MyActivity.java" title?> # ```java # // Java code here # ``` # {% sample Kotlin %} # <?code-excerpt "MyActivity.kt" title?> # ```kotlin # // Kotlin code here # ``` # {% endsamplecode %} # # Example iOS usage: # # {% samplecode sample-title %} # {% sample Objective-C %} # <?code-excerpt "MyVC.h" title?> # ```objectivec # // Header file code # ``` # <?code-excerpt "MyVC.c" title?> # ```objectivec # // Implementation file code # ``` # {% sample Swift %} # <?code-excerpt "MyVC.swift" title?> # ```swift # // Swift code here # ``` # {% endsamplecode %} # # The "samplecode" tag accepts a single parameter that represents the title of this sample. The # title is not displayed on the page, but it is injected into a number of HTML attributes to # differentiate itself from other code samples. The "samplecode" tag is a block tag and therefore # must be closed with a "endsamplecode" tag. # # The "sample" tag accepts one parameter: the name of the language as it should appear to # the reader. # # Code samples are placed directly beneath their associated "sample" tag. # # Helpful maintenance information: # # You can log with the following command: # Jekyll.logger.info("Log message") # # You can get crash stack traces with: # ./tool/serve.sh --trace # # Understanding custom tags and this class: # # There does not seem to be much documentation available for creating custom Liquid tags. The root # class "Tag" establishes a number of methods that are called at specific times by the templating # engine. The "Block" class subclasses "Tag" and adds some behavior on top of that protocol. # # The fundamental process is: # 1. The templating engine instructs the Block/Tag to "parse()" a given tag with parameters and content # - the 1st parameter, tag_name, is the literal name of the tag # - the 2nd parameter, params, is a string that includes all content that appears after the tag name in a tag. # The Liquid template engine does not parse multiple parameters for you. You have to do that, yourself. # - the 3rd parameter, tokens, is an object that understands all types of content that follows this tag, e.g., # other tags and regular text content. The tokens object is used by the Block class to find and report each # inner tag that it finds, so it should probably not be directly manipulated in this class. # # 2. The Block superclass looks for other tags within itself while parsing # a. If inner tags are found, but not recognized, then the "unknown_tag()" method is invoked. # b. This class overrides "unknown_tag()" to find inner "sample" tags. # c. For each "sample" tag, fields are set that will be processed when rendering. # # 3. The Block/Tag is instructed to "render()". The render step occurs after all parsing is complete. Therefore, # it appears that the standard workflow is to collect all needed information during parsing and then apply it # during rendering. # a. HTML for language tabs are generated for all languages that were found. # b. HTML for each code sample is generated, inserting the literal code that was written beneath the given # "sample" tag. # c. The generated code is returned form the "render()" function. # # Reading the source code for Tag, Block, and BlockBody will be helpful in understanding this code. In the # Liquid project, those classes can be found at: # # - lib/liquid/tag.rb # - lib/liquid/block.rb # - lib/liquid/block_body.rb module Jekyll class SampleCode < Liquid::Block def initialize(tag_name, params, tokens) super # Title that differentiates this code sample from others on the page. @title = params.strip # Info needed to render the HTML for the language tabs above the sample. @tabs = CodeTabsBlock.new(@title) # Info needed to render each per-language code sample. @codeBlocks = [] # List of BlockBody's to facilitate the standard parsing process. @blocks = [] @blocks << @tabs end # Invoked by the superclass throughout the parsing process. The nodelist # represents the mutating data structure that is being filled during parsing. # # By default the super class has a single BodyBlock and that BodyBlock's internal # nodelist is used here. We override that behavior, offering our own list, which # allows us to construct a list of various kinds of BodyBlocks, e.g., CodeTabBlock # and CodeBlocks. def nodelist @blocks end # Invoked by the superclass to parse this tags contents. # # We override this method to force parsing to use our @blocks list. def parse(tokens) while parse_body(@blocks.last, tokens) end end # Invoked by the superclass as it parses the content block and # finds additional Liquid tags. def unknown_tag(name, params, tokens) if name == "sample" language = params.strip codeBlock = CodeBlock.new(@title, language) @tabs.addLanguage(language) @codeBlocks << codeBlock @blocks << codeBlock else super end end def render(context) output = "" output += @tabs.render(context) + "\n" # Start rendering code blocks with an appropriate div. output += "<div class=\"tab-content\">" + "\n" # We want to display the first code block when the page loads. To do that # we tell the first code block that it is active, which will generate the # appropriate HTML to display itself. @codeBlocks[0].is_active = true # Render all language code blocks. for codeBlock in @codeBlocks do output += codeBlock.render(context) + "\n" end # Close the code blocks div. output += "</div>\n" # Return the rendered output output.strip end end class CodeTabsBlock < Liquid::BlockBody def initialize(title) super() @title = title @languages = [].to_set end def addLanguage(language) @languages << language end def language_as_id(language) language_sanitized = language.downcase language_sanitized.gsub(/\+/, "-plus") end def render(context) output = %Q(<ul class="nav nav-tabs sample-code-tabs" id="#{@title}-language" role="tablist">) is_active = true for language in @languages language_id = language_as_id(language) output += %Q( <li class="nav-item"> <a class="nav-link #{is_active ? "active" : ""}" id="#{@title}-#{language_id}" href="\##{@title}-#{language_id}-tab" role="tab" aria-controls="#{@title}-#{language_id}" aria-selected="true">#{language}</a> </li> ) is_active = false end output += "</ul>" output.strip end end class CodeBlock < Liquid::BlockBody attr_reader :language_name attr_accessor :is_active def initialize(title, language_name) super() @title = title @language_name = language_name @is_active = false end def language_as_id(language) language_sanitized = language.downcase language_sanitized.gsub(/\+/, "-plus") end def render(context) code = super language_id = language_as_id(@language_name) %Q( <div class="tab-pane #{@is_active ? "active" : ""}" id="#{@title}-#{language_id}-tab" role="tabpanel" aria-labelledby="#{@title}-#{language_id}-tab" markdown="1"> #{code} </div> ) end end end Liquid::Template.register_tag('samplecode', Jekyll::SampleCode)
website/src/_plugins/code_tabs.rb/0
{ "file_path": "website/src/_plugins/code_tabs.rb", "repo_id": "website", "token_count": 3222 }
1,417
@use 'sass:color'; @use '../base/variables' as *; @use '../base/material-colors' as *; @use '../vendor/bootstrap'; @use '../vendor/prettify'; @mixin pre-defaults { background-color: $site-color-codeblock-bg; padding: bootstrap.bs-spacer(3) bootstrap.bs-spacer(4); } $flutter-color-teal-darker: color.scale($flutter-color-teal, $lightness: -10%, $saturation: 10%); // // Code-prettyprint overrides // pre { &.prettyprint { @include pre-defaults; border: none; } .highlight { background: $flutter-color-yellow; padding: 2px; } } .pln { color: #222 } /* plain text */ @media screen { .str { color: $flutter-color-blue-600 } /* string content */ .kwd { color: $flutter-color-teal } /* a keyword */ .com { color: #6e6e70 } /* a comment */ /* punctuation, lisp open bracket, lisp close bracket */ .pun, .opn, .clo { color: #222 } } // // Rouge / pygments classes -- https://github.com/jneen/rouge // // For CSS class names, see // - https://github.com/rouge-ruby/rouge/blob/master/lib/rouge/token.rb // - https://github.com/rouge-ruby/rouge/wiki/List-of-tokens, doc page, // but doesn't seem to be as complete as token.rb. // $generic-output-color: #8ae234; @mixin console-base($color: $light-green-A700) { background: $grey-900; color: $color; } .language-console .highlight { @include console-base; .go { color: $generic-output-color; } /* Generic.Output */ } pre.console-output { @include console-base($generic-output-color) } // `terminal` is like `console` with prompts and output colored differently .language-terminal .highlight { @include console-base; .gp { color: $flutter-color-yellow; font-weight: 700; } /* Generic.Prompt */ .go { color: $generic-output-color; } /* Generic.Output */ .k, .kc, .kd, .kn, .kp, .kr, .kt { color: $flutter-color-blue-on-dark; } /* Keyword.* */ .nb, .nt { color: $flutter-color-blue-on-dark; } /* Name.Builtin, Name.Tag */ .nv { color: #03bbbb; } .o { color: $flutter-color-grey-500; font-weight: bold; } /* Operator */ .s, .s1, .s2 { color: $flutter-color-blue-on-dark; } /* String, .Single, .Double quotes */ .sb { color: $flutter-color-light-blue; } /* String.Backtick */ } // Match code-prettify classes to the extent possible. .highlight { .s, .s1, .s2 { @extend .str; } /* Literal.String.* */ .k, .kc, .kd, .kn, .kp, .kr, .kt { @extend .kwd; } /* Keyword.* */ .p { @extend .pun; } /* Punctuation */ .c, .c1, .cm { @extend .com; } /* Comment */ .cp { @extend .typ; } /* Comment.Preproc */ .l, .m, .mb, .mf, .mh, .mi, .mo, .mx { @extend .lit; } /* Literal.* */ .o { @extend .opn; } /* Operator */ .n { @extend .typ; } /* Name */ .na { @extend .kwd; } /* Name.Attribute */ .nb { @extend .typ; } /* Name.Builtin */ .nl { @extend .kwd; } /* Name.Label */ .no { @extend .lit; } /* Name.Constant */ .nt { @extend .tag; } /* Name.Tag */ .gp { user-select: none; } /* Generic.Prompt */ } code { color: $flutter-color-teal-darker; } pre { @include pre-defaults; } // Give code blocks the same margin-bottom as regular paragraphs. div.highlighter-rouge { margin-bottom: bootstrap.bs-spacer(4); } pre > span.strike { text-decoration: line-through; } .numbered-code-notes { list-style-type: none; padding-left: 0; display: table; li { counter-increment: code-note-counter; display: table-row; padding-left: 8px; &:before { font-family: bootstrap.$font-family-monospace; content: '/*' counter(code-note-counter) '*/' ; display: table-cell; text-align: right; color: bootstrap.$teal; padding-right: bootstrap.$font-size-base * 0.5; // background-color: lightyellow; } } } @mixin code-excerpt-border($side: '') { border#{$side}: bootstrap.$border-width solid bootstrap.$border-color; } .code-excerpt { &__code { margin-bottom: bootstrap.bs-spacer(4); position: relative; pre { @include code-excerpt-border; background-color: $site-color-codeblock-bg; margin-bottom: 0; } } &__copy-btn { background: transparent; border: none; cursor: pointer; color: lighten($site-color-body, 20%); // Offers better contrast on dark bg margin-top: bootstrap.bs-spacer(2); outline: none !important; position: absolute; right: 0; } &__header { background-color: bootstrap.$gray-200; @include code-excerpt-border('-top'); @include code-excerpt-border('-left'); @include code-excerpt-border('-right'); font-size: $site-spacer * .875; font-weight: bootstrap.$font-weight-bold; padding: bootstrap.bs-spacer(3) bootstrap.bs-spacer(2) 0.67rem bootstrap.bs-spacer(4); } }
website/src/_sass/components/_code.scss/0
{ "file_path": "website/src/_sass/components/_code.scss", "repo_id": "website", "token_count": 1893 }
1,418
The concept of an initial route is available when configuring a `FlutterActivity` or a `FlutterFragment` with a new `FlutterEngine`. However, `FlutterActivity` and `FlutterFragment` don't offer the concept of an initial route when using a cached engine. This is because a cached engine is expected to already be running Dart code, which means it's too late to configure the initial route. Developers that would like their cached engine to begin with a custom initial route can configure their cached `FlutterEngine` to use a custom initial route just before executing the Dart entrypoint. The following example demonstrates the use of an initial route with a cached engine: {% samplecode cached-engine-with-initial-route %} {% sample Java %} <?code-excerpt title="MyApplication.java"?> ```java public class MyApplication extends Application { @Override public void onCreate() { super.onCreate(); // Instantiate a FlutterEngine. flutterEngine = new FlutterEngine(this); // Configure an initial route. flutterEngine.getNavigationChannel().setInitialRoute("your/route/here"); // Start executing Dart code to pre-warm the FlutterEngine. flutterEngine.getDartExecutor().executeDartEntrypoint( DartEntrypoint.createDefault() ); // Cache the FlutterEngine to be used by FlutterActivity or FlutterFragment. FlutterEngineCache .getInstance() .put("my_engine_id", flutterEngine); } } ``` {% sample Kotlin %} <?code-excerpt title="MyApplication.kt"?> ```kotlin class MyApplication : Application() { lateinit var flutterEngine : FlutterEngine override fun onCreate() { super.onCreate() // Instantiate a FlutterEngine. flutterEngine = FlutterEngine(this) // Configure an initial route. flutterEngine.navigationChannel.setInitialRoute("your/route/here"); // Start executing Dart code to pre-warm the FlutterEngine. flutterEngine.dartExecutor.executeDartEntrypoint( DartExecutor.DartEntrypoint.createDefault() ) // Cache the FlutterEngine to be used by FlutterActivity or FlutterFragment. FlutterEngineCache .getInstance() .put("my_engine_id", flutterEngine) } } ``` {% endsamplecode %} By setting the initial route of the navigation channel, the associated `FlutterEngine` displays the desired route upon initial execution of the `runApp()` Dart function. Changing the initial route property of the navigation channel after the initial execution of `runApp()` has no effect. Developers who would like to use the same `FlutterEngine` between different `Activity`s and `Fragment`s and switch the route between those displays need to set up a method channel and explicitly instruct their Dart code to change `Navigator` routes.
website/src/add-to-app/android/_initial-route-cached-engine.md/0
{ "file_path": "website/src/add-to-app/android/_initial-route-cached-engine.md", "repo_id": "website", "token_count": 798 }
1,419
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!-- Generator: Adobe Illustrator 27.7.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> <svg version="1.1" id="Layer_1" x="0px" y="0px" width="0.5in" height="0.5in" viewBox="0 0 47.998463 47.998464" xml:space="preserve" sodipodi:docname="macos-bug.svg" inkscape:version="1.3.2 (091e20e, 2023-11-25)" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"><defs id="defs1" /><sodipodi:namedview id="namedview1" pagecolor="#ffffff" bordercolor="#000000" borderopacity="0.25" inkscape:showpageshadow="2" inkscape:pageopacity="0.0" inkscape:pagecheckerboard="0" inkscape:deskcolor="#d1d1d1" inkscape:zoom="6.2421875" inkscape:cx="49.341677" inkscape:cy="30.518148" inkscape:window-width="1248" inkscape:window-height="942" inkscape:window-x="0" inkscape:window-y="25" inkscape:window-maximized="0" inkscape:current-layer="Layer_1" inkscape:document-units="in" /> <style type="text/css" id="style1"> .st0{fill:#027DFD;} </style> <path class="st0" d="m 36.916996,25.298993 c -0.02037,-3.743989 1.673063,-6.569826 5.100796,-8.65095 -1.9179,-2.744225 -4.815147,-4.254059 -8.640742,-4.549905 -3.621562,-0.285645 -7.57978,2.111729 -9.028404,2.111729 -1.530239,0 -5.039585,-2.009712 -7.794012,-2.009712 -5.692486,0.09181 -11.7420264,4.539704 -11.7420264,13.588512 0,2.672812 0.4896762,5.437445 1.4690288,8.283683 1.3058028,3.743989 6.0189356,12.925414 10.9360996,12.772389 2.5708,-0.06121 4.386681,-1.82608 7.732803,-1.82608 3.244103,0 4.927368,1.82608 7.794008,1.82608 4.957977,-0.0714 9.222237,-8.416308 10.466831,-12.170493 -6.651432,-3.131888 -6.294382,-9.181424 -6.294382,-9.375253 z M 31.142903,8.5479857 c 2.785034,-3.3053138 2.529992,-6.3147814 2.448376,-7.396149 -2.458582,0.1428218 -5.30482,1.6730608 -6.926874,3.5603541 -1.785279,2.0199134 -2.836041,4.5193013 -2.611606,7.3349392 2.662612,0.204031 5.090588,-1.162981 7.090104,-3.4991443 z" id="path1" style="fill:#027dfd;fill-opacity:1;stroke-width:0.102016" /> </svg>
website/src/assets/images/docs/brand-svg/macos-bug.svg/0
{ "file_path": "website/src/assets/images/docs/brand-svg/macos-bug.svg", "repo_id": "website", "token_count": 1149 }
1,420
const oldToNew = { 'ios-setup': '/get-started/install/macos/mobile-ios', 'set-up-the-ios-simulator': '/get-started/install/macos/mobile-ios#configure-your-target-ios-device', 'deploy-to-physical-ios-devices': '/deployment/ios', 'deploy-to-ios-devices': '/deployment/ios', 'macos-setup': '/get-started/install/macos/desktop', 'android-setup': '/get-started/install/macos/mobile-android#configure-android-development', 'set-up-your-android-device': '/get-started/install/macos/mobile-android#configure-your-target-android-device', 'set-up-the-android-emulator': '/get-started/install/macos/mobile-android#configure-your-target-android-device', 'agree-to-android-licenses': '/get-started/install/macos/mobile-android#agree-to-android-licenses', }; function handleRedirect() { const rawOldFragment = window.location.hash; // If no fragment was specified, don't do anything. if (!rawOldFragment) { return; } const oldFragmentWithHash = rawOldFragment.trim().toLowerCase(); // If the fragment is empty, don't do anything. if (oldFragmentWithHash.length === 0) { return; } const oldFragment = oldFragmentWithHash.substring(1); // If the fragment did not exist, don't do anything. if (!(oldFragment in oldToNew)) { return; } const newDestination = oldToNew[oldFragment]; // If the desired destination exists, go there. // Otherwise, don't go anywhere. fetch(newDestination) .then((response) => { if (response.status === 200) { window.location.replace(newDestination); } }).catch((_) => { }); } const currentLocation = window.location.pathname; if (currentLocation.includes('/get-started/install/macos') && currentLocation.split('/') .filter(value => value.trim().length !== 0).length === 3) { handleRedirect(); }
website/src/assets/js/temp/macos-install-redirector.js/0
{ "file_path": "website/src/assets/js/temp/macos-install-redirector.js", "repo_id": "website", "token_count": 642 }
1,421
--- title: Use a custom font description: How to use custom fonts. --- <?code-excerpt path-base="cookbook/design/fonts/"?> {{site.alert.secondary}} ## What you'll learn * How to choose a font. * How to import font files. * How to set a font as a default. * How to use a font in a given widget. {{site.alert.end}} Although Android and iOS offer high quality system fonts, designers want support for custom fonts. You might have a custom-built font from a designer, or perhaps you downloaded a font from [Google Fonts][]. A typeface is the collection of glyphs or shapes that comprise a given style of lettering. A font is one representation of that typeface at a given weight or variation. Roboto is a typeface and Roboto Bold is a font. Flutter lets you apply a custom font across an entire app or to individual widgets. This recipe creates an app that uses custom fonts with the following steps. 1. Choose your fonts. 1. Import the font files. 1. Declare the font in the pubspec. 1. Set a font as the default. 1. Use a font in a specific widget. You don't need to follow each step as you go. The guide offers completed example files at the end. {{site.alert.note}} This guide makes the following presumptions: 1. You've [set up your Flutter environment][]. 1. You've [created a new Flutter app][new-flutter-app] named `custom_fonts`. If you haven't completed these steps yet, do so before continuing with this guide. 1. You're performing the provided commands in a macOS or Linux shell and using `vi`. You can substitute any text editor for `vi`. Windows users should use the appropriate commands and paths when performing the steps. 1. You're adding the Raleway and RobotoMono fonts to your Flutter app. {{site.alert.end}} [set up your Flutter environment]: /get-started/install [new-flutter-app]: /get-started/test-drive ## Choose a font Your choice of font should be more than a preference. Consider which file formats work with Flutter and how the font could affect design options and app performance. #### Pick a supported font format Flutter supports the following font formats: * OpenType font collections: `.ttc` * TrueType fonts: `.ttf` * OpenType fonts: `.otf` Flutter does not support fonts in the Web Open Font Format, `.woff` and `.woff2`, on desktop platforms. #### Choose fonts for their specific benefits Few sources agree on what a font file type is or which uses less space. The key difference between font file types involves how the format encodes the glyphs in the file. Most TrueType and OpenType font files have similar capabilities as they borrowed from each other as the formats and fonts improved over time. Which font you should use depends on the following considerations. * How much variation you need for fonts in your app? * How much file size you can accept fonts using in your app? * How many languages you need to support in your app? Research what options a given font offers, like more than one weight or style per font file, [variable font capability][variable-fonts], the availability of multiple font files for a multiple font weights, or more than one width per font. Choose the typeface or font family that meets the design needs of your app. {{site.alert.secondary}} To learn how to get direct access to over 1,000 open-sourced font families, check out the [google_fonts][] package. <iframe class="full-width" src="{{site.yt.embed}}/8Vzv2CdbEY0" title="Learn about the google_fonts Flutter Package" {{site.yt.set}}></iframe> To learn about another approach to using custom fonts that allows you to re-use one font over multiple projects, check out [Export fonts from a package][]. {{site.alert.end}} ## Import the font files To work with a font, import its font files into your Flutter project. To import font files, perform the following steps. 1. If necessary, to match the remaining steps in this guide, change the name of your Flutter app to `custom_fonts`. ```terminal $ mv /path/to/my_app /path/to/custom_fonts ``` 1. Navigate to the root of your Flutter project. ```terminal $ cd /path/to/custom_fonts ``` 1. Create a `fonts` directory at the root of your Flutter project. ```terminal $ mkdir fonts ``` 1. Move or copy the font files in a `fonts` or `assets` folder at the root of your Flutter project. ```terminal $ cp ~/Downloads/*.ttf ./fonts ``` The resulting folder structure should resemble the following: ```nocode custom_fonts/ |- fonts/ |- Raleway-Regular.ttf |- Raleway-Italic.ttf |- RobotoMono-Regular.ttf |- RobotoMono-Bold.ttf ``` ## Declare the font in the pubspec.yaml file After you've downloaded a font, include a font definition in the `pubspec.yaml` file. This font definition also specifies which font file should be used to render a given weight or style in your app. ### Define fonts in the `pubspec.yaml` file To add font files to your Flutter app, complete the following steps. 1. Open the `pubspec.yaml` file at the root of your Flutter project. ```terminal $ vi pubspec.yaml ``` 1. Paste the following YAML block after the `flutter` declaration. ```yaml fonts: - family: Raleway fonts: - asset: fonts/Raleway-Regular.ttf - asset: fonts/Raleway-Italic.ttf style: italic - family: RobotoMono fonts: - asset: fonts/RobotoMono-Regular.ttf - asset: fonts/RobotoMono-Bold.ttf weight: 700 ``` This `pubspec.yaml` file defines the italic style for the `Raleway` font family as the `Raleway-Italic.ttf` font file. When you set `style: TextStyle(fontStyle: FontStyle.italic)`, Flutter swaps `Raleway-Regular` with `Raleway-Italic`. The `family` value sets the name of the typeface. You use this name in the [`fontFamily`][] property of a [`TextStyle`][] object. The value of an `asset` is a relative path from the `pubspec.yaml` file to the font file. These files contain the outlines for the glyphs in the font. When building the app, Flutter includes these files in the app's asset bundle. ### Include font files for each font Different typefaces implement font files in different ways. If you need a typeface with a variety of font weights and styles, choose and import font files that represent that variety. When you import a font file that doesn't include either multiple fonts within it or variable font capabilities, don't use the `style` or `weight` property to adjust how they display. If you do use those properties on a regular font file, Flutter attempts to _simulate_ the look. The visual result will look quite different from using the correct font file. ### Set styles and weights with font files When you declare which font files represent styles or weights of a font, you can apply the `style` or `weight` properties. #### Set font weight The `weight` property specifies the weight of the outlines in the file as an integer multiple of 100, between 100 and 900. These values correspond to the [`FontWeight`][] and can be used in the [`fontWeight`][fontWeight property] property of a [`TextStyle`][] object. In the `pubspec.yaml` shown in this guide, you defined `RobotoMono-Bold` as the `700` weight of the font family. To use the `RobotoMono-Bold` font that you added to your app, set `fontWeight` to `FontWeight.w700` in your `TextStyle` widget. If hadn't added `RobotoMono-Bold` to your app, Flutter attempts to make the font look bold. The text then might appear to be somewhat darker. You can't use the `weight` property to override the weight of the font. You can't set `RobotoMono-Bold` to any other weight than `700`. If you set `TextStyle(fontFamily: 'RobotoMono', fontWeight: FontWeight.w900)`, the displayed font would still render as however bold `RobotoMono-Bold` looks. #### Set font style The `style` property specifies whether the glyphs in the font file display as either `italic` or `normal`. These values correspond to the [`FontStyle`][]. You can use these styles in the [`fontStyle`][fontStyle property] property of a [`TextStyle`][] object. In the `pubspec.yaml` shown in this guide, you defined `Raleway-Italic` as being in the `italic` style. To use the `Raleway-Italic` font that you added to your app, set `style: TextStyle(fontStyle: FontStyle.italic)`. Flutter swaps `Raleway-Regular` with `Raleway-Italic` when rendering. If hadn't added `Raleway-Italic` to your app, Flutter attempts to make the font _look_ italic. The text then might appear to be leaning to the right. You can't use the `style` property to override the glyphs of a font. If you set `TextStyle(fontFamily: 'Raleway', fontStyle: FontStyle.normal)`, the displayed font would still render as italic. The `regular` style of an italic font _is_ italic. ## Set a font as the default To apply a font to text, you can set the font as the app's default font in its `theme`. To set a default font, set the `fontFamily` property in the app's `theme`. Match the `fontFamily` value to the `family` name declared in the `pubspec.yaml` file. The result would resemble the following code. <?code-excerpt "lib/main.dart (MaterialApp)"?> ```dart return MaterialApp( title: 'Custom Fonts', // Set Raleway as the default app font. theme: ThemeData(fontFamily: 'Raleway'), home: const MyHomePage(), ); ``` To learn more about themes, check out the [Using Themes to share colors and font styles][] recipe. ## Set the font in a specific widget To apply the font to a specific widget like a `Text` widget, provide a [`TextStyle`][] to the widget. For this guide, try to apply the `RobotoMono` font to a single `Text` widget. Match the `fontFamily` value to the `family` name declared in the `pubspec.yaml` file. The result would resemble the following code. <?code-excerpt "lib/main.dart (Text)"?> ```dart child: Text( 'Roboto Mono sample', style: TextStyle(fontFamily: 'RobotoMono'), ), ``` {{site.alert.important}} If a [`TextStyle`][] object specifies a weight or style without a corresponding font file, the engine uses a generic file for the font and attempts to extrapolate outlines for the requested weight and style. Avoid relying on this capability. Import the proper font file instead. {{site.alert.end}} ## Try the complete example ### Download fonts Download the Raleway and RobotoMono font files from [Google Fonts][]. ### Update the `pubspec.yaml` file 1. Open the `pubspec.yaml` file at the root of your Flutter project. ```terminal $ vi pubspec.yaml ``` 1. Replace its contents with the following YAML. ```yaml name: custom_fonts description: An example of how to use custom fonts with Flutter dependencies: flutter: sdk: flutter dev_dependencies: flutter_test: sdk: flutter flutter: fonts: - family: Raleway fonts: - asset: fonts/Raleway-Regular.ttf - asset: fonts/Raleway-Italic.ttf style: italic - family: RobotoMono fonts: - asset: fonts/RobotoMono-Regular.ttf - asset: fonts/RobotoMono-Bold.ttf weight: 700 uses-material-design: true ``` ### Use this `main.dart` file 1. Open the `main.dart` file in the `lib/` directory of your Flutter project. ```terminal $ vi lib/main.dart ``` 1. Replace its contents with the following Dart code. <?code-excerpt "lib/main.dart"?> ```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 MaterialApp( title: 'Custom Fonts', // Set Raleway as the default app font. theme: ThemeData(fontFamily: 'Raleway'), home: const MyHomePage(), ); } } class MyHomePage extends StatelessWidget { const MyHomePage({super.key}); @override Widget build(BuildContext context) { return Scaffold( // The AppBar uses the app-default Raleway font. appBar: AppBar(title: const Text('Custom Fonts')), body: const Center( // This Text widget uses the RobotoMono font. child: Text( 'Roboto Mono sample', style: TextStyle(fontFamily: 'RobotoMono'), ), ), ); } } ``` The resulting Flutter app should display the following screen. ![Custom Fonts Demo](/assets/images/docs/cookbook/fonts.png){:.site-mobile-screenshot} [variable-fonts]: https://fonts.google.com/knowledge/introducing_type/introducing_variable_fonts [Export fonts from a package]: /cookbook/design/package-fonts [`fontFamily`]: {{site.api}}/flutter/painting/TextStyle/fontFamily.html [fontStyle property]: {{site.api}}/flutter/painting/TextStyle/fontStyle.html [`FontStyle`]: {{site.api}}/flutter/dart-ui/FontStyle.html [fontWeight property]: {{site.api}}/flutter/painting/TextStyle/fontWeight.html [`FontWeight`]: {{site.api}}/flutter/dart-ui/FontWeight-class.html [Google Fonts]: https://fonts.google.com [google_fonts]: {{site.pub-pkg}}/google_fonts [`TextStyle`]: {{site.api}}/flutter/painting/TextStyle-class.html [Using Themes to share colors and font styles]: /cookbook/design/themes
website/src/cookbook/design/fonts.md/0
{ "file_path": "website/src/cookbook/design/fonts.md", "repo_id": "website", "token_count": 4351 }
1,422
--- title: Create a staggered menu animation description: How to implement a staggered menu animation. js: - defer: true url: https://old-dartpad-3ce3f.web.app/inject_embed.dart.js --- <?code-excerpt path-base="cookbook/effects/staggered_menu_animation"?> A single app screen might contain multiple animations. Playing all of the animations at the same time can be overwhelming. Playing the animations one after the other can take too long. A better option is to stagger the animations. Each animation begins at a different time, but the animations overlap to create a shorter duration. In this recipe, you build a drawer menu with animated content that is staggered and has a button that pops in at the bottom. The following animation shows the app's behavior: ![Staggered Menu Animation Example](/assets/images/docs/cookbook/effects/StaggeredMenuAnimation.gif){:.site-mobile-screenshot} ## 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. <?code-excerpt "lib/step1.dart (step1)"?> ```dart class Menu extends StatefulWidget { const Menu({super.key}); @override State<Menu> createState() => _MenuState(); } class _MenuState extends State<Menu> { static const _menuTitles = [ 'Declarative Style', 'Premade Widgets', 'Stateful Hot Reload', 'Native Performance', 'Great Community', ]; @override Widget build(BuildContext context) { return Container( color: Colors.white, child: Stack( fit: StackFit.expand, children: [ _buildFlutterLogo(), _buildContent(), ], ), ); } Widget _buildFlutterLogo() { // TODO: We'll implement this later. return Container(); } Widget _buildContent() { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const SizedBox(height: 16), ..._buildListItems(), const Spacer(), _buildGetStartedButton(), ], ); } List<Widget> _buildListItems() { final listItems = <Widget>[]; for (var i = 0; i < _menuTitles.length; ++i) { listItems.add( Padding( padding: const EdgeInsets.symmetric(horizontal: 36, vertical: 16), child: Text( _menuTitles[i], textAlign: TextAlign.left, style: const TextStyle( fontSize: 24, fontWeight: FontWeight.w500, ), ), ), ); } return listItems; } Widget _buildGetStartedButton() { return SizedBox( width: double.infinity, child: Padding( padding: const EdgeInsets.all(24), child: ElevatedButton( style: ElevatedButton.styleFrom( shape: const StadiumBorder(), backgroundColor: Colors.blue, padding: const EdgeInsets.symmetric(horizontal: 48, vertical: 14), ), onPressed: () {}, child: const Text( 'Get Started', style: TextStyle( color: Colors.white, fontSize: 22, ), ), ), ), ); } } ``` ## Prepare for animations Control of the animation timing requires an `AnimationController`. Add the `SingleTickerProviderStateMixin` to the `MenuState` class. Then, declare and instantiate an `AnimationController`. <?code-excerpt "lib/step2.dart (AnimationController)" replace="/}\n/}\n}\n/g;"?> ```dart class _MenuState extends State<Menu> with SingleTickerProviderStateMixin { late AnimationController _staggeredController; @override void initState() { super.initState(); _staggeredController = AnimationController( vsync: this, ); } } @override void dispose() { _staggeredController.dispose(); super.dispose(); } } ``` The length of the delay before every animation is up to you. Define the animation delays, individual animation durations, and the total animation duration. <?code-excerpt "lib/animation_delays.dart (delays)" replace="/_buttonTime;\n/_buttonTime;\n}/g;"?> ```dart class _MenuState extends State<Menu> with SingleTickerProviderStateMixin { static const _initialDelayTime = Duration(milliseconds: 50); static const _itemSlideTime = Duration(milliseconds: 250); static const _staggerTime = Duration(milliseconds: 50); static const _buttonDelayTime = Duration(milliseconds: 150); static const _buttonTime = Duration(milliseconds: 500); final _animationDuration = _initialDelayTime + (_staggerTime * _menuTitles.length) + _buttonDelayTime + _buttonTime; } ``` 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 waits another 150 ms to pop in. The button animation takes 500 ms. With each delay and animation duration defined, the total duration is calculated so that it can be used to calculate the individual animation times. The desired animation times are shown in the following diagram: ![Animation Timing Diagram](/assets/images/docs/cookbook/effects/TimingDiagram.png){:.site-mobile-screenshot} 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, instead of using the entire animation's start and end times. For example, given an animation that takes 1 second, an interval from 0.2 to 0.5 would start at 200 ms (20%) and end at 500 ms (50%). Declare and calculate each list item's `Interval` and the bottom button `Interval`. <?code-excerpt "lib/step3.dart (step3)" replace="/\/\/code-excerpt-close-bracket/\n}/g;"?> ```dart class _MenuState extends State<Menu> with SingleTickerProviderStateMixin { final List<Interval> _itemSlideIntervals = []; late Interval _buttonInterval; @override void initState() { super.initState(); _createAnimationIntervals(); _staggeredController = AnimationController( vsync: this, duration: _animationDuration, ); } void _createAnimationIntervals() { for (var i = 0; i < _menuTitles.length; ++i) { final startTime = _initialDelayTime + (_staggerTime * i); final endTime = startTime + _itemSlideTime; _itemSlideIntervals.add( Interval( startTime.inMilliseconds / _animationDuration.inMilliseconds, endTime.inMilliseconds / _animationDuration.inMilliseconds, ), ); } final buttonStartTime = Duration(milliseconds: (_menuTitles.length * 50)) + _buttonDelayTime; final buttonEndTime = buttonStartTime + _buttonTime; _buttonInterval = Interval( buttonStartTime.inMilliseconds / _animationDuration.inMilliseconds, buttonEndTime.inMilliseconds / _animationDuration.inMilliseconds, ); } } ``` ## Animate the list items and button The staggered animation plays as soon as the menu becomes visible. Start the animation in `initState()`. <?code-excerpt "lib/step4.dart (initState)"?> ```dart @override void initState() { super.initState(); _createAnimationIntervals(); _staggeredController = AnimationController( vsync: this, duration: _animationDuration, )..forward(); } ``` 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. <?code-excerpt "lib/step4.dart (buildListItems)"?> ```dart List<Widget> _buildListItems() { final listItems = <Widget>[]; for (var i = 0; i < _menuTitles.length; ++i) { listItems.add( AnimatedBuilder( animation: _staggeredController, builder: (context, child) { final animationPercent = Curves.easeOut.transform( _itemSlideIntervals[i].transform(_staggeredController.value), ); final opacity = animationPercent; final slideDistance = (1.0 - animationPercent) * 150; return Opacity( opacity: opacity, child: Transform.translate( offset: Offset(slideDistance, 0), child: child, ), ); }, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 36, vertical: 16), child: Text( _menuTitles[i], textAlign: TextAlign.left, style: const TextStyle( fontSize: 24, fontWeight: FontWeight.w500, ), ), ), ), ); } return listItems; } ``` Use the same approach to animate the opacity and scale of the bottom button. This time, use an `elasticOut` curve to give the button a springy effect. <?code-excerpt "lib/step4.dart (buildGetStartedButton)"?> ```dart Widget _buildGetStartedButton() { return SizedBox( width: double.infinity, child: Padding( padding: const EdgeInsets.all(24), child: AnimatedBuilder( animation: _staggeredController, builder: (context, child) { final animationPercent = Curves.elasticOut.transform( _buttonInterval.transform(_staggeredController.value)); final opacity = animationPercent.clamp(0.0, 1.0); final scale = (animationPercent * 0.5) + 0.5; return Opacity( opacity: opacity, child: Transform.scale( scale: scale, child: child, ), ); }, child: ElevatedButton( style: ElevatedButton.styleFrom( shape: const StadiumBorder(), backgroundColor: Colors.blue, padding: const EdgeInsets.symmetric(horizontal: 48, vertical: 14), ), onPressed: () {}, child: const Text( 'Get Started', style: TextStyle( color: Colors.white, fontSize: 22, ), ), ), ), ), ); } ``` Congratulations! You have an animated menu where the appearance of each list item is staggered, followed by a bottom button that pops into place. ## Interactive example <?code-excerpt "lib/main.dart"?> ```run-dartpad:theme-light:mode-flutter:run-true:width-100%:height-600px:split-60:ga_id-interactive_example import 'package:flutter/material.dart'; void main() { runApp( const MaterialApp( home: ExampleStaggeredAnimations(), debugShowCheckedModeBanner: false, ), ); } class ExampleStaggeredAnimations extends StatefulWidget { const ExampleStaggeredAnimations({ super.key, }); @override State<ExampleStaggeredAnimations> createState() => _ExampleStaggeredAnimationsState(); } class _ExampleStaggeredAnimationsState extends State<ExampleStaggeredAnimations> with SingleTickerProviderStateMixin { late AnimationController _drawerSlideController; @override void initState() { super.initState(); _drawerSlideController = AnimationController( vsync: this, duration: const Duration(milliseconds: 150), ); } @override void dispose() { _drawerSlideController.dispose(); super.dispose(); } bool _isDrawerOpen() { return _drawerSlideController.value == 1.0; } bool _isDrawerOpening() { return _drawerSlideController.status == AnimationStatus.forward; } bool _isDrawerClosed() { return _drawerSlideController.value == 0.0; } void _toggleDrawer() { if (_isDrawerOpen() || _isDrawerOpening()) { _drawerSlideController.reverse(); } else { _drawerSlideController.forward(); } } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, appBar: _buildAppBar(), body: Stack( children: [ _buildContent(), _buildDrawer(), ], ), ); } PreferredSizeWidget _buildAppBar() { return AppBar( title: const Text( 'Flutter Menu', style: TextStyle( color: Colors.black, ), ), backgroundColor: Colors.transparent, elevation: 0.0, automaticallyImplyLeading: false, actions: [ AnimatedBuilder( animation: _drawerSlideController, builder: (context, child) { return IconButton( onPressed: _toggleDrawer, icon: _isDrawerOpen() || _isDrawerOpening() ? const Icon( Icons.clear, color: Colors.black, ) : const Icon( Icons.menu, color: Colors.black, ), ); }, ), ], ); } Widget _buildContent() { // Put page content here. return const SizedBox(); } Widget _buildDrawer() { return AnimatedBuilder( animation: _drawerSlideController, builder: (context, child) { return FractionalTranslation( translation: Offset(1.0 - _drawerSlideController.value, 0.0), child: _isDrawerClosed() ? const SizedBox() : const Menu(), ); }, ); } } class Menu extends StatefulWidget { const Menu({super.key}); @override State<Menu> createState() => _MenuState(); } class _MenuState extends State<Menu> with SingleTickerProviderStateMixin { static const _menuTitles = [ 'Declarative style', 'Premade widgets', 'Stateful hot reload', 'Native performance', 'Great community', ]; static const _initialDelayTime = Duration(milliseconds: 50); static const _itemSlideTime = Duration(milliseconds: 250); static const _staggerTime = Duration(milliseconds: 50); static const _buttonDelayTime = Duration(milliseconds: 150); static const _buttonTime = Duration(milliseconds: 500); final _animationDuration = _initialDelayTime + (_staggerTime * _menuTitles.length) + _buttonDelayTime + _buttonTime; late AnimationController _staggeredController; final List<Interval> _itemSlideIntervals = []; late Interval _buttonInterval; @override void initState() { super.initState(); _createAnimationIntervals(); _staggeredController = AnimationController( vsync: this, duration: _animationDuration, )..forward(); } void _createAnimationIntervals() { for (var i = 0; i < _menuTitles.length; ++i) { final startTime = _initialDelayTime + (_staggerTime * i); final endTime = startTime + _itemSlideTime; _itemSlideIntervals.add( Interval( startTime.inMilliseconds / _animationDuration.inMilliseconds, endTime.inMilliseconds / _animationDuration.inMilliseconds, ), ); } final buttonStartTime = Duration(milliseconds: (_menuTitles.length * 50)) + _buttonDelayTime; final buttonEndTime = buttonStartTime + _buttonTime; _buttonInterval = Interval( buttonStartTime.inMilliseconds / _animationDuration.inMilliseconds, buttonEndTime.inMilliseconds / _animationDuration.inMilliseconds, ); } @override void dispose() { _staggeredController.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return Container( color: Colors.white, child: Stack( fit: StackFit.expand, children: [ _buildFlutterLogo(), _buildContent(), ], ), ); } Widget _buildFlutterLogo() { return const Positioned( right: -100, bottom: -30, child: Opacity( opacity: 0.2, child: FlutterLogo( size: 400, ), ), ); } Widget _buildContent() { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const SizedBox(height: 16), ..._buildListItems(), const Spacer(), _buildGetStartedButton(), ], ); } List<Widget> _buildListItems() { final listItems = <Widget>[]; for (var i = 0; i < _menuTitles.length; ++i) { listItems.add( AnimatedBuilder( animation: _staggeredController, builder: (context, child) { final animationPercent = Curves.easeOut.transform( _itemSlideIntervals[i].transform(_staggeredController.value), ); final opacity = animationPercent; final slideDistance = (1.0 - animationPercent) * 150; return Opacity( opacity: opacity, child: Transform.translate( offset: Offset(slideDistance, 0), child: child, ), ); }, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 36, vertical: 16), child: Text( _menuTitles[i], textAlign: TextAlign.left, style: const TextStyle( fontSize: 24, fontWeight: FontWeight.w500, ), ), ), ), ); } return listItems; } Widget _buildGetStartedButton() { return SizedBox( width: double.infinity, child: Padding( padding: const EdgeInsets.all(24), child: AnimatedBuilder( animation: _staggeredController, builder: (context, child) { final animationPercent = Curves.elasticOut.transform( _buttonInterval.transform(_staggeredController.value)); final opacity = animationPercent.clamp(0.0, 1.0); final scale = (animationPercent * 0.5) + 0.5; return Opacity( opacity: opacity, child: Transform.scale( scale: scale, child: child, ), ); }, child: ElevatedButton( style: ElevatedButton.styleFrom( shape: const StadiumBorder(), backgroundColor: Colors.blue, padding: const EdgeInsets.symmetric(horizontal: 48, vertical: 14), ), onPressed: () {}, child: const Text( 'Get started', style: TextStyle( color: Colors.white, fontSize: 22, ), ), ), ), ), ); } } ```
website/src/cookbook/effects/staggered-menu-animation.md/0
{ "file_path": "website/src/cookbook/effects/staggered-menu-animation.md", "repo_id": "website", "token_count": 7721 }
1,423
--- title: Images description: A catalog of recipes for handling images in your Flutter app. --- {% include docs/cookbook-group-index.md %}
website/src/cookbook/images/index.md/0
{ "file_path": "website/src/cookbook/images/index.md", "repo_id": "website", "token_count": 41 }
1,424
--- title: Navigation description: A catalog of recipes for handling navigation in your Flutter app. --- {% include docs/cookbook-group-index.md %}
website/src/cookbook/navigation/index.md/0
{ "file_path": "website/src/cookbook/navigation/index.md", "repo_id": "website", "token_count": 41 }
1,425
--- title: Persistence description: A catalog of recipes for adding persistence to your Flutter app. --- {% include docs/cookbook-group-index.md %}
website/src/cookbook/persistence/index.md/0
{ "file_path": "website/src/cookbook/persistence/index.md", "repo_id": "website", "token_count": 42 }
1,426
--- title: Widget description: A catalog of recipes for adding widget testing to your Flutter app. --- {% include docs/cookbook-group-index.md %}
website/src/cookbook/testing/widget/index.md/0
{ "file_path": "website/src/cookbook/testing/widget/index.md", "repo_id": "website", "token_count": 43 }
1,427
--- title: List of state management approaches description: A list of different approaches to managing state. prev: title: Simple app state management path: /development/data-and-backend/state-mgmt/simple --- State management is a complex topic. If you feel that some of your questions haven't been answered, or that the approach described on these pages is not viable for your use cases, you are probably right. Learn more at the following links, many of which have been contributed by the Flutter community: ## General overview Things to review before selecting an approach. * [Introduction to state management][], which is the beginning of this very section (for those of you who arrived directly to this _Options_ page and missed the previous pages) * [Pragmatic State Management in Flutter][], a video from Google I/O 2019 * [Flutter Architecture Samples][], by Brian Egan [Flutter Architecture Samples]: https://fluttersamples.com/ [Introduction to state management]: /data-and-backend/state-mgmt/intro [Pragmatic State Management in Flutter]: {{site.yt.watch}}?v=d_m5csmrf7I ## Provider * [Simple app state management][], the previous page in this section * [Provider package][] [Provider package]: {{site.pub-pkg}}/provider [Simple app state management]: /data-and-backend/state-mgmt/simple ## Riverpod Riverpod works in a similar fashion to Provider. It offers compile safety and testing without depending on the Flutter SDK. * [Riverpod][] homepage * [Getting started with Riverpod][] [Getting started with Riverpod]: https://riverpod.dev/docs/introduction/getting_started [Riverpod]: https://riverpod.dev/ ## setState The low-level approach to use for widget-specific, ephemeral state. * [Adding interactivity to your Flutter app][], a Flutter tutorial * [Basic state management in Google Flutter][], by Agung Surya [Adding interactivity to your Flutter app]: /ui/interactivity [Basic state management in Google Flutter]: {{site.medium}}/@agungsurya/basic-state-management-in-google-flutter-6ee73608f96d ## ValueNotifier &amp; InheritedNotifier An approach using only Flutter provided tooling to update state and notify the UI of changes. * [State Management using ValueNotifier and InheritedNotifier][], by Tadas Petra [State Management using ValueNotifier and InheritedNotifier]: https://www.hungrimind.com/articles/flutter-state-management ## InheritedWidget &amp; InheritedModel The low-level approach used to communicate between ancestors and children in the widget tree. This is what `provider` and many other approaches use under the hood. The following instructor-led video workshop covers how to use `InheritedWidget`: <iframe width="560" height="315" src="{{site.yt.embed}}/LFcGPS6cGrY" title="How to manage application states using inherited widgets" {{site.yt.set}}></iframe> Other useful docs include: * [InheritedWidget docs][] * [Managing Flutter Application State With InheritedWidgets][], by Hans Muller * [Inheriting Widgets][], by Mehmet Fidanboylu * [Using Flutter Inherited Widgets Effectively][], by Eric Windmill * [Widget - State - Context - InheritedWidget][], by Didier Bolelens [InheritedWidget docs]: {{site.api}}/flutter/widgets/InheritedWidget-class.html [Inheriting Widgets]: {{site.medium}}/@mehmetf_71205/inheriting-widgets-b7ac56dbbeb1 [Managing Flutter Application State With InheritedWidgets]: {{site.flutter-medium}}/managing-flutter-application-state-with-inheritedwidgets-1140452befe1 [Using Flutter Inherited Widgets Effectively]: https://ericwindmill.com/articles/inherited_widget/ [Widget - State - Context - InheritedWidget]: https://www.didierboelens.com/2018/06/widget---state---context---inheritedwidget/ ## June A lightweight and modern state management library that focuses on providing a pattern similar to Flutter's built-in state management. * [june package][] [june package]: {{site.pub-pkg}}/june ## Redux A state container approach familiar to many web developers. * [Animation Management with Redux and Flutter][], a video from DartConf 2018 [Accompanying article on Medium][] * [Flutter Redux package][] * [Redux Saga Middleware Dart and Flutter][], by Bilal Uslu * [Introduction to Redux in Flutter][], by Xavi Rigau * [Flutter + Redux&mdash;How to make a shopping list app][], by Paulina Szklarska on Hackernoon * [Building a TODO application (CRUD) in Flutter with Redux&mdash;Part 1][], a video by Tensor Programming * [Flutter Redux Thunk, an example][], by Jack Wong * [Building a (large) Flutter app with Redux][], by Hillel Coren * [Fish-Redux–An assembled flutter application framework based on Redux][], by Alibaba * [Async Redux–Redux without boilerplate. Allows for both sync and async reducers][], by Marcelo Glasberg * [Flutter meets Redux: The Redux way of managing Flutter applications state][], by Amir Ghezelbash * [Redux and epics for better-organized code in Flutter apps][], by Nihad Delic * [Flutter_Redux_Gen - VS Code Plugin to generate boiler plate code][], by Balamurugan Muthusamy (BalaDhruv) [Accompanying article on Medium]: {{site.flutter-medium}}/animation-management-with-flutter-and-flux-redux-94729e6585fa [Animation Management with Redux and Flutter]: {{site.yt.watch}}?v=9ZkLtr0Fbgk [Async Redux–Redux without boilerplate. Allows for both sync and async reducers]: {{site.pub}}/packages/async_redux [Building a (large) Flutter app with Redux]: https://hillelcoren.com/2018/06/01/building-a-large-flutter-app-with-redux/ [Building a TODO application (CRUD) in Flutter with Redux&mdash;Part 1]: {{site.yt.watch}}?v=Wj216eSBBWs [Fish-Redux–An assembled flutter application framework based on Redux]: {{site.github}}/alibaba/fish-redux/ [Flutter Redux Thunk, an example]: {{site.medium}}/flutterpub/flutter-redux-thunk-27c2f2b80a3b [Flutter meets Redux: The Redux way of managing Flutter applications state]: {{site.medium}}/@thisisamir98/flutter-meets-redux-the-redux-way-of-managing-flutter-applications-state-f60ef693b509 [Flutter Redux package]: {{site.pub-pkg}}/flutter_redux [Flutter + Redux&mdash;How to make a shopping list app]: https://hackernoon.com/flutter-redux-how-to-make-shopping-list-app-1cd315e79b65 [Introduction to Redux in Flutter]: https://blog.novoda.com/introduction-to-redux-in-flutter/ [Redux and epics for better-organized code in Flutter apps]: {{site.medium}}/upday-devs/reduce-duplication-achieve-flexibility-means-success-for-the-flutter-app-e5e432839e61 [Redux Saga Middleware Dart and Flutter]: {{site.pub-pkg}}/redux_saga [Flutter_Redux_Gen - VS Code Plugin to generate boiler plate code]: https://marketplace.visualstudio.com/items?itemName=BalaDhruv.flutter-redux-gen ## Fish-Redux Fish Redux is an assembled flutter application framework based on Redux state management. It is suitable for building medium and large applications. * [Fish-Redux-Library][] package, by Alibaba * [Fish-Redux-Source][], project code * [Flutter-Movie][], A non-trivial example demonstrating how to use Fish Redux, with more than 30 screens, graphql, payment api, and media player. [Fish-Redux-Library]: {{site.pub-pkg}}/fish_redux [Fish-Redux-Source]: {{site.github}}/alibaba/fish-redux [Flutter-Movie]: {{site.github}}/o1298098/Flutter-Movie ## BLoC / Rx A family of stream/observable based patterns. * [Architect your Flutter project using BLoC pattern][], by Sagar Suri * [BloC Library][], by Felix Angelov * [Reactive Programming - Streams - BLoC - Practical Use Cases][], by Didier Boelens [Architect your Flutter project using BLoC pattern]: {{site.medium}}/flutterpub/architecting-your-flutter-project-bd04e144a8f1 [BloC Library]: https://felangel.github.io/bloc [Reactive Programming - Streams - BLoC - Practical Use Cases]: https://www.didierboelens.com/2018/12/reactive-programming---streams---bloc---practical-use-cases ## GetIt A service locator based state management approach that doesn't need a `BuildContext`. * [GetIt package][], the service locator. It can also be used together with BloCs. * [GetIt Mixin package][], a mixin that completes `GetIt` to a full state management solution. * [GetIt Hooks package][], same as the mixin in case you already use `flutter_hooks`. * [Flutter state management for minimalists][], by Suragch {{site.alert.note}} To learn more, watch this short Package of the Week video on the GetIt package: <iframe class="full-width" src="{{site.yt.embed}}/f9XQD5mf6FY" title="Learn about the GetIt Flutter Package" {{site.yt.set}}></iframe> {{site.alert.end}} [Flutter state management for minimalists]: {{site.medium}}/flutter-community/flutter-state-management-for-minimalists-4c71a2f2f0c1?sk=6f9cedfb550ca9cc7f88317e2e7055a0 [GetIt package]: {{site.pub-pkg}}/get_it [GetIt Hooks package]: {{site.pub-pkg}}/get_it_hooks [GetIt Mixin package]: {{site.pub-pkg}}/get_it_mixin ## MobX A popular library based on observables and reactions. * [MobX.dart, Hassle free state-management for your Dart and Flutter apps][] * [Getting started with MobX.dart][] * [Flutter: State Management with Mobx][], a video by Paul Halliday [Flutter: State Management with Mobx]: {{site.yt.watch}}?v=p-MUBLOEkCs [Getting started with MobX.dart]: https://mobx.netlify.com/getting-started [MobX.dart, Hassle free state-management for your Dart and Flutter apps]: {{site.github}}/mobxjs/mobx.dart ## Flutter Commands Reactive state management that uses the Command Pattern and is based on `ValueNotifiers`. Best in combination with [GetIt](#getit), but can be used with `Provider` or other locators too. * [Flutter Command package][] * [RxCommand package][], `Stream` based implementation. [Flutter Command package]: {{site.pub-pkg}}/flutter_command [RxCommand package]: {{site.pub-pkg}}/rx_command ## Binder A state management package that uses `InheritedWidget` at its core. Inspired in part by recoil. This package promotes the separation of concerns. * [Binder package][] * [Binder examples][] * [Binder snippets][], vscode snippets to be even more productive with Binder [Binder examples]: {{site.github}}/letsar/binder/tree/main/examples [Binder package]: {{site.pub-pkg}}/binder [Binder snippets]: https://marketplace.visualstudio.com/items?itemName=romain-rastel.flutter-binder-snippets ## GetX A simplified reactive state management solution. * [GetX package][] * [GetX Flutter Firebase Auth Example][], by Jeff McMorris [GetX package]: {{site.pub-pkg}}/get [GetX Flutter Firebase Auth Example]: {{site.medium}}/@jeffmcmorris/getx-flutter-firebase-auth-example-b383c1dd1de2 ## states_rebuilder An approach that combines state management with a dependency injection solution and an integrated router. For more information, see the following info: * [States Rebuilder][] project code * [States Rebuilder documentation][] [States Rebuilder]: {{site.github}}/GIfatahTH/states_rebuilder [States Rebuilder documentation]: {{site.github}}/GIfatahTH/states_rebuilder/wiki ## Triple Pattern (Segmented State Pattern) Triple is a pattern for state management that uses `Streams` or `ValueNotifier`. This mechanism (nicknamed _triple_ because the stream always uses three values: `Error`, `Loading`, and `State`), is based on the [Segmented State pattern][]. For more information, refer to the following resources: * [Triple documentation][] * [Flutter Triple package][] * [Triple Pattern: A new pattern for state management in Flutter][] (blog post written in Portuguese but can be auto-translated) * [VIDEO: Flutter Triple Pattern by Kevlin Ossada][] (recorded in English) [Triple documentation]: https://triple.flutterando.com.br/ [Flutter Triple package]: {{site.pub-pkg}}/flutter_triple [Segmented State pattern]: https://triple.flutterando.com.br/docs/intro/overview#-segmented-state-pattern-ssp [Triple Pattern: A new pattern for state management in Flutter]: https://blog.flutterando.com.br/triple-pattern-um-novo-padr%C3%A3o-para-ger%C3%AAncia-de-estado-no-flutter-2e693a0f4c3e [VIDEO: Flutter Triple Pattern by Kevlin Ossada]: {{site.yt.watch}}?v=dXc3tR15AoA ## solidart A simple but powerful state management solution inspired by SolidJS. * [Official Documentation][] * [solidart package][] * [flutter_solidart package][] [Official Documentation]: https://docs.page/nank1ro/solidart [solidart package]: {{site.pub-pkg}}/solidart [flutter_solidart package]: {{site.pub-pkg}}/flutter_solidart ## flutter_reactive_value The `flutter_reactive_value` library might offer the least complex solution for state management in Flutter. It might help Flutter newcomers add reactivity to their UI, without the complexity of the mechanisms described before. The `flutter_reactive_value` library defines the `reactiveValue(BuildContext)` extension method on `ValueNotifier`. This extension allows a `Widget` to fetch the current value of the `ValueNotifier` and subscribe the `Widget` to changes in the value of the `ValueNotifier`. If the value of the `ValueNotifier` changes, `Widget` rebuilds. * [`flutter_reactive_value`][] source and documentation [`flutter_reactive_value`]: {{site.github}}/lukehutch/flutter_reactive_value
website/src/data-and-backend/state-mgmt/options.md/0
{ "file_path": "website/src/data-and-backend/state-mgmt/options.md", "repo_id": "website", "token_count": 4036 }
1,428
--- title: Write your first Flutter app description: How to write an app in Flutter. short-title: Write your first app prev: title: Test drive path: /get-started/test-drive next: title: Learn more path: /get-started/learn-more toc: false --- You are now ready to start the "First Flutter app" codelab. In about an hour and a half, you will learn the basics of Flutter by creating an app that works on mobile, desktop, and web. <div class="juicy-button-container"> <img src="/assets/images/docs/get-started/codelab-goal-background.jpg" alt="The illustration of the initial and the resulting app that you will build in this codelab."> {%- comment %} The &#9654; character below is the "black right-pointing triangle" Unicode character. The non-breaking space after it makes the button look nicer. {% endcomment -%} <a class="btn btn-primary" target="_blank" href="https://codelabs.developers.google.com/codelabs/flutter-codelab-first"> &#9654;&nbsp; Start codelab </a> </div> {{site.alert.tip}} The codelab above walks you through writing your first Flutter app for all platforms &mdash; mobile, desktop and web. You might prefer to take [another codelab written specifically for the web][codelab-web]. {{site.alert.end}} [codelab-web]: /get-started/codelab-web If you prefer an instructor-led version of this codelab, check out the following workshop: <iframe width="560" height="315" src="{{site.yt.embed}}/8sAyPDLorek" title="Learn how to build your first Flutter app" {{site.yt.set}}></iframe>
website/src/get-started/codelab.md/0
{ "file_path": "website/src/get-started/codelab.md", "repo_id": "website", "token_count": 506 }
1,429
--- title: Handling user input description: Learn how to handle user input in Flutter. prev: title: State management path: /get-started/fwe/state-management next: title: Networking and data path: /get-started/fwe/networking --- Now that you know how to manage state in your Flutter app, how can you let users interact with your app and change its state? ## Introduction to user input As a multi-platform UI framework, there are many different ways for users to interact with a Flutter app. The resources in this section introduce you to some of the common widgets used for enabling user interaction. Some user input types, like [scrolling], have already been covered in [Layouts][]. For an introduction to how you can change app state in response to user interactions, check out the following tutorial that teaches you how to build a "favorite" button: <i class="material-symbols" aria-hidden="true">flutter_dash</i> Tutorial: [Add interactivity to your Flutter app][] [Layouts]: {{site.url}}/get-started/fwe/layout ## Material 3 demo Next, check out the [Material 3 Demo][], which samples some of the user input widgets available in the Material 3 component library. {{site.alert.note}} This page focuses on Material 3 widgets because it's the library that many developers start with when learning Flutter. However, Flutter also supports [Cupertino][] for iOS-styled widgets, or you can build your own widget library. {{site.alert.end}} [Cupertino]: {{site.api}}flutter/cupertino/cupertino-library.html ## Get user input This section covers widgets that help you build the most common user input methods into your Flutter app. ### Click or tap (Buttons) Let a user prompt action in a UI by clicking or tapping. The following Material 3 button types are functionally similar, but are styled differently: [`ElevatedButton]`[] : A button with some depth. Use elevated buttons to add dimension to otherwise mostly flat layouts. [`FilledButton`][] : A filled button that should be used for important, final actions that complete a flow, like **Save**, **Join now**, or **Confirm**. [`OutlinedButton`][] : A button with text and a visible border. These buttons contain actions that are important, but aren’t the primary action in an app. [`TextButton`][] : Clickable text, without a border. Since text buttons don't have visible borders and they must therefore rely on their position relative to other content for context. [`IconButton`][]: A button with an icon. [`FloatingActionButton`][] : A circular icon button that hovers over content to promote a primary action. * Video: [FloatingActionButton (Widget of the Week)][] [`ElevatedButton`]: {{site.api}}flutter/material/ElevatedButton-class.html [`FilledButton`]: {{site.api}}flutter/material/FilledButton-class.html [`FloatingActionButton`]: {{site.api}}flutter/material/FloatingActionButton-class.html [FloatingActionButton (Widget of the Week)]: https://youtu.be/2uaoEDOgk_I?si=MQZcSp24oRaS_kiY [`IconButton`]: {{site.api}}flutter/material/IconButton-class.html [`OutlinedButton`]: {{site.api}}flutter/material/OutlinedButton-class.html [`TextButton`]: {{site.api}}flutter/material/TextButton-class.html ### Text Several widgets support text input. [`TextField`][] : Let users enter text, either with hardware keyboard or with an onscreen keyboard. The following series of cookbook articles walk you through every step on how to build a text field, retrieve its value, and handle state changes: 1. Article: [Create and style a text field][] 1. Article: [Retrieve the value of a text field][] 1. Article: [Handle changes to a text field][] 1. Article: [Focus and text fields][] [`RichText`][] : Display text that uses multiple styles. * Video: [Rich Text (Widget of the Week)][] * Demo: [Rich Text Editor][] * Sample code: [Rich Text Editor code][] [`SelectableText`][] : Display a string of user-selectable text with a single style. * Video: [SelectableText (Widget of the Week)][] [`Form`][] : An optional container for grouping together multiple form field widgets. * Article: [Build a form with validation][] * Demo: [Form app][] * Sample code: [Form app code][] [Build a form with validation]: {{site.url}}/cookbook/forms/validation [Create and style a text field]: {{site.url}}/cookbook/forms/text-input [Focus and text fields]: {{site.url}}/cookbook/forms/focus [`Form`]: {{site.api}}flutter/widgets/Form-class.html [Form app]: https://flutter.github.io/samples/web/form_app/ [Form app code]: https://github.com/flutter/samples/tree/main/form_app [Handle changes to a text field]: {{site.url}}/cookbook/forms/text-field-changes [Retrieve the value of a text field]: {{site.url}}/cookbook/forms/retrieve-input [`RichText`]: {{site.api}}flutter/widgets/RichText-class.html [Rich Text (Widget of the Week)]: https://www.youtube.com/watch?v=rykDVh-QFfw [Rich Text Editor]: https://flutter.github.io/samples/rich_text_editor.html [Rich Text Editor code]: https://github.com/flutter/samples/tree/main/simplistic_editor [`SelectableText`]: {{site.api}}flutter/material/SelectableText-class.html [SelectableText (Widget of the Week)]: https://www.youtube.com/watch?v=ZSU3ZXOs6hc [`TextField`]: {{site.api}}flutter/material/TextField-class.html ### Select a value from a group of options [`SegmentedButton`][] : Allow users to select from limited set of options. [`DropdownMenu`][] : Let users select a choice from a menu and place the selected item into the text input field. * Video: [DropdownMenu (Widget of the Week)][] [`Slider`][] : Select from a range of values. * Video: [Slider, RangeSlider, CupertinoSlider (Widget of the Week)][] [`DropdownMenu`]: {{site.api}}flutter/material/DropdownMenu-class.html [DropdownMenu (Widget of the Week)]: https://youtu.be/giV9AbM2gd8?si=E23hjg72cjMTe_mz [`SegmentedButton`]: {{site.api}}flutter/material/SegmentedButton-class.html [`Slider`]: {{site.api}}flutter/material/Slider-class.html [Slider, RangeSlider, CupertinoSlider (Widget of the Week)]: https://www.youtube.com/watch?v=ufb4gIPDmEss ### Toggle values [`Checkbox`][] : Select one or more items from a list, or toggle an item. [`CheckboxListTile`][] : A checkbox with a label. * Video: [CheckboxListTile (Widget of the Week)][] [`Switch`][] : Toggle the on/off state of a single setting. [`SwitchListTile`][] : A switch with a label. * Video [SwitchListTile (Widget of the Week)][] [`Radio`][] : Select between a number of mutually exclusive values. When one radio button in a group is selected, the other radio buttons in the group cease to be selected. [`Chip`][] : Chips are compact elements that represent an attribute, text, entity, or action. ### Select a date or time [`showDatePicker`][] : Shows a dialog containing a [Material Design date picker][]. [`showTimePicker`][] : Shows a dialog containing a [Material Design time picker][]. ### Swipe and slide [`Dismissible`][] : Clear list items by swiping left or right. * Video: [Dismissible (Widget of the Week)][] * Article: [Implement swipe to dismiss][] [pkg:`flutter_slidable`][] : A list item with directional slide actions that can be dismissed. * Video: [flutter_slidable (Package of the Week)][] ## Add interactivity with GestureDetector If none of Flutter's widgets fit the functionality for what you're looking for, you can add interactivity to your own widget using `GestureDetector`. * Video: [GestureDetector (Widget of the Week)][] * Documentation: [Taps, drags, and other gestures][] * Article: [Handle taps][] Don't forget about accessibility! If you're building your own custom widget, you can annotate its meaning with the `Semantics` widget. It lets you provide descriptions, metadata, and more to screen readers and other semantic analysis-based tools. * Video: [Semantics (Flutter Widget of the Week)][] Bonus: For a deeper understanding on how Flutter's `GestureArena` turns raw user interaction data into human recognizable concepts like taps, drags, and pinches check out the following video: * Video: [GestureArena (Decoding Flutter)][] ## Testing Once you have finished building user interactions into your app, don't forget to write tests to ensure that everything works as expected! * Article: [Tap, drag, and enter text][] * Article: [Handle scrolling][] [GestureArena (Decoding Flutter)]: https://www.youtube.com/watch?v=Q85LBtBdi0U [GestureDetector (Widget of the Week)]: https://www.youtube.com/watch?v=WhVXkCFPmK4 [Handle taps]: {{site.url}}/cookbook/gestures/handling-taps [Semantics (Flutter Widget of the Week)]: https://youtu.be/NvtMt_DtFrQ?si=o79BqAg9NAl8EE8_ [Tap, drag, and enter text]: {{site.url}}/cookbook/testing/widget/tap-drag [Taps, drags, and other gestures]: {{site.url}}/ui/interactivity/gestures#gestures ## Next: Networking This page was an introduction to handling user input. Now that you know how to accept input from app's users, you can make your app even more interesting by adding external data. In the next section, you'll learn now to fetch data for your app over a network, how to convert data to and from JSON, authentication, and other networking features. [scrolling]: /get-started/fwe/layout#scrollable-widgets [Add interactivity to your Flutter app]: /ui/interactivity [Material 3 Demo]: https://flutter.github.io/samples/web/material_3_demo/ [`Checkbox`]: {{site.api}}flutter/material/Checkbox-class.html [`CheckboxListTile`]: {{site.api}}flutter/material/CheckboxListTile-class.html [CheckboxListTile (Widget of the Week)]: https://www.youtube.com/watch?v=RkSqPAn9szs [`Switch`]: {{site.api}}flutter/material/Switch-class.html [`SwitchListTile`]: {{site.api}}flutter/material/SwitchListTile-class.html [SwitchListTile (Widget of the Week)]: https://www.youtube.com/watch?v=0igIjvtEWNU [`Radio`]: {{site.api}}flutter/material/Radio-class.html [`Chip`]: {{site.api}}flutter/material/Chip-class.html [Material Design date picker]: https://m3.material.io/components/date-pickers/overview [Material Design time picker]: https://m3.material.io/components/time-pickers/overview [`showDatePicker`]: {{site.api}}flutter/material/showDatePicker.html [`showTimePicker`]: {{site.api}}flutter/material/showTimePicker.html [`Dismissible`]: {{site.api}}flutter/widgets/Dismissible-class.html [Dismissible (Widget of the Week)]: https://youtu.be/iEMgjrfuc58?si=f0S7IdaA9PIWIYvl [Implement swipe to dismiss]: {{site.url}}/cookbook/gestures/dismissible [pkg:`flutter_slidable`]: https://pub.dev/packages/flutter_slidable [flutter_slidable (Package of the Week)]: https://www.youtube.com/watch?v=QFcFEpFmNJ8 [Handle scrolling]: {{site.url}}/cookbook/testing/widget/scrolling ## Feedback As this section of the website is evolving, we [welcome your feedback][]! [welcome your feedback]: {{site.url}}/get-started/fwe
website/src/get-started/fwe/user-input.md/0
{ "file_path": "website/src/get-started/fwe/user-input.md", "repo_id": "website", "token_count": 3426 }
1,430
--- title: Start building Flutter Android apps on ChromeOS description: Configure your system to develop Flutter mobile apps on ChromeOS and Android. short-title: ChromeOS Android development target: Android config: ChromeOSAndroid devos: ChromeOS next: title: Create a test app path: /get-started/test-drive --- {% include docs/install/reqs/linux/base.md os=page.devos target=page.target -%} {% include docs/install/flutter-sdk.md os=page.devos target=page.target terminal='Terminal' -%} {% include docs/install/compiler/android.md devos=page.devos target=page.target attempt='first' -%} {% include docs/install/flutter-doctor.md devos=page.devos target=page.target config=page.config -%} {% include docs/install/next-steps.md devos=page.devos target=page.target config=page.config -%}
website/src/get-started/install/chromeos/android.md/0
{ "file_path": "website/src/get-started/install/chromeos/android.md", "repo_id": "website", "token_count": 309 }
1,431
--- title: Start building Flutter Android apps on Windows description: Configure your system to develop Flutter mobile apps on Windows. short-title: Make Android apps target: Android config: WindowsAndroid devos: Windows next: title: Create a test app path: /get-started/test-drive --- {% include docs/install/reqs/windows/base.md os=page.devos target=page.target -%} {% include docs/install/flutter-sdk.md os=page.devos target=page.target terminal='PowerShell' -%} {% include docs/install/compiler/android.md devos=page.devos target=page.target attempt='first' -%} {% include docs/install/flutter-doctor.md devos=page.devos target=page.target config=page.config -%} {% include docs/install/next-steps.md devos=page.devos target=page.target config=page.config -%}
website/src/get-started/install/windows/mobile.md/0
{ "file_path": "website/src/get-started/install/windows/mobile.md", "repo_id": "website", "token_count": 302 }
1,432
--- title: Deferred components description: How to create deferred components for improved download performance. --- <?code-excerpt path-base="perf/deferred_components"?> ## Introduction Flutter has the capability to build apps that can download additional Dart code and assets at runtime. This allows apps to reduce install apk size and download features and assets when needed by the user. We refer to each uniquely downloadable bundle of Dart libraries and assets as a "deferred component". To load these components, use [Dart's deferred imports][dart-def-import]. They can be compiled into split AOT and JavaScript shared libraries. {{site.alert.note}} Flutter supports deferred, or "lazy", loading on Android and the web. The implementations differ. Android's [dynamic feature modules][] deliver the deferred components packaged as Android modules. The web creates these components as separate `*.js` files. Deferred code doesn't impact other platforms, which continue to build as normal with all deferred components and assets included at initial install time. {{site.alert.end}} Though you can defer loading modules, you must build the entire app and upload that app as a single [Android App Bundle][android-app-bundle] (`*.aab`). Flutter doesn't support dispatching partial updates without re-uploading new Android App Bundles for the entire application. Flutter performs deferred loading when you compile your app in [release or profile mode][]. Debug mode treats all deferred components as regular imports. The components are present at launch and load immediately. This allows debug builds to hot reload. For a deeper dive into the technical details of how this feature works, see [Deferred Components][] on the [Flutter wiki][]. ## How to set your project up for deferred components The following instructions explain how to set up your Android app for deferred loading. ### Step 1: Dependencies and initial project setup <ol markdown="1"> <li markdown="1">Add Play Core to the Android app's build.gradle dependencies. In `android/app/build.gradle` add the following: ```gradle ... dependencies { ... implementation "com.google.android.play:core:1.8.0" ... } ``` </li> <li markdown="1">If using the Google Play Store as the distribution model for dynamic features, the app must support `SplitCompat` and provide an instance of a `PlayStoreDeferredComponentManager`. Both of these tasks can be accomplished by setting the `android:name` property on the application in `android/app/src/main/AndroidManifest.xml` to `io.flutter.embedding.android.FlutterPlayStoreSplitApplication`: ```xml <manifest ... <application android:name="io.flutter.embedding.android.FlutterPlayStoreSplitApplication" ... </application> </manifest> ``` `io.flutter.app.FlutterPlayStoreSplitApplication` handles both of these tasks for you. If you use `FlutterPlayStoreSplitApplication`, you can skip to step 1.3. If your Android application is large or complex, you might want to separately support `SplitCompat` and provide the `PlayStoreDynamicFeatureManager` manually. To support `SplitCompat`, there are three methods (as detailed in the [Android docs][]), any of which are valid: <ul markdown="1"> <li markdown="1">Make your application class extend `SplitCompatApplication`: ```java public class MyApplication extends SplitCompatApplication { ... } ``` </li> <li markdown="1">Call `SplitCompat.install(this);` in the `attachBaseContext()` method: ```java @Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); // Emulates installation of future on demand modules using SplitCompat. SplitCompat.install(this); } ``` </li> <li markdown="1">Declare `SplitCompatApplication` as the application subclass and add the Flutter compatibility code from `FlutterApplication` to your application class: ```js <application ... android:name="com.google.android.play.core.splitcompat.SplitCompatApplication"> </application> ``` </li> </ul> The embedder relies on an injected `DeferredComponentManager` instance to handle install requests for deferred components. Provide a `PlayStoreDeferredComponentManager` into the Flutter embedder by adding the following code to your app initialization: ```java import io.flutter.embedding.engine.dynamicfeatures.PlayStoreDeferredComponentManager; import io.flutter.FlutterInjector; ... PlayStoreDeferredComponentManager deferredComponentManager = new PlayStoreDeferredComponentManager(this, null); FlutterInjector.setInstance(new FlutterInjector.Builder() .setDeferredComponentManager(deferredComponentManager).build()); ``` </li> <li markdown="1">Opt into deferred components by adding the `deferred-components` entry to the app's `pubspec.yaml` under the `flutter` entry: ```yaml ... flutter: ... deferred-components: ... ``` The `flutter` tool looks for the `deferred-components` entry in the `pubspec.yaml` to determine whether the app should be built as deferred or not. This can be left empty for now unless you already know the components desired and the Dart deferred libraries that go into each. You will fill in this section later in [step 3.3][] once `gen_snapshot` produces the loading units. </li> </ol> ### Step 2: Implementing deferred Dart libraries Next, implement deferred loaded Dart libraries in your app's Dart code. The implementation does not need to be feature complete yet. The example in the rest of this page adds a new simple deferred widget as a placeholder. You can also convert existing code to be deferred by modifying the imports and guarding usages of deferred code behind `loadLibrary()` `Futures`. <ol markdown="1"> <li markdown="1">Create a new Dart library. For example, create a new `DeferredBox` widget that can be downloaded at runtime. This widget can be of any complexity but, for the purposes of this guide, create a simple box as a stand-in. To create a simple blue box widget, create `box.dart` with the following contents: <?code-excerpt "lib/box.dart"?> ```dart // box.dart import 'package:flutter/material.dart'; /// A simple blue 30x30 box. class DeferredBox extends StatelessWidget { const DeferredBox({super.key}); @override Widget build(BuildContext context) { return Container( height: 30, width: 30, color: Colors.blue, ); } } ``` </li> <li markdown="1">Import the new Dart library with the `deferred` keyword in your app and call `loadLibrary()` (see [lazily loading a library][]). The following example uses `FutureBuilder` to wait for the `loadLibrary` `Future` (created in `initState`) to complete and display a `CircularProgressIndicator` as a placeholder. When the `Future` completes, it returns the `DeferredBox` widget. `SomeWidget` can then be used in the app as normal and won't ever attempt to access the deferred Dart code until it has successfully loaded. <?code-excerpt "lib/use_deferred_box.dart"?> ```dart import 'package:flutter/material.dart'; import 'box.dart' deferred as box; class SomeWidget extends StatefulWidget { const SomeWidget({super.key}); @override State<SomeWidget> createState() => _SomeWidgetState(); } class _SomeWidgetState extends State<SomeWidget> { late Future<void> _libraryFuture; @override void initState() { super.initState(); _libraryFuture = box.loadLibrary(); } @override Widget build(BuildContext context) { return FutureBuilder<void>( future: _libraryFuture, builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.done) { if (snapshot.hasError) { return Text('Error: ${snapshot.error}'); } return box.DeferredBox(); } return const CircularProgressIndicator(); }, ); } } ``` The `loadLibrary()` function returns a `Future<void>` that completes successfully when the code in the library is available for use and completes with an error otherwise. All usage of symbols from the deferred library should be guarded behind a completed `loadLibrary()` call. All imports of the library must be marked as `deferred` for it to be compiled appropriately to be used in a deferred component. If a component has already been loaded, additional calls to `loadLibrary()` complete quickly (but not synchronously). The `loadLibrary()` function can also be called early to trigger a pre-load to help mask the loading time. You can find another example of deferred import loading in [Flutter Gallery's `lib/deferred_widget.dart`][]. </li> </ol> ### Step 3: Building the app Use the following `flutter` command to build a deferred components app: ```terminal $ flutter build appbundle ``` This command assists you by validating that your project is properly set up to build deferred components apps. By default, the build fails if the validator detects any issues and guides you through suggested changes to fix them. {{site.alert.note}} You can opt out of building deferred components with the `--no-deferred-components` flag. This flag causes all assets defined under deferred components to be treated as if they were defined under the assets section of `pubspec.yaml`. All Dart code is compiled into a single shared library and `loadLibrary()` calls complete in the next event loop boundary (as soon as possible while being asynchronous). This flag is also equivalent to omitting the `deferred-components:` entry in `pubspec.yaml`. {{site.alert.end}} <ol markdown="1"> <li markdown="1"><a id="step-3.1"></a>The `flutter build appbundle` command runs the validator and attempts to build the app with `gen_snapshot` instructed to produce split AOT shared libraries as separate `.so` files. On the first run, the validator will likely fail as it detects issues; the tool makes recommendations for how to set up the project and fix these issues. The validator is split into two sections: prebuild and post-gen_snapshot validation. This is because any validation referencing loading units cannot be performed until `gen_snapshot` completes and produces a final set of loading units. {{site.alert.note}} You can opt to have the tool attempt to build your app without the validator by passing the `--no-validate-deferred-components` flag. This can result in unexpected and confusing instructions to resolve failures. This flag is meant to be used in custom implementations that do not rely on the default Play-store-based implementation that the validator checks for. {{site.alert.end}} The validator detects any new, changed, or removed loading units generated by `gen_snapshot`. The current generated loading units are tracked in your `<projectDirectory>/deferred_components_loading_units.yaml` file. This file should be checked into source control to ensure that changes to the loading units by other developers can be caught. The validator also checks for the following in the `android` directory: <ul markdown="1"> <li markdown="1">**`<projectDir>/android/app/src/main/res/values/strings.xml`**<br> An entry for every deferred component mapping the key `${componentName}Name` to `${componentName}`. This string resource is used by the `AndroidManifest.xml` of each feature module to define the `dist:title property`. For example: ```xml <?xml version="1.0" encoding="utf-8"?> <resources> ... <string name="boxComponentName">boxComponent</string> </resources> ``` </li> <li markdown="1">**`<projectDir>/android/<componentName>`**<br> An Android dynamic feature module for each deferred component exists and contains a `build.gradle` and `src/main/AndroidManifest.xml` file. This only checks for existence and does not validate the contents of these files. If a file does not exist, it generates a default recommended one. </li> <li markdown="1">**`<projectDir>/android/app/src/main/res/values/AndroidManifest.xml`**<br> Contains a meta-data entry that encodes the mapping between loading units and component name the loading unit is associated with. This mapping is used by the embedder to convert Dart's internal loading unit id to the name of a deferred component to install. For example: ```js ... <application android:label="MyApp" android:name="io.flutter.app.FlutterPlayStoreSplitApplication" android:icon="@mipmap/ic_launcher"> ... <meta-data android:name="io.flutter.embedding.engine.deferredcomponents.DeferredComponentManager.loadingUnitMapping" android:value="2:boxComponent"/> </application> ... ``` </li> </ul> The `gen_snapshot` validator won't run until the prebuild validator passes. </li> <li markdown="1">For each of these checks, the tool produces the modified or new files needed to pass the check. These files are placed in the `<projectDir>/build/android_deferred_components_setup_files` directory. It is recommended that the changes be applied by copying and overwriting the same files in the project's `android` directory. Before overwriting, the current project state should be committed to source control and the recommended changes should be reviewed to be appropriate. The tool won't make any changes to your `android/` directory automatically. </li> <li markdown="1"><a id="step-3.3"></a>Once the available loading units are generated and logged in `<projectDirectory>/deferred_components_loading_units.yaml`, it is possible to fully configure the pubspec's `deferred-components` section so that the loading units are assigned to deferred components as desired. To continue with the box example, the generated `deferred_components_loading_units.yaml` file would contain: ```yaml loading-units: - id: 2 libraries: - package:MyAppName/box.Dart ``` The loading unit id ('2' in this case) is used internally by Dart, and can be ignored. The base loading unit (id '1') is not listed and contains everything not explicitly contained in another loading unit. You can now add the following to `pubspec.yaml`: ```yaml ... flutter: ... deferred-components: - name: boxComponent libraries: - package:MyAppName/box.Dart ... ``` To assign a loading unit to a deferred component, add any Dart lib in the loading unit into the libraries section of the feature module. Keep the following guidelines in mind: <ul markdown="1"> <li markdown="1">Loading units should not be included in more than one component. </li> <li markdown="1">Including one Dart library from a loading unit indicates that the entire loading unit is assigned to the deferred component. </li> <li markdown="1">All loading units not assigned to a deferred component are included in the base component, which always exists implicitly. </li> <li markdown="1">Loading units assigned to the same deferred component are downloaded, installed, and shipped together. </li> <li markdown="1">The base component is implicit and need not be defined in the pubspec. </li> </ul> </li> <li markdown="1">Assets can also be included by adding an assets section in the deferred component configuration: ```yaml deferred-components: - name: boxComponent libraries: - package:MyAppName/box.Dart assets: - assets/image.jpg - assets/picture.png # wildcard directory - assets/gallery/ ``` An asset can be included in multiple deferred components, but installing both components results in a replicated asset. Assets-only components can also be defined by omitting the libraries section. These assets-only components must be installed with the [`DeferredComponent`][] utility class in services rather than `loadLibrary()`. Since Dart libs are packaged together with assets, if a Dart library is loaded with `loadLibrary()`, any assets in the component are loaded as well. However, installing by component name and the services utility won't load any dart libraries in the component. You are free to include assets in any component, as long as they are installed and loaded when they are first referenced, though typically, assets and the Dart code that uses those assets are best packed in the same component. </li> <li markdown="1">Manually add all deferred components that you defined in `pubspec.yaml` into the `android/settings.gradle` file as includes. For example, if there are three deferred components defined in the pubspec named, `boxComponent`, `circleComponent`, and `assetComponent`, ensure that `android/settings.gradle` contains the following: ```gradle include ':app', ':boxComponent', ':circleComponent', ':assetComponent' ... ``` </li> <li markdown="1">Repeat steps [3.1][] through 3.6 (this step) until all validator recommendations are handled and the tool runs without further recommendations. When successful, this command outputs an `app-release.aab` file in `build/app/outputs/bundle/release`. A successful build does not always mean the app was built as intended. It is up to you to ensure that all loading units and Dart libraries are included in the way you intended. For example, a common mistake is accidentally importing a Dart library without the `deferred` keyword, resulting in a deferred library being compiled as part of the base loading unit. In this case, the Dart lib would load properly because it is always present in the base, and the lib would not be split off. This can be checked by examining the `deferred_components_loading_units.yaml` file to verify that the generated loading units are described as intended. When adjusting the deferred components configurations, or making Dart changes that add, modify, or remove loading units, you should expect the validator to fail. Follow steps [3.1][] through 3.6 (this step) to apply any recommended changes to continue the build. </li> </ol> ### Running the app locally Once your app has successfully built an `.aab` file, use Android's [`bundletool`][] to perform local testing with the `--local-testing` flag. To run the `.aab` file on a test device, download the bundletool jar executable from [github.com/google/bundletool/releases][] and run: ```terminal $ java -jar bundletool.jar build-apks --bundle=<your_app_project_dir>/build/app/outputs/bundle/release/app-release.aab --output=<your_temp_dir>/app.apks --local-testing $ java -jar bundletool.jar install-apks --apks=<your_temp_dir>/app.apks ``` Where `<your_app_project_dir>` is the path to your app's project directory and `<your_temp_dir>` is any temporary directory used to store the outputs of bundletool. This unpacks your `.aab` file into an `.apks` file and installs it on the device. All available Android dynamic features are loaded onto the device locally and installation of deferred components is emulated. Before running `build-apks` again, remove the existing app .apks file: ```terminal $ rm <your_temp_dir>/app.apks ``` Changes to the Dart codebase require either incrementing the Android build ID or uninstalling and reinstalling the app, as Android won't update the feature modules unless it detects a new version number. ### Releasing to the Google Play Store The built `.aab` file can be uploaded directly to the Play store as normal. When `loadLibrary()` is called, the needed Android module containing the Dart AOT lib and assets is downloaded by the Flutter engine using the Play store's delivery feature. [3.1]: #step-3.1 [Android docs]: {{site.android-dev}}/guide/playcore/feature-delivery#declare_splitcompatapplication_in_the_manifest [`bundletool`]: {{site.android-dev}}/studio/command-line/bundletool [Deferred Components]: {{site.repo.flutter}}/wiki/Deferred-Components [`DeferredComponent`]: {{site.api}}/flutter/services/DeferredComponent-class.html [dynamic feature modules]: {{site.android-dev}}/guide/playcore/feature-delivery [Flutter Gallery's `lib/deferred_widget.dart`]: {{site.repo.gallery-archive}}/blob/main/lib/deferred_widget.dart [Flutter wiki]: {{site.repo.flutter}}/wiki [github.com/google/bundletool/releases]: {{site.github}}/google/bundletool/releases [lazily loading a library]: {{site.dart-site}}/language/libraries#lazily-loading-a-library [release or profile mode]: /testing/build-modes [step 3.3]: #step-3.3 [android-app-bundle]: {{site.android-dev}}/guide/app-bundle [dart-def-import]: https://dart.dev/language/libraries#lazily-loading-a-library
website/src/perf/deferred-components.md/0
{ "file_path": "website/src/perf/deferred-components.md", "repo_id": "website", "token_count": 6078 }
1,433
--- title: Add iOS devtools to Flutter from Android start description: Configure your system to develop Flutter mobile apps also on iOS. short-title: Starting from Android --- To add iOS as a Flutter app target for macOS, follow this procedure. ## Install Xcode 1. Allocate a minimum of 26 GB of storage for Xcode. Consider allocating 42 GB of storage for an optimal configuration. 1. Install [Xcode][] {{site.appnow.xcode}} to debug and compile native Swift or ObjectiveC code. {% include docs/install/compiler/xcode.md target='iOS' devos='macOS' attempt="first" -%} {% include docs/install/flutter-doctor.md target='iOS' devos='macOS' config='macOSAndroidiOS' %} [Xcode]: {{site.apple-dev}}/xcode/
website/src/platform-integration/ios/install-ios/install-ios-from-android.md/0
{ "file_path": "website/src/platform-integration/ios/install-ios/install-ios-from-android.md", "repo_id": "website", "token_count": 232 }
1,434
--- title: Add macOS devtools for Flutter description: Configure your system to develop Flutter for macOS. short-title: Add macOS desktop DevTools target-list: [iOS, Android, Web] --- To choose the guide to add macOS devtools to your Flutter configuration, click the [Getting Started path][] you followed. <div class="card-deck mb-8"> {% for target in page.target-list %} {% assign targetlink='/platform-integration/macos/install-macos/install-macos-from-' | append: target | downcase %} <a class="card card-app-type card-macos" id="install-{{target | downcase}}" href="{{targetlink}}"> <div class="card-body"> <header class="card-title text-center m-0"> <span class="d-block h1"> {% assign icon = target | downcase -%} {% case icon %} {% when 'ios' -%} <span class="material-symbols">phone_iphone</span> {% when 'android' -%} <span class="material-symbols">phone_android</span> {% when 'web' -%} <span class="material-symbols">web</span> {% endcase -%} <span class="material-symbols">add</span> <span class="material-symbols">laptop_mac</span> </span> <span class="text-muted"> Make {{ target }} and macOS desktop apps </span> </header> </div> </a> {% endfor %} </div> [Getting Started path]: /get-started/install
website/src/platform-integration/macos/install-macos/index.md/0
{ "file_path": "website/src/platform-integration/macos/install-macos/index.md", "repo_id": "website", "token_count": 584 }
1,435
--- title: Add web DevTools to Flutter from Linux start description: Configure your system to develop Flutter web apps on Linux. short-title: Starting from Linux desktop --- To add web as a Flutter app target for Linux desktop, follow this procedure. ## Configure Chrome as the web DevTools tools {% include docs/install/reqs/add-web.md devos='Linux' %} {% include docs/install/flutter-doctor.md target='Web' devos='Linux' config='LinuxDesktopWeb' %}
website/src/platform-integration/web/install-web/install-web-from-linux-desktop.md/0
{ "file_path": "website/src/platform-integration/web/install-web/install-web-from-linux-desktop.md", "repo_id": "website", "token_count": 138 }
1,436
--- title: Tutorials description: A list of Flutter tutorials. --- The **Flutter tutorials** teach you how to use the Flutter framework to build mobile applications for iOS and Android. Choose from the following: * [Building layouts](/ui/layout/tutorial) : How to build layouts using Flutter's layout mechanism. Once you've learned basic principles, you'll build the layout for a sample screenshot. * [Adding interactivity to your Flutter app](/ui/interactivity) : You'll extend the simple layout app created in "Building Layouts in Flutter" to make an icon tappable. Different ways of managing a widget's state are also discussed. * [Animations in Flutter](/ui/animations/tutorial) : Explains the fundamental classes in the Flutter animation package (controllers, Animatable, curves, listeners, builders), as it guides you through a progression of tween animations using different aspects of the animation APIs. * [Internationalizing Flutter apps](/ui/accessibility-and-internationalization/internationalization) : Learn how to internationalize your Flutter application. A guide through the widgets and classes that enable apps to display their content using the user's language and formatting conventions.
website/src/reference/tutorials.md/0
{ "file_path": "website/src/reference/tutorials.md", "repo_id": "website", "token_count": 295 }
1,437
--- title: Migration guide for adding AppLifecycleState.hidden description: AppLifecycleState had an additional hidden state added. --- ## Summary A new `hidden` state was added to the [`AppLifecycleState`][] enum to denote when the application is not visible. ## Context The `AppLifecycleState` enum is used to indicate which lifecycle state the application is in when [`WidgetsBindingObserver.didChangeAppLifecycleState`][] is called. ## Description of change The new state `AppLifecycleState.hidden` was added to the `AppLifecycleState` enum in the `dart:ui` package. The `hidden` state is entered when all of the application views are no longer visible to the user. On Android and iOS, this state is entered briefly whenever the state machine traverses from inactive to paused, or from paused to inactive. It doesn't change when paused or inactive are entered. On other platforms, it will be in this state while the application is not visible. ## Migration guide If code has switch statements that handle all cases of the `AppLifecycleState` enum, a new case will need to be added to handle the `AppLifecycleState.hidden` state. Code before migration: ```dart void didChangeAppLifecycleState(AppLifecycleState state) { switch (state) { case AppLifecycleState.resumed: case AppLifecycleState.inactive: // Do something when the app is visible... break; case AppLifecycleState.paused: case AppLifecycleState.detached: // Do something when the app is not visible... break; } } ``` Code after migration: ```dart void didChangeAppLifecycleState(AppLifecycleState state) { switch (state) { case AppLifecycleState.resumed: case AppLifecycleState.inactive: // Do something when the app is visible... break; case AppLifecycleState.hidden: // <-- This is the new state. case AppLifecycleState.paused: case AppLifecycleState.detached: // Do something when the app is not visible... break; } } ``` If there is already a `default:` case in the switch statement, or the code uses conditionals instead, then the code will compile without changes, but the default case or conditional will still need to be evaluated to decide if the `hidden` state should also be handled. ## Timeline Landed in version: 3.11.0-16.0.pre<br> In stable release: 3.13.0 ## References Relevant PRs: * [PR 42418][]: Adds `AppLifecycleState.hidden` enum value [PR 42418]: {{site.repo.engine}}/pull/42418 [`WidgetsBindingObserver.didChangeAppLifecycleState`]: {{site.api}}/flutter/widgets/WidgetsBindingObserver/didChangeAppLifecycleState.html [`AppLifecycleState`]: {{site.api}}/flutter/dart-ui/AppLifecycleState.html
website/src/release/breaking-changes/add-applifecyclestate-hidden.md/0
{ "file_path": "website/src/release/breaking-changes/add-applifecyclestate-hidden.md", "repo_id": "website", "token_count": 846 }
1,438
--- title: New CupertinoIcons has icon glyph changes description: > Once you update to cupertino_icons 1.0.0, some old glyphs are automapped to the new glyphs. Consider double-checking visually. --- ## Summary The existing cupertino_icons [0.1.3 icons][] are based on iOS 11 aesthetics with sharp angles and thin lines. As Apple's iconography updates with new OS versions, the `cupertino_icons` package is also refreshed. Generally, all previous glyphs referenced from the [`CupertinoIcons`][] API are automatically mapped to very similar looking icons in the new SF Symbols style (featuring rounder, thicker lines). Some icons that have no equivalents in the new SF Symbols style are left as is. Some icons that have less variation (such as thickness, alternative looks, and so on) are automapped and collapsed to the best matching variation in the new SF Symbols style but should be double checked to determine whether they preserve the intended visual effect. ## Description of change The new `cupertino_icons 1.0.0` font is handcrafted to best preserve the intent and aesthetic of the symbology through the transition. All existing `CupertinoIcons`' static `IconData` fields (and thus all of the font `.ttf`'s codepoints) continue to work and point to a reasonable new icon. The new cupertino_icons 1.0.0 package also has ~1,000 more icons to choose from. ### Unchanged icons No SF Symbols styled alternatives exist for the icons in the following list. The previous cupertino_icons 0.1.3 icons have been kept as is in 1.0.0. * bluetooth * bus * car * car_detailed * chevron_back * chevron_forward * lab_flask * lab_flask_solid * news * news_solid * train_style_one * train_style_two ### Merged icons Icons within the same group are now the exact same icon in 1.0.0. In other words, the distinctions between those icon variations that existed in 0.1.3 is lost and now renders the same SF Symbols styled icon that represents the theme of the group. This affects the following icon groups: * share, share_up * battery_charging, battery_full, battery_75_percent * shuffle, shuffle_medium, shuffle_thick * delete, delete_simple * refresh, refresh_thin, refresh_thick * clear, clear_thick * clear_circled_solid, clear_thick_circled * gear, gear_alt, gear_big * loop, loop_thick * time_solid, clock_solid * time, clock * tag, tags * tag_solid, tags_solid This is mainly due to some artistic liberties taken when creating the original `cupertino_icons` set that no longer match the variations diversity of the more formal SF Symbols icon set for some of the icons. ## Migration guide After upgrading to 1.22, if you also upgrade the `cupertino_icons` pubspec dependency from 0.1.3 to 1.0.0, for example, by changing: ```yaml dependencies: ... // Other dependencies cupertino_icons: ^0.1.0 ``` to: ```yaml dependencies: ... // Other dependencies cupertino_icons: ^1.0.0 ``` All your `CupertinoIcons` should automatically update to the new aesthetic (except for the [unchanged icons](#unchanged-icons) listed above). At this point, you can also explore [`CupertinoIcons`][] for new icons to use in your application. You're encouraged to verify your application after migrating to ensure that the automatically mapped new icons are suitable for your desired aesthetics. ## Timeline Landed in: 1.22.0-10.0.pre.65<br> In stable release: 1.22 ## References [0.1.3 icons]: https://raw.githubusercontent.com/flutter/cupertino_icons/master/map.png [`CupertinoIcons`]: {{site.api}}/flutter/cupertino/CupertinoIcons-class.html
website/src/release/breaking-changes/cupertino-icons-1.0.0.md/0
{ "file_path": "website/src/release/breaking-changes/cupertino-icons-1.0.0.md", "repo_id": "website", "token_count": 1067 }
1,439
--- title: Deprecate MemoryAllocations in favor of FlutterMemoryAllocations description: >- MemoryAllocations is renamed to FlutterMemoryAllocations. --- ## Summary Disposables in pure Dart projects can't use `MemoryAllocations` in Flutter. So, to be leak-trackable they need a Dart-only class. `MemoryAllocations` in Flutter is renamed to make the name available to a non-Flutter, Dart project. ## Migration guide Before: ```dart if (kFlutterMemoryAllocationsEnabled) { MemoryAllocations.instance.dispatchObjectCreated( library: 'package:flutter/gestures.dart', className: '$MultiDragPointerState', object: this, ); } ``` After: ```dart if (kFlutterMemoryAllocationsEnabled) { FlutterMemoryAllocations.instance.dispatchObjectCreated( library: 'package:flutter/gestures.dart', className: '$MultiDragPointerState', object: this, ); } ``` ## Timeline Landed in version: 3.19.0-2.0.pre<br> Landed in stable: Not yet ## References Relevant issues: * [Rename MemoryAllocations to FlutterMemoryAllocations (Issue 140622)][] [Rename MemoryAllocations to FlutterMemoryAllocations (Issue 140622)]: {{site.repo.flutter}}/issues/140622
website/src/release/breaking-changes/flutter-memory-allocations.md/0
{ "file_path": "website/src/release/breaking-changes/flutter-memory-allocations.md", "repo_id": "website", "token_count": 389 }
1,440
--- title: Migrate to Material 3 description: >- Learn how to migrate your Flutter app's UI from Material 2 to Material 3. --- ## Summary The Material library has been updated to match the Material 3 Design spec. Changes include new components and component themes, updated component visuals, and much more. Many of these updates are seamless. You'll see the new version of an affected widget when recompiling your app against the 3.16 (or later) release. But some manual work is also required to complete the migration. ## Migration guide Prior to the 3.16 release, you could opt in to the Material 3 changes by setting the `useMaterial3` flag to true. As of the Flutter 3.16 release (November 2023), `useMaterial3` is true by default. By the way, you _can_ revert to Material 2 behavior in your app by setting the `useMaterial3` to `false`. However, this is just a temporary solution. The `useMaterial3` flag _and_ the Material 2 implementation will eventually be removed as part of Flutter's deprecation policy. ### Colors The default values for `ThemeData.colorScheme` are updated to match the Material 3 Design spec. The `ColorScheme.fromSeed` constructor generates a `ColorScheme` derived from the given `seedColor`. The colors generated by this constructor are designed to work well together and meet contrast requirements for accessibility in the Material 3 Design system. When updating to the 3.16 release, your UI might look a little strange without the correct `ColorScheme`. To fix this, migrate to the `ColorScheme` generated from the `ColorScheme.fromSeed` constructor. Code before migration: ```dart theme: ThemeData( colorScheme: ColorScheme.light(primary: Colors.blue), ), ``` Code after migration: ```dart theme: ThemeData( colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue), ), ``` To generate a content-based dynamic color scheme, use the `ColorScheme.fromImageProvider` static method. For an example of generating a color scheme, check out the [`ColorScheme` from a network image][] sample. [`ColorScheme` from a network image]: {{site.api}}/flutter/material/ColorScheme/fromImageProvider.html Changes to Flutter Material 3 include a new background color. `ColorScheme.surfaceTint` indicates an elevated widget. Some widgets use different colors. To return your app's UI to its previous behavior (which we don't recommend): * Set `Colors.grey[50]!` to `ColorScheme.background` (when the theme is `Brightness.light`). * Set `Colors.grey[850]!`to `ColorScheme.background` (when the theme is `Brightness.dark`). Code before migration: ```dart theme: ThemeData( colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), ), ``` Code after migration: ```dart theme: ThemeData( colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple).copyWith( background: Colors.grey[50]!, ), ), ``` ```dart darkTheme: ThemeData( colorScheme: ColorScheme.fromSeed( seedColor: Colors.deepPurple, brightness: Brightness.dark, ).copyWith(background: Colors.grey[850]!), ), ``` The `ColorScheme.surfaceTint` value indicates a component's elevation in Material 3. Some widgets might use both `surfaceTint` and `shadowColor` to indicate elevation (for example, `Card` and `ElevatedButton`) and others might only use `surfaceTint` to indicate elevation (such as `AppBar`). To return to the widget's previous behavior, set, set `Colors.transparent` to `ColorScheme.surfaceTint` in the theme. To differentiate a widget's shadow from the content (when it has no shadow), set the `ColorScheme.shadow` color to the `shadowColor` property in the widget theme without a default shadow color. Code before migration: ```dart theme: ThemeData( colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), ), ``` Code after migration: ```dart theme: ThemeData( colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple).copyWith( surfaceTint: Colors.transparent, ), appBarTheme: AppBarTheme( elevation: 4.0, shadowColor: Theme.of(context).colorScheme.shadow, ), ), ``` The `ElevatedButton` now styles itself with a new combination of colors. Previously, when the `useMaterial3` flag was set to false, `ElevatedButton` styled itself with `ColorScheme.primary` for the background and `ColorScheme.onPrimary` for the foreground. To achieve the same visuals, switch to the new `FilledButton` widget without the elevation changes or drop shadow. Code before migration: ```dart ElevatedButton( onPressed: () {}, child: const Text('Button'), ), ``` Code after migration: ```dart ElevatedButton( style: ElevatedButton.styleFrom( backgroundColor: Theme.of(context).colorScheme.primary, foregroundColor: Theme.of(context).colorScheme.onPrimary, ), onPressed: () {}, child: const Text('Button'), ), ``` ### Typography The default values for `ThemeData.textTheme` are updated to match the Material 3 defaults. Changes include updated font size, font weight, letter spacing, and line height. For more details, check out the [`TextTheme`][] documentation. As shown in the following example, prior to the 3.16 release, when a `Text` widget with a long string using `TextTheme.bodyLarge` in a constrained layout wrapped the text into two lines. However, the 3.16 release wraps the text into three lines. If you must achieve the previous behavior, adjust the text style and, if necessary, the letter spacing. Code before migration: ```dart ConstrainedBox( constraints: const BoxConstraints(maxWidth: 200), child: Text( 'This is a very long text that should wrap to multiple lines.', style: Theme.of(context).textTheme.bodyLarge, ), ), ``` Code after migration: ```dart ConstrainedBox( constraints: const BoxConstraints(maxWidth: 200), child: Text( 'This is a very long text that should wrap to multiple lines.', style: Theme.of(context).textTheme.bodyMedium!.copyWith( letterSpacing: 0.0, ), ), ), ``` [`TextTheme`]: {{site.api}}/flutter/material/TextTheme-class.html ### Components Some components couldn't merely be updated to match the Material 3 Design spec but needed a whole new implementation. Such components require manual migration since the Flutter SDK doesn't know what, exactly, you want. Replace the Material 2 style [`BottomNavigationBar`][] widget with the new [`NavigationBar`][] widget. It's slightly taller, contains pill-shaped navigation indicators, and uses new color mappings. Code before migration: ```dart BottomNavigationBar( items: const <BottomNavigationBarItem>[ BottomNavigationBarItem( icon: Icon(Icons.home), label: 'Home', ), BottomNavigationBarItem( icon: Icon(Icons.business), label: 'Business', ), BottomNavigationBarItem( icon: Icon(Icons.school), label: 'School', ), ], ), ``` Code after migration: ```dart NavigationBar( destinations: const <Widget>[ NavigationDestination( icon: Icon(Icons.home), label: 'Home', ), NavigationDestination( icon: Icon(Icons.business), label: 'Business', ), NavigationDestination( icon: Icon(Icons.school), label: 'School', ), ], ), ``` Check out the complete sample on [migrating from `BottomNavigationBar` to `NavigationBar`][]. Replace the [`Drawer`][] widget with [`NavigationDrawer`][], which provides pill-shaped navigation indicators, rounded corners, and new color mappings. Code before migration: ```dart Drawer( child: ListView( children: <Widget>[ DrawerHeader( child: Text( 'Drawer Header', style: Theme.of(context).textTheme.titleLarge, ), ), ListTile( leading: const Icon(Icons.message), title: const Text('Messages'), onTap: () { }, ), ListTile( leading: const Icon(Icons.account_circle), title: const Text('Profile'), onTap: () {}, ), ListTile( leading: const Icon(Icons.settings), title: const Text('Settings'), onTap: () { }, ), ], ), ), ``` Code after migration: ```dart NavigationDrawer( children: <Widget>[ DrawerHeader( child: Text( 'Drawer Header', style: Theme.of(context).textTheme.titleLarge, ), ), const NavigationDrawerDestination( icon: Icon(Icons.message), label: Text('Messages'), ), const NavigationDrawerDestination( icon: Icon(Icons.account_circle), label: Text('Profile'), ), const NavigationDrawerDestination( icon: Icon(Icons.settings), label: Text('Settings'), ), ], ), ``` Check out the complete sample on [migrating from `Drawer` to `NavigationDrawer`][]. Material 3 introduces medium and large app bars that display a larger headline before scrolling. Instead of a drop shadow, `ColorScheme.surfaceTint` color is used create a separation from the content when scrolling. The following code demonstrates how to implement the medium app bar: ```dart CustomScrollView( slivers: <Widget>[ const SliverAppBar.medium( title: Text('Title'), ), SliverToBoxAdapter( child: Card( child: SizedBox( height: 1200, child: Padding( padding: const EdgeInsets.fromLTRB(8, 100, 8, 100), child: Text( 'Here be scrolling content...', style: Theme.of(context).textTheme.headlineSmall, ), ), ), ), ), ], ), ``` There are now two types of [`TabBar`][] widgets: primary and secondary. Secondary tabs are used within a content area to further separate related content and establish hierarchy. Check out the [`TabBar.secondary`][] example. The new [`TabBar.tabAlignment`][] property specifies the horizontal alignment of the tabs. The following sample shows how to modify tab alignment in a scrollable `TabBar`: ```dart AppBar( title: const Text('Title'), bottom: const TabBar( tabAlignment: TabAlignment.start, isScrollable: true, tabs: <Widget>[ Tab( icon: Icon(Icons.cloud_outlined), ), Tab( icon: Icon(Icons.beach_access_sharp), ), Tab( icon: Icon(Icons.brightness_5_sharp), ), ], ), ), ``` [`SegmentedButton`][], an updated version of [`ToggleButtons`][], uses fully rounded corners, differs in layout height and size, and uses a Dart `Set` to determine selected items. Code before migration: ```dart enum Weather { cloudy, rainy, sunny } ToggleButtons( isSelected: const [false, true, false], onPressed: (int newSelection) { }, children: const <Widget>[ Icon(Icons.cloud_outlined), Icon(Icons.beach_access_sharp), Icon(Icons.brightness_5_sharp), ], ), ``` Code after migration: ```dart enum Weather { cloudy, rainy, sunny } SegmentedButton<Weather>( selected: const <Weather>{Weather.rainy}, onSelectionChanged: (Set<Weather> newSelection) { }, segments: const <ButtonSegment<Weather>>[ ButtonSegment( icon: Icon(Icons.cloud_outlined), value: Weather.cloudy, ), ButtonSegment( icon: Icon(Icons.beach_access_sharp), value: Weather.rainy, ), ButtonSegment( icon: Icon(Icons.brightness_5_sharp), value: Weather.sunny, ), ], ), ``` Check out the complete sample on [migrating from `ToggleButtons` to `SegmentedButton`][]. [migrating from `BottomNavigationBar` to `NavigationBar`]: {{site.api}}/flutter/material/BottomNavigationBar-class.html#material.BottomNavigationBar.2 [migrating from `Drawer` to `NavigationDrawer`]: {{site.api}}/flutter/material/Drawer-class.html#material.Drawer.2 [migrating from `ToggleButtons` to `SegmentedButton`]: {{site.api}}/flutter/material/ToggleButtons-class.html#material.ToggleButtons.1 #### New components * "Menu bars and cascading menus" provide a desktop-style menu system that is fully traversable with the mouse or keyboard. Menus are anchored by a [`MenuBar`][] or a [`MenuAnchor`][]. The new menu system isn't something that existing applications must migrate to, however applications that are deployed on the web or on desktop platforms should consider using it instead of `PopupMenuButton` (and related) classes. * [`DropdownMenu`][] combines a text field and a menu to produce what's sometimes called a _combo box_. Users can select a menu item from a potentially large list by entering a matching string or by interacting with the menu with touch, mouse, or keyboard. This can be a good replacement for `DropdownButton` widget, although it isn't necessary. * [`SearchBar`][] and [`SearchAnchor`][] are for interactions where the user enters a search query, the app computes a list of matching responses, and then the user either selects one or adjusts the query. * [`Badge`][] decorates its child with a small label of just a few characters. Like '+1'. Badges are typically used to decorate the icon within a `NavigationDestination`, a `NavigationRailDestination`, A `NavigationDrawerDestination`, or a button's icon, as in `TextButton.icon`. * [`FilledButton`] and [`FilledButton.tonal`][] are very similar to an `ElevatedButton` without the elevation changes and drop shadow. * [`FilterChip.elevated`][], [`ChoiceChip.elevated`][], and [`ActionChip.elevated`] are elevated variants of the same chips with a drop shadow and a fill color. * [`Dialog.fullscreen`][] fills the entire screen and typically contains a title, an action button, and a close button at the top. [`BottomNavigationBar`]: {{site.api}}/flutter/material/BottomNavigationBar-class.html [`NavigationBar`]: {{site.api}}/flutter/material/NavigationBar-class.html [`Drawer`]: {{site.api}}/flutter/material/Drawer-class.html [`NavigationDrawer`]: {{site.api}}/flutter/material/NavigationDrawer-class.html [`TabBar`]: {{site.api}}/flutter/material/TabBar-class.html [`TabBar.secondary`]: {{site.api}}/flutter/material/TabBar/TabBar.secondary.html [`TabBar.tabAlignment`]: {{site.api}}/flutter/material/TabBar/tabAlignment.html [`SegmentedButton`]: {{site.api}}/flutter/material/SegmentedButton-class.html [`ToggleButtons`]: {{site.api}}/flutter/material/ToggleButtons-class.html [`MenuBar`]: {{site.api}}/flutter/material/MenuBar-class.html [`MenuAnchor`]: {{site.api}}/flutter/material/MenuAnchor-class.html [`DropdownMenu`]: {{site.api}}/flutter/material/DropdownMenu-class.html [`SearchBar`]: {{site.api}}/flutter/material/SearchBar-class.html [`SearchAnchor`]: {{site.api}}/flutter/material/SearchAnchor-class.html [`Badge`]: {{site.api}}/flutter/material/Badge-class.html [`FilledButton`]: {{site.api}}/flutter/material/FilledButton-class.html [`FilledButton.tonal`]: {{site.api}}/flutter/material/FilledButton/FilledButton.tonal.html [`FilterChip.elevated`]: {{site.api}}/flutter/material/FilterChip/FilterChip.elevated.html [`ChoiceChip.elevated`]: {{site.api}}/flutter/material/ChoiceChip/ChoiceChip.elevated.html [`ActionChip.elevated`]: {{site.api}}/flutter/material/ActionChip/ActionChip.elevated.html [`Dialog.fullscreen`]: {{site.api}}/flutter/material/Dialog/Dialog.fullscreen.html ## Timeline In stable release: 3.16 ## References Documentation: * [Material Design for Flutter][] API documentation: * [`ThemeData.useMaterial3`][] Relevant issues: * [Material 3 umbrella issue][] Relevant PRs: * [Change the default for `ThemeData.useMaterial3` to true][] * [Updated `ThemeData.useMaterial3` API doc, default is true][] [Material 3 umbrella issue]: {{site.repo.flutter}}/issues/91605 [Material Design for Flutter]: /ui/design/material [`ThemeData.useMaterial3`]: {{site.api}}/flutter/material/ThemeData/useMaterial3.html [Change the default for `ThemeData.useMaterial3` to true]: {{site.repo.flutter}}/pull/129724 [Updated `ThemeData.useMaterial3` API doc, default is true]: {{site.repo.flutter}}/pull/130764
website/src/release/breaking-changes/material-3-migration.md/0
{ "file_path": "website/src/release/breaking-changes/material-3-migration.md", "repo_id": "website", "token_count": 5363 }
1,441
--- title: The generic type of ParentDataWidget changed to ParentData description: The ParentDataWidget is now bound to the ParentData type. --- ## Summary The generic type of `ParentDataWidget` has changed from `RenderObjectWidget` to `ParentData`. ## Context Prior to this change, a `ParentDataWidget` was bound to a specific `RenderObjectWidget` type as ancestor. For example, a `Positioned` widget could only be used within a `Stack` widget. With this change, a `ParentDataWidget` can be used with any `RenderObjectWidget` type as ancestor as long as the `RenderObject` of said `RenderObjectWidget` sets up the correct `ParentData` type. In this new world, the `Positioned` widget can be reused with a hypothetical new `SuperStack` widget. ## Description of change The generic type argument of `ParentDataWidget` has changed from `RenderObjectWidget` to `ParentData`, and a new debug property, `debugTypicalAncestorWidgetClass`, is added to `ParentDataWidget`. The latter is used for error messages to give users a better idea of the context a given `ParentDataWidget` is supposed to be used in. ## Migration guide You must migrate your code as described in this section if you're subclassing or implementing `ParentDataWidget`. If you do, the analyzer shows the following warnings when you upgrade to the Flutter version that includes this change: ```none error • Missing concrete implementation of 'getter ParentDataWidget.debugTypicalAncestorWidgetClass' • lib/main.dart:114:7 • non_abstract_class_inherits_abstract_member error • 'FrogJar' doesn't extend 'ParentData' • lib/main.dart:114:41 • type_argument_not_matching_bounds ``` Code before migration: ```dart class FrogSize extends ParentDataWidget<FrogJar> { FrogSize({ Key key, required this.size, required Widget child, }) : assert(child != null), assert(size != null), super(key: key, child: child); final Size size; @override void applyParentData(RenderObject renderObject) { final FrogJarParentData parentData = renderObject.parentData; if (parentData.size != size) { parentData.size = size; final RenderFrogJar targetParent = renderObject.parent; targetParent.markNeedsLayout(); } } } class FrogJarParentData extends ParentData { Size size; } class FrogJar extends RenderObjectWidget { // ... } ``` Code after migration: ```dart class FrogSize extends ParentDataWidget<FrogJarParentData> { // FrogJar changed to FrogJarParentData FrogSize({ Key key, required this.size, required Widget child, }) : assert(child != null), assert(size != null), super(key: key, child: child); final Size size; @override void applyParentData(RenderObject renderObject) { final FrogJarParentData parentData = renderObject.parentData; if (parentData.size != size) { parentData.size = size; final RenderFrogJar targetParent = renderObject.parent; targetParent.markNeedsLayout(); } } @override Type get debugTypicalAncestorWidgetClass => FrogJar; // Newly added } ``` The generic type of the `ParentDataWidget` superclass changes from `FrogJar` (a `RenderObjectWidget`) to `FrogJarParentData` (the `ParentData` type that `FrogSize.applyParentData` wants to operate on). Additionally, the new `debugTypicalAncestorWidgetClass` is implemented for this `ParentDataWidget` subclass. It returns the type of a typical ancestor `RenderObjectWidget` for this `ParentDataWidget`. Most of the time, you just want to return the old generic type here (`FrogJar` in this example). ## Timeline Landed in version: 1.16.3<br> In stable release: 1.17 ## References API documentation: * [`ParentDataWidget`][] Relevant PR: * [Make ParentDataWidget usable with different ancestor RenderObjectWidget types][] [Make ParentDataWidget usable with different ancestor RenderObjectWidget types]: {{site.repo.flutter}}/pull/48541 [`ParentDataWidget`]: {{site.api}}/flutter/widgets/ParentDataWidget-class.html
website/src/release/breaking-changes/parent-data-widget-generic-type.md/0
{ "file_path": "website/src/release/breaking-changes/parent-data-widget-generic-type.md", "repo_id": "website", "token_count": 1202 }
1,442
--- title: Migrate ShortcutActivator and ShortcutManager to KeyEvent system description: > The raw key event subsystem has been superseded by the key event subsystem, and APIs that use RawKeyEvent and RawKeyboard are converted to KeyEvent and HardwareKeyboard. --- ## Summary For some time now (years), Flutter has had two key event systems implemented. The new system reached parity with the old platform-specific raw key event system, and the raw system will be removed. To prepare for that, the Flutter APIs that use the old system are being modified, and for a select few of them we have decided to make breaking changes in the API in order to preserve the quality of the API. ## Context In the original key event subsystem handling each platform's quirks in the framework and in client apps caused overly complex code, and the old system didn't properly represent the true state of key events on the system. So, the new [`KeyEvent`][]-based system was born, and to minimize breaking changes, was implemented in parallel with the old system with the intention of eventually deprecating the raw system. That time is quickly arriving, and to prepare for it, we have made some minimal breaking changes required to preserve the quality of the API. ## Description of change Summary of APIs that have been affected: - `ShortcutActivator.accepts` now takes a `KeyEvent` and `HardwareKeyboard`. - `ShortcutActivator.isActivatedBy` is now deprecated. Just call `accepts` instead. - `ShortcutActivator.triggers` is now optional, and returns null if not implemented. - `ShortcutManager.handleKeypress` now takes a `KeyEvent`. The change modifies the `ShortcutActivator.accepts` method to take a `KeyEvent` and `HardwareKeyboard` instead of the previous `RawKeyEvent` and `RawKeyboard`. The meaning of `ShortcutActivator.accepts` has changed slightly. Before the change, it was assumed that `accepts` was only called if `ShortcutActivator.triggers` returned null, or if the key event sent to `accepts` had a logical key that was in the `triggers` list. Now it is always called, and may use the `triggers` list as a performance improvement, but is not required to. Flutter subclasses such as `SingleActivator` and `CharacterActivator` already do this. The change also modifies the `ShortcutManager.handleKeypress` method to take a `KeyEvent` instead of `RawKeyEvent`. ## Migration guide APIs provided by the Flutter framework are already migrated. Migration is needed only if you're using any of the methods listed in the previous section. ### Migrating your APIs that use `ShortcutActivator` or its subclasses. Pass a `KeyEvent` instead of a `RawKeyEvent` to `ShortcutActivator.accepts`. This may mean switching where you get your key events from. Depending on where you get them, this can either mean switching to using `Focus.onKeyEvent` instead of `Focus.onKey`, or a similar change if using `FocusScope`, `FocusNode` or `FocusScopeNode`. If you're using a `RawKeyboardListener`, switch to using a `KeyboardListener` instead. If you're accessing `RawKeyboard` directly, use `HardwareKeyboard` instead. You'll find that there are non-raw equivalents for all of the key event sources. ### Migrating your APIs that extend `ShortcutActivator` The `ShortcutActivator.accepts` method was modified to take a `KeyEvent` and a `HardwareKeyboard` instead of a `RawKeyEvent` and `RawKeyboard`. Before: ```dart class MyActivator extends ShortcutActivator { @override bool accepts(RawKeyEvent event, RawKeyboard state) { // ... (your implementation here) returns false; } // ... } ``` After: ```dart class MyActivator extends ShortcutActivator { @override bool accepts(KeyEvent event, HardwareKeyboard state) { // ... (your implementation here) returns false; } // ... } ``` ### Migrating your APIs that extend `ShortcutManager` The `ShortcutManager` class was modified to take `KeyEvent`s in `handleKeypress` instead of `RawKeyEvent`s. One difference in the two APIs is that repeated keys are determined differently. In the `RawKeyEvent` case, the `repeat` member indicated a repeat, but in `RawKeyEvent` code, the event is a different type (`KeyRepeatEvent`). Before: ```dart class _MyShortcutManager extends ShortcutManager { @override KeyEventResult handleKeypress(BuildContext context, RawKeyEvent event) { if (event is! RawKeyDownEvent) { return KeyEventResult.ignored; } if (event.repeat) { // (Do something with repeated keys.) } // ... (your implementation here) return KeyEventResult.handled; } } ``` After: ```dart class _MyShortcutManager extends ShortcutManager { @override KeyEventResult handleKeypress(BuildContext context, KeyEvent event) { if (event is! KeyDownEvent && event is! KeyRepeatEvent) { return KeyEventResult.ignored; } if (event is KeyRepeatEvent) { // (Do something with repeated keys.) } // ... (your implementation here) return KeyEventResult.handled; } } ``` ## Timeline Landed in version: 3.17.0-5.0.pre<br> In stable release: not yet (Not in 3.17) ## References API documentation: * [`KeyEvent`][] * [`HardwareKeyboard`][] * [`ShortcutActivator`][] * [`ShortcutManager`][] Relevant issues: * [`RawKeyEvent` and `RawKeyboard`, et al should be deprecated and removed (Issue 136419)][] Relevant PRs: * [Prepare ShortcutActivator and ShortcutManager to migrate to KeyEvent from RawKeyEvent.][] [`KeyEvent`]: {{site.api}}/flutter/services/KeyEvent-class.html [`HardwareKeyboard`]: {{site.api}}/flutter/services/HardwareKeyboard-class.html [`ShortcutActivator`]: {{site.api}}/flutter/widgets/ShortcutActivator-class.html [`ShortcutManager`]: {{site.api}}/flutter/widgets/ShortcutManager-class.html [`RawKeyEvent` and `RawKeyboard`, et al should be deprecated and removed (Issue 136419)]: {{site.repo.flutter}}/issues/136419 [Prepare ShortcutActivator and ShortcutManager to migrate to KeyEvent from RawKeyEvent.]: {{site.repo.flutter}}/pull/136854
website/src/release/breaking-changes/shortcut-key-event-migration.md/0
{ "file_path": "website/src/release/breaking-changes/shortcut-key-event-migration.md", "repo_id": "website", "token_count": 1763 }
1,443
--- title: Introduction of FlutterEngine::ProcessExternalWindowMessage description: >- External windows should call ProcessExternalWindowMessage to be considered for application lifecycle events. --- ## Summary When you add any external windows to your Flutter app, you need to include them in the Window's app lifecycle logic. To include the window, its `WndProc` function should invoke `FlutterEngine::ProcessExternalWindowMessage`. ## Who is affected Windows applications built against Flutter 3.13 or newer that open non-Flutter windows. ## Description of change Implementing application lifecycle on Windows involves listening for Window messages in order to update the lifecycle state. In order for additional non-Flutter windows to affect the lifecycle state, they must forward their window messages to `FlutterEngine::ProcessExternalWindowMessage` from their `WndProc` functions. This function returns an `std::optional<LRESULT>`, which is `std::nullopt` when the message is received, but not consumed. When the returned result has a value, the message has been consumed, and further processing in `WndProc` should cease. ## Migration guide The following example `WndProc` procedure invokes `FlutterEngine::ProcessExternalWindowMessage`: ```cpp LRESULT Window::Messagehandler(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { std::optional<LRESULT> result = flutter_controller_->engine()->ProcessExternalWindowMessage(hwnd, msg, wparam, lparam); if (result.has_value()) { return *result; } // Original contents of WndProc... } ``` ## Timeline Landed in version: 3.14.0-3.0.pre<br> In stable release: 3.16 ## References Relevant PRs: * [Reintroduce Windows lifecycle with guard for posthumous OnWindowStateEvent][] [Reintroduce Windows lifecycle with guard for posthumous OnWindowStateEvent]: {{site.repo.engine}}/pull/44344
website/src/release/breaking-changes/win-lifecycle-process-function.md/0
{ "file_path": "website/src/release/breaking-changes/win-lifecycle-process-function.md", "repo_id": "website", "token_count": 527 }
1,444
--- title: Flutter Changelog 0.0.21 - 1.0.0 short-title: Flutter Changelog up to 1.0.0 description: Archived Changelog wiki page, containing release information between Flutter 0.0.21 and 1.0.0. --- _This page is a dump of the old Changelog page from the Flutter wiki up until [Flutter release notes](./) were published in flutter.dev._ ## Changes through and including 1.0.0 * Skia and engine rolls to address the following: * [video_player image distortion problem after last flutter update 0.11.3](https://github.com/flutter/flutter/issues/24402) * [Green, flickering bar over camera preview](https://github.com/flutter/flutter/issues/24289) * [Image rendering issues on Adreno 3xx devices after upgrade from 0.9.4 to 0.10.2](https://github.com/flutter/flutter/issues/24517) * Engine rolls to fix * [Prepend [NSLocale currentLocale] for first locale on iOS to ensure countryCode exists. Allow language-only locales.](https://github.com/flutter/engine/issues/6995) * [Changes to unblock Fuchsia roll](https://github.com/flutter/engine/issues/6949) * Various fixes to tooling for documentation, documentation, and documentation accompanying the templates. ## Changes since v0.10.2 * [flutter/engine#6883](https://github.com/flutter/engine/pull/6883) - FlutterViewController will no longer load your app's splash screen by default. The implementation of that has been moved to a new method `loadDefaultSplashScreenView`. * [#23755](https://github.com/flutter/flutter/pull/23755) Removed direct dependency of flutter_test on `package:test`. Flutter now requires test version 1.5.1 and mockito version 4.0.0. ### Breaking change: This requires adding an explicit dependency to your pubspec.yaml: ```yaml dev_dependencies: test: ^1.5.1 ``` * [#24024](https://github.com/flutter/flutter/pull/24024) and [flutter/engine#6760](https://github.com/flutter/engine/pull/6760) Upgraded harfbuzz to 2.1.0, Significantly improved text layout, and zero-width-joiner (zwj) support for better emojis on iOS. * [#23417](https://github.com/flutter/flutter/pull/23417) provide `null` when locale is unavailable or invalid instead of `_`. * [#23583](https://github.com/flutter/flutter/pull/23583) Improved localization algorithm with scriptCodes and full preferred locales list support, breaking changes to callbacks when locales are changed (pass list instead of single locale). ### v0.11.0 * [#23320](https://github.com/flutter/flutter/pull/23320) Adds back swipe gesture support for Cupertino navigation bars' cross-page transitions. * [#23320](https://github.com/flutter/flutter/pull/23322) Adds support for Hero transitions across multiple Navigators. ## Changes in v0.10.2 (since v0.9.4) - beta 10 ### v0.10.2 * [#23194](https://github.com/flutter/flutter/pull/23194) Adds CupertinoTextField, an iOS styled text entry field. * [#23221](https://github.com/flutter/flutter/pull/23221) Adds RTL support for Cupertino navigation bars' cross-page transitions. ### v0.10.1 * [#22977](https://github.com/flutter/flutter/pull/22977) replaces most of `Null` by `void`. See [the mail proposing this change](https://groups.google.com/forum/#!topic/flutter-dev/b7TKGqERNTM). * [#22985](https://github.com/flutter/flutter/pull/22985) Implement correct orthographic projection * [#23104](https://github.com/flutter/flutter/pull/23104) Update wrapping message * [#22924](https://github.com/flutter/flutter/pull/22924) Support for disabling interactive TextField caret and selection * [#22870](https://github.com/flutter/flutter/pull/22870) Use new `mixin` syntax for super-mixins * [#22022](https://github.com/flutter/flutter/pull/22022) allow command line option "--project-name" in flutter create * [#23126](https://github.com/flutter/flutter/pull/23126) Dispatch a Flutter.Navigation event each time navigation occurs. * [#23183](https://github.com/flutter/flutter/pull/23183) Fix bug where gradle build rule would rerun on switching from * [#22394](https://github.com/flutter/flutter/pull/22394) Fix out of range spring simulation in ClampingScrollSimulation * [#23174](https://github.com/flutter/flutter/pull/23174) enable lint prefer_void_to_null * [#23184](https://github.com/flutter/flutter/pull/23184) TextTheme.apply() should not assume non-null TextStyle fields * [#23168](https://github.com/flutter/flutter/pull/23168) Added Mongolian (mn) translations * [#23167](https://github.com/flutter/flutter/pull/23167) Fix disabled formfield validation * [#23015](https://github.com/flutter/flutter/pull/23015) Finalize editing when hitting the enter key on a single line TextField * [#23021](https://github.com/flutter/flutter/pull/23021) Make it easier to use CocoaPods to Add2App for iOS * [#22825](https://github.com/flutter/flutter/pull/22825) fix Curves.bounceInOut math * [#22977](https://github.com/flutter/flutter/pull/22977) Prefer void to null * [#22822](https://github.com/flutter/flutter/pull/22822) Adds callback for Long Press Up * [#18770](https://github.com/flutter/flutter/pull/18770) Add `disabledHint` to DropdownButton * [#21657](https://github.com/flutter/flutter/pull/21657) Make AndroidView take gesture recognizer factories. * [#22449](https://github.com/flutter/flutter/pull/22449) Add support for text shadows * [flutter/engine#6644](https://github.com/flutter/engine/pull/6644) Add BoxHeightStyle and BoxWidthStyle as arguments to Paragraph.getBoxesForRange() to obtain various styles of enclosing boxes. * Skia update that changes the low level implementation of blurs and anti aliasing, which may break golden tests. ### v0.9.7 * [flutter/engine#6393](https://github.com/flutter/engine/pull/6393) adds nullability annotations to Android MethodChannel/MethodCall. ### v0.9.6 * [#21251](https://github.com/flutter/flutter/pull/21251) adds CupertinoDatePicker, an iOS-style picker control that supports a date mode and a date + time mode. ## Changes in v0.9.4 (since v0.8.2 ) - beta 9 ### v0.9.4 * [#21715](https://github.com/flutter/flutter/pull/21715), The default MaterialPageRoute transition is now defined by the Theme. Added (optional) support for Android P style page transitions. The MaterialPageRoute support for "hosting" another route to reuse its buildTransitions() method was removed because PageTransitionsBuilders, including CupertinoPageTransitionBuilder, are standalone objects. ### v0.9.3 * [#22108](https://github.com/flutter/flutter/pull/22108) changed the output of `flutter doctor` slightly, which may affect automated scripts that depended on the exact output. ### v0.9.2 * [#21540](https://github.com/flutter/flutter/pull/21540) added a `transform()` method to [`Animatable`](https://api.flutter.dev/flutter/animation/Animatable-class.html). It is implemented by `Tween` (the main subclass of `Animatable`) but classes that subclass `Animatable` directly will need to implement it. Typically the existing `evaluate()` method can be changed to implement `transform()` instead, using the value given by the argument to `transform()` rather than the current value of the animation provided to `evaluate()`. `evaluate()` now has a default implementation that defers to `transform()`. ## Changes in v0.8.2 (since v0.7.3) - beta 8 ### v0.7.4 * [#20322](https://github.com/flutter/flutter/pull/20322) performs parallax transitions between `CupertinoNavigationBar`s and `CupertinoSliverNavigationBar`s when navigating between pages. ## Changes in v0.7.3 (since v0.6.0) - beta 7 ### v0.7.3 * [#20966](https://github.com/flutter/flutter/pull/20966) adds `CupertinoTimerPicker`. ### v0.7.2 * [#20929](https://github.com/flutter/flutter/pull/20929) fixes bug where `CupertinoPageScaffold` wasn't insetting its content when the keyboard is shown. ### v0.7.1 * [#19637](https://github.com/flutter/flutter/pull/19637) `CupertinoNavigationBar` and `CupertinoSliverNavigationBar` now auto-populate their title and back button labels based on their `CupertinoPageRoute.title`. ## Changes in v0.6.0 (since v0.5.1) - beta 6 ### v0.6.0 * Dart SDK updated to a Dart 2 build (2.1.0-dev.0.0). Package and plugin authors should ensure their `pubspec.yaml` files include a Dart SDK constraint with an upper bound of `<3.0.0`. See the [Getting ready for Dart 2 post](https://medium.com/dartlang/getting-ready-for-dart-2-and-making-your-packages-look-great-on-the-pub-site-118464d7f59d) for details. * [#19025](https://github.com/flutter/flutter/pull/19025) renamed `CupertinoRefreshControl` to `CupertinoSliverRefreshControl` for consistency. * [#19317](https://github.com/flutter/flutter/pull/19317) Add cursorWidth and cursorRadius to TextField (Material) cursor. * [#20116](https://github.com/flutter/flutter/pull/20116) reduced release binary sizes by ~2MB * [#20267](https://github.com/flutter/flutter/pull/20267) adds `CupertinoSegmentedControl'. * [#19232](https://github.com/flutter/flutter/pull/19232) adds `CupertinoActionSheet` for iOS-style bottom pop-up sheets. * [#20101](https://github.com/flutter/flutter/pull/20101) improves `CupertinoScrollbar` visual fidelity during overscrolls. * [#19789](https://github.com/flutter/flutter/pull/19789) adds support for infinite scrolling and looped scrolling for `CupertinoPicker`. * [#18381](https://github.com/flutter/flutter/pull/18381) improves visual fidelity of `CupertinoAlertDialog`. ### v0.5.8 * [#19284](https://github.com/flutter/flutter/pull/19284) adds multi-column `CupertinoPicker` support for off-axis cylindrical projection. ### v0.5.7 * [#18469](https://github.com/flutter/flutter/pull/18469) added a `CupertinoApp` for creating iOS styled apps. ### v0.5.6 * [#18614](https://github.com/flutter/flutter/pull/18614) added `isInstanceOf` as a function exported from Flutter, because package:matcher has deprecated its implementation of `isInstanceOf`. * [flutter/engine#5517](https://github.com/flutter/engine/pull/5517) enabled the `--sync-async` Dart flag. ### v0.5.5 * [#18488](https://github.com/flutter/flutter/pull/18488) made the `--debug-port` argument to `flutter trace` required, because the previous behaviour was unreliable and caused flaky tests. ### v0.5.2 * [#18096](https://github.com/flutter/flutter/pull/18096) changed the rendering of the character counter in text fields to more closely match the Material design specifications. ## Changes in v0.5.1 (since v0.3.2) - beta 5 ### v0.5.0 * [#17661](https://github.com/flutter/flutter/pull/17661) changed the layout and size of `ListTile` to better conform to the latest Material design specs. * [#17620](https://github.com/flutter/flutter/pull/17620) slightly reduces the default dimensions of `Checkbox`, `Radio`, and `Switch` to better conform to the latest Material design specs. * [#17637](https://github.com/flutter/flutter/pull/17637) updates `Checkbox`, `Radio`, and `Switch` to use the `ThemeData` `toggleableActiveColor`. If you are using a light theme and are not specifying an `accentColor` in your `ThemeData`, these controls will now use a higher contrast shade from the primary swatch. * [#17586](https://github.com/flutter/flutter/pull/17586) added a new `background` property to `TextStyle`. Subclasses must ensure that this property is handled in constructors and `copyWith`. ## Changes in v0.4.4 (since v0.3.2) - beta 4 ### v0.4.0 * [#17021](https://github.com/flutter/flutter/pull/17021) added implicit a11y scrolling for iOS. For this, viewports define a cache extend before the leading as well as after the trailing edge and slivers are expected to provide semantics information if they fall into the cache extent. ### Breaking change With this change, children of a viewport that are currently not visible in the viewport are now considered off-stage. To find them in a test, specify `skipOffstage: false` on the Finder. ### v0.3.6 * [#17094](https://github.com/flutter/flutter/pull/17094) introduced the ability to do golden image testing in widget tests. Within a widget test, you can now use the following matcher to ensure that your widget's rasterized image matches a golden file (e.g. `foo.png`): ```dart await expectLater(find.byType(MyWidget), matchesGoldenFile('foo.png')); ``` ### Breaking change One of the consequences of this change is that all tests run through `flutter test` now explicitly depend on `package:flutter_test`. Users of `flutter test` will need to update their `pubspec.yaml` file to include the following if it does not already exist: ``` dev_dependencies: flutter_test: sdk: flutter ``` If your `pubspec.yaml` does not contain the requisite dependency, and you run `flutter test`, you will see errors of the following form: ``` compiler message: Error: Could not resolve the package 'flutter_test' in 'package:flutter_test/flutter_test.dart'. ``` ### v0.3.3 * [flutter/engine#5060](https://github.com/flutter/engine/pull/5060) introduced the ability to encode a `dart:ui Image` into a PNG via `Image.toByteData()`. Callers wishing to get encoded bytes may pass the `format` argument, like so: ```dart image.toByteData(format: ui.ImageByteFormat.png); ``` ## Changes in v0.3.2 (since v0.3.1) - beta 3 ## Changes in v0.3.1 (since v0.2.8) - beta 2 update We are aware of a potential problem with certificate validation in the `HttpClient` implementation. To follow our investigation, see [Dart issue 32936](https://github.com/dart-lang/sdk/issues/32936). ### v0.3.1 * [flutter/engine#4932](https://github.com/flutter/engine/pull/4932) introduced a new shell embedding API with numerous new features. In particular, a single process can now host multiple Flutter shells. * [flutter/engine#4762](https://github.com/flutter/engine/pull/4762) and [flutter/engine#5008](https://github.com/flutter/engine/pull/5008) introduced `Image.toByteData()`, which is used to get the raw RGBA bytes of an `Image` instance in `dart:ui`. * [#16721](https://github.com/flutter/flutter/pull/16721) scroll motion starts on iOS has been fine tuned to avoid a jump when the scroll first starts moving and to more closely mirror native behavior. ### v0.2.11 * [#16039](https://github.com/flutter/flutter/pull/16039) and [#16447](https://github.com/flutter/flutter/pull/16447) substantially revised the `Chip` implementation, added new chip types: `InputChip`, `ChoiceChip`, `FilterChip`, `ActionChip`, and updated the appearance of chips. ### v0.2.9 * [#16187](https://github.com/flutter/flutter/pull/16187) updated the `Card` widget's shape and elevation. ### Dart changes since Flutter v0.2.8 * `dart:async`: Removed the deprecated `defaultValue` parameter on `Stream.firstWhere` and `Stream.lastWhere`. * `dart:core`: Added `tryParse` static method to `int`, `double`, `num`, `BigInt`, `Uri` and `DateTime`, and deprecated `onError` parameter on `int.parse`, `double.parse`, and `num.parse`. * The `new` keyword can now always be omitted. The `const` keyword is required to create a constant expression, although within the expression, further `const` keywords can also be omitted. ## Changes in v0.2.8 (since v0.2.3) - beta 2 ### v0.2.8 * [#16040](https://github.com/flutter/flutter/pull/16040) adds an API to let `CupertinoTabScaffold`'s current tab be programmatically changed via its `CupertinoTabBar`'s `currentIndex`. ### v0.2.5 * [#15416](https://github.com/flutter/flutter/pull/15416) removed `package:http` from Flutter and replaced all usages with the `HttpClient` from `dart:io`. If you use `package:http` you must add it as a dependency in your `pubspec.yaml` to continue using it. `createHttpClient()` was also removed after being marked deprecated. To change how the framework creates http clients, you can use [HttpOverrides](https://api.flutter.dev/flutter/dart-io/HttpOverrides-class.html) from `dart:io` to provide your own `createHttpClient()` callback globally or per zone. More details are available [in the announcement](https://groups.google.com/forum/#!topic/flutter-dev/AnqDqgQ6vus). * [#15871](https://github.com/flutter/flutter/pull/15871) changed the default configuration of the `AndroidManifest.xml` created by `flutter create`. "screenLayout" and "density" are now included by default in the configChanges attribute, preventing flutter apps from restarting when these change. * [#15324](https://github.com/flutter/flutter/pull/15324) adds a new CupertinoRefreshControl widget styled after the iOS pull-to-refresh pattern. Demo available in the Flutter Gallery. ### v0.2.4 * [#15565](https://github.com/flutter/flutter/pull/15565) turned Dart 2 mode on by default. To run in Dart 1 mode, you can still use `--no-preview-dart-2`. More details are available [in the announcement](https://groups.google.com/d/msg/flutter-dev/H8dDhWg_c8I/_Ql78q_6AgAJ). * [#15537](https://github.com/flutter/flutter/pull/15537) removed SemanticsSortOrder. From now on traversal sorting is done among sibling nodes only. More details available [in the announcement](https://groups.google.com/forum/#!topic/flutter-dev/iCoLnW31heE). * [#15484](https://github.com/flutter/flutter/pull/15484) changed the meaning of the `TextFormField` `initialValue` constructor parameter. The TextFormField initialValue parameter no longer unconditionally initializes the text property of its TextEditingController. If you create a TextFormField and provide a controller, the initialValue must be null, which is now the default. If you're providing a controller you can specify it's initial text value with the TextEditingController text property. > #### Before > new TextFormField( > initialValue: 'Hello World', > controller: _myTextEditingController, > ); > > #### After > new TextFormField( > controller: _myTextEditingController ..text = 'Hello World', > ) > // Or more typically: > _myTextEditingController = new TextEditingController( > text: 'Hello World', > ); > new TextFormField( > controller: _myTextEditingController, > ); * [#15303](https://github.com/flutter/flutter/pull/15303) updated the `showDialog` function to take a builder and deprecated the `widget` parameter. > #### Before > showDialog(context: context, child: new Text('hello')) > > #### After > showDialog(context: context, builder: (BuildContext context) => new Text('hello')) * [#15265](https://github.com/flutter/flutter/pull/15265) updated `ThemeData` to use the primary color of a `MaterialColor` instead of unconditionally using the 500 shade for light themes. The color values remain unchanged. > #### Before > expect(widget.color, Colors.blue.shade500) // primary color > > #### After > expect(widget.color, Colors.blue) // primary color * [#15548](https://github.com/flutter/flutter/pull/15548) adds debugging flags `debugDisableClipLayers`, `debugDisablePhysicalShapeLayers` and `debugDisableOpacityLayers` to help with performance diagnosis of rasterizing speed. ## Changes in v0.2.3 (since v0.1.5) - beta 1 update ### v0.2.0 * [flutter/engine#4742](https://github.com/flutter/engine/pull/4742) updated assets to be read directly out of the APK on Android. As a result, leading slashes are no longer supported in image asset paths: > #### Before > new Image.asset('/foo/bar.png') > > #### After: > new Image.asset('foo/bar.png') ### v0.1.9 * [#14901](https://github.com/flutter/flutter/pull/14901) A [Slider](https://api.flutter.dev/flutter/material/Slider-class.html) visual update changed the colors, opacities, and the value indicator shape and behavior. It also removed the "`thumbOpenAtMin`" flag from the Slider class, which is no longer needed, and can be emulated by the custom thumb shape support. ## Changes in v0.1.5 (since v0.1.4) - beta 1.1 ### v0.1.5 * [#14714](https://github.com/flutter/flutter/pull/14714) fixed the groovy script for the Flutter Gallery, thus fixing [#14912](https://github.com/flutter/flutter/issues/14912). ## Changes in v0.1.4 (since v0.0.20) - beta 1 ### v0.1.3 * [#14702](https://github.com/flutter/flutter/pull/14702) removed the `engineDartVersion` getter from the flutter tool's `Version` class. ### v0.1.1 * [flutter/engine#4607](https://github.com/flutter/engine/pull/4607) and [#14601](https://github.com/flutter/flutter/pull/14601) removed default constructors from the following `dart:ui` classes: * `Codec` * `FrameInfo` * `Gradient` * `Image` * `Paragraph` * `Picture` * `Scene` * `SemanticsUpdate` * `Shader` The default constructors were removed to prevent the creation of uninitialized instances of these classes (and in certain cases to prevent extending these classes). These classes should be instantiated only by the Flutter engine or through named constructors (if provided). ### v0.0.24 * [#14410](https://github.com/flutter/flutter/pull/14410) contained a breaking API change to `ButtonTheme`: * The constructors `ButtonTheme()` and `ButtonTheme.bar()` are no longer `const` constructible * `ButtonTheme.textTheme` is now `ButtonTheme.data.textTheme` * `ButtonTheme.minWidth` is now `ButtonTheme.data.minWidth` * `ButtonTheme.height` is now `ButtonTheme.data.height` * `ButtonTheme.padding` is now `ButtonTheme.data.padding` * [#14410](https://github.com/flutter/flutter/pull/14410) changed the hierarchy of `FlatButton` and `RaisedButton` - they both inherit from `RawMaterialButton` now rather than from `MaterialButton`. * [#14410](https://github.com/flutter/flutter/pull/14410) changed `RaisedButton` to no longer cast a shadow when disabled. ### v0.0.23 * [#14343](https://github.com/flutter/flutter/pull/14343) revised how copy, cut, and paste works for EditableText: The abstract class TextSelectionControls has new methods canCopy, canCut, etc. to determine if those actions are available. The TextSelectionDelegate interface now requires an additional method bringIntoView(TextPosition position) to scroll a TextPosition into the visible part of a TextField. Furthermore, that interface is no longer implemented by TextSelectionOverlay. In its place EditableTextState should be used, which implements that interface. See also: [flutter-dev/IHPndyUDy0M](https://groups.google.com/forum/#!topic/flutter-dev/IHPndyUDy0M) #### Sliver APIs * [#14449](https://github.com/flutter/flutter/pull/14449) replaces the `SliverGridLayout.estimateMaxScrollOffset` method by the `SliverGridLayout.computeMaxScrollOffset` method. This new method must report an accurate value, not just an estimate. This was necessary to fix a bug where a finite `SliverGrid` could not handle being scrolled off the top of the screen (because we had no way to determine how much content it had). For similar reasons, the `RenderSliverBoxChildManager` interface has a new getter, `childCount`, which must return a non-null value if `createChild` can return null. In practice, it is unusual to implement this interface, so this should have no effect. It is more common to implement the widgets-layer equivalent, `SliverChildDelegate`. This interface already had an `estimatedChildCount` getter. The getter continues to exist, though its semantics have been adjusted a little to require that the returned value be accurate if the `build` method on the delegate ever returns null. ### v0.0.21 * [#13734](https://github.com/flutter/flutter/pull/13734), [#14055](https://github.com/flutter/flutter/pull/14055), and [#14177](https://github.com/flutter/flutter/pull/14177) substantially revised the InputDecorator et al. widgets. The layout of the input decorator's parts has changed a little, which means that the internal layout of text fields has changed as well. Tests that depend on the internal geometry of text fields will need to be updated. In addition, `hideDivider: true` must be replaced by the new `border: InputBorder.none`. This is part of our making it easier to customize how inputs are rendered; you can now also provide a custom InputBorder subclass if you have particularly novel desires for your input decoration. * [#4528](https://github.com/flutter/engine/pull/4528) and [#14011](https://github.com/flutter/flutter/pull/14011) deprecated support for big integers in the standard platform channel message/method codecs, to be made unavailable following a four week grace period. This change is a consequence of the transition to Dart 2.0 where the `int` type is no longer unlimited size. * [#4487](https://github.com/flutter/engine/pull/4487) replaces all uses of the `RequestPermissionResult` callback concept in `io.flutter.plugin.common.PluginRegistry` with `RequestPermissionsResult`, adding a missing `s` to align with the corresponding Android SDK concept. The old API has been deprecated and will be made unavailable in a later release. There will be a grace period of at least four weeks between the release that introduces the deprecation and the release that makes the old API unavailable.
website/src/release/release-notes/release-notes-0.0.21-1.0.0.md/0
{ "file_path": "website/src/release/release-notes/release-notes-0.0.21-1.0.0.md", "repo_id": "website", "token_count": 7665 }
1,445
--- title: Casual Games Toolkit description: Free & open source multiplatform 2D game development in Flutter --- The Flutter Casual Games Toolkit pulls together new and existing resources so you can accelerate development of games on mobile platforms. This page outlines where you can find these available resources. ## Why Flutter for games? The Flutter framework can create performant apps for six target platforms from the desktop to mobile devices to the web. With Flutter's benefits of cross-platform development, performance, and open source licensing, it makes a great choice for games. Casual games fall into two categories: turn-based games and real-time games. You might be familiar with both types of games, though perhaps you didn't think about them in quite this way. _Turn-based games_ cover games meant for a mass market with simple rules and gameplay. This includes board games, card games, puzzles, and strategy games. These games respond to simple user input, like tapping on a card or entering a number or letter. These games are well suited for Flutter. _Real-time games_ cover games a series of actions require real time responses. These include endless runner games, racing games, and so on. You might want to create a game with advanced features like collision detection, camera views, game loops, and the like. These types of games could use an open source game engine like the [Flame game engine][] built using Flutter. ## What's included in the toolkit The Casual Games Toolkit provides the following free resources. * A repository that includes three new game templates that provide a starting point for building a casual game. 1. A [base game template][basic-template] that includes the basics for: * Main menu * Navigation * Settings * Level selection * Player progress * Play session management * Sound * Themes 1. A [card game template][card-template] that includes everything in the base template plus: * Drag and drop * Game state management * Multiplayer integration hooks 1. An [endless runner template][runner-template] created in partnership with the open source game engine, Flame. It implements: * A FlameGame base template * Player steering * Collision detection * Parallax effects * Spawning * Different visual effects 1. A sample game built on top of the endless runner template, called SuperDash. You can play the game on iOS, Android, or [web][], [view the open source code repo][], or [read how the game was created in 6 weeks][]. * Developer guides for integrating needed services. * A link to a [Flame Discord][game-discord] channel. If you have a Discord account, use this [direct link][discord-direct]. The included game templates and cookbook recipes make certain choices to accelerate development. They include specific packages, like `provider`, `google_mobile_ads`, `in_app_purchase`, `audioplayers`, `crashlytics`, and `games_services`. If you prefer other packages, you can change the code to use them. The Flutter team understands that monetization might be a future consideration. Cookbook recipes for advertising and in-app purchases have been added. As explained on the [Games][] page, you can leverage up to $900 in offers when you integrate Google services, such as [Cloud, Firebase][], and [Ads][], into your game. {{ site.alert.important }} **Terms and conditions apply.** You must connect your Firebase and GCP accounts to use credits for Firebase services and verify your business email during sign up to earn an additional $100 on top of the normal $300 credit. For the Ads offer, [check your region's eligibility][]. {{ site.alert.end }} ## Get started Are you ready? To get started: 1. If you haven't done so, [install Flutter][]. 1. [Clone the games repo][game-repo]. 1. Review the `README` file for the first type of game you want to create. * [basic game][basic-template-readme] * [card game][card-template-readme] * [runner game][runner-template-readme] 1. [Join the Flame community on Discord][game-discord] (use the [direct link][discord-direct] if you already have a Discord account). 1. Review the codelabs and cookbook recipes. * Build a [multiplayer game][multiplayer-recipe] with Cloud Firestore. * Make your games more engaging with [leaderboards and achievements][leaderboard-recipe]. * Monetize your games with [in-game ads][ads-recipe] and [in-app purchases][iap-recipe]. * Add user authentication flow to your game via [Firebase Authentication][firebase-auth]. * Collect analytics about crashes and errors inside your game with [Firebase Crashlytics][firebase-crashlytics]. 1. Set up accounts on AdMob, Firebase, and Cloud, as needed. 1. Write your game! 1. Deploy to both the Google Play and Apple stores. ## Example games For Google I/O 2022, both the Flutter team and Very Good Ventures created new games. * VGV created the [I/O Pinball game][pinball-game] using the Flame engine. To learn about this game, check out [I/O Pinball Powered by Flutter and Firebase][] on Medium and [play the game][pinball-game] in your browser. * The Flutter team created [I/O Flip][flip-game], a virtual [CCG]. To learn more about I/O Flip, check out [How It's Made: I/O FLIP adds a twist to a classic card game with generative AI][flip-blog] on the Google Developers blog and [play the game][flip-game] in your browser. {% comment %} Some examples of successful mobile videogames built with Flutter and Flame include [Tomb Toad][] and [Air Hockey][]. {% endcomment %} ## Other resources Once you feel ready to go beyond these games templates, investigate other resources that our community recommended. {% assign pkg-icon = '<span class="material-symbols">package_2</span>' %} {% assign doc-icon = '<span class="material-symbols">quick_reference_all</span>' %} {% assign codelab = '<span class="material-symbols">science</span>' %} {% assign engine = '<span class="material-symbols">manufacturing</span>' %} {% assign tool-icon = '<span class="material-symbols">handyman</span>' %} {% assign recipe-icon = '<span class="material-symbols">book_5</span>' %} {% assign assets-icon = '<span class="material-symbols">photo_album</span>' %} {% assign api-icon = '<span class="material-symbols">api</span>' %} {{ site.alert.secondary }} {{pkg-icon}} Flutter package<br> {{api-icon}} API documentation<br> {{codelab}} Codelab <br> {{recipe-icon}} Cookbook recipe<br> {{tool-icon}} Desktop application<br> {{assets-icon}} Game assets<br> {{doc-icon}} Guide<br> {{ site.alert.end }} <table class="table table-striped" markdown="1"> <tr> <th>Feature</th> <th>Resources</th> </tr> <tr> <td>Animation and sprites</td> <td markdown="1"> {{recipe-icon}} [Special effects][]<br> {{tool-icon}} [Spriter Pro][]<br> {{pkg-icon}} [rive][]<br> {{pkg-icon}} [spriteWidget][] </td> </tr> <tr> <td>App review</td> <td markdown="1"> {{pkg-icon}} [app_review][] </td> </tr> <tr> <td>Audio</td> <td markdown="1"> {{pkg-icon}} [audioplayers][] </td> </tr> <tr> <td>Authentication</td> <td markdown="1"> {{codelab}} [User Authentication using Firebase][firebase-auth] </td> </tr> <tr> <td>Cloud services</td> <td markdown="1"> {{codelab}} [Add Firebase to your Flutter game][] </td> </tr> <tr> <td>Debugging</td> <td markdown="1"> {{doc-icon}} [Firebase Crashlytics overview][firebase-crashlytics]<br> {{pkg-icon}} [firebase_crashlytics][] </td> </tr> <tr> <td>Drivers</td> <td markdown="1"> {{pkg-icon}} [win32_gamepad][] </td> </tr> <tr> <td>Game assets<br>and asset tools</td> <td markdown="1"> {{assets-icon}} [CraftPix][]<br> {{assets-icon}} [Game Developer Studio][]<br> {{tool-icon}} [GIMP][] </td> </tr> <tr> <td>Game engines</td> <td markdown="1"> {{pkg-icon}} [Flame][flame-pkg]<br> {{pkg-icon}} [Bonfire][bonfire-pkg]<br> {{pkg-icon}} [forge2d][] </td> </tr> <tr> <td>Game features</td> <td markdown="1"> {{recipe-icon}} [Add achievements and leaderboards to your game][leaderboard-recipe]<br> {{recipe-icon}} [Add multiplayer support to your game][multiplayer-recipe] </td> </tr> <tr> <td>Game services integration</td> <td markdown="1"> {{pkg-icon}} [games_services][game-svc-pkg] </td> </tr> <tr> <td>Legacy code</td> <td markdown="1"> {{codelab}} [Use the Foreign Function Interface in a Flutter plugin][] </td> </tr> <tr> <td>Level editor</td> <td markdown="1"> {{tool-icon}} [Tiled][] </td> </tr> <tr> <td>Monetization</td> <td markdown="1"> {{recipe-icon}} [Add advertising to your Flutter game][ads-recipe]<br> {{codelab}} [Add AdMob ads to a Flutter app][]<br> {{codelab}} [Add in-app purchases to your Flutter app][iap-recipe]<br> {{doc-icon}} [Gaming UX and Revenue Optimizations for Apps][] (PDF) </td> </tr> <tr> <td>Persistence</td> <td markdown="1"> {{pkg-icon}} [shared_preferences][]<br> {{pkg-icon}} [sqflite][]<br> {{pkg-icon}} [cbl_flutter][] (Couchbase Lite)<br> </td> </tr> <tr> <td>Special effects</td> <td markdown="1"> {{api-icon}} [Paint API][]<br> {{recipe-icon}} [Special effects][] </td> </tr> <tr> <td>User Experience</td> <td markdown="1"> {{codelab}} [Build next generation UIs in Flutter][] </td> </tr> </table> {% assign games-gh = site.github | append: '/flutter/games' -%} [Ads]: https://ads.google.com/intl/en_us/home/flutter/#!/ [Air Hockey]: https://play.google.com/store/apps/details?id=com.ignacemaes.airhockey [CCG]: https://en.wikipedia.org/wiki/Collectible_card_game [Cloud, Firebase]: https://cloud.google.com/free [Flame game engine]: https://flame-engine.org/ [Games]: {{site.main-url}}/games [I/O Pinball Powered by Flutter and Firebase]: {{site.medium}}/flutter/di-o-pinball-powered-by-flutter-and-firebase-d22423f3f5d [install Flutter]: /get-started/install [Tomb Toad]: https://play.google.com/store/apps/details?id=com.crescentmoongames.tombtoad [basic-template-readme]: {{games-gh}}/blob/main/templates/basic/README.md [basic-template]: {{games-gh}}/tree/main/templates/basic [card-template-readme]: {{games-gh}}/blob/main/templates/card/README.md [card-template]: {{games-gh}}/tree/main/templates/card [check your region's eligibility]: https://www.google.com/intl/en/ads/coupons/terms/flutter/ [discord-direct]: https://discord.com/login?redirect_to=%2Fchannels%2F509714518008528896%2F788415774938103829 [firebase_crashlytics]: {{site.pub}}/packages/firebase_crashlytics [flame-pkg]: {{site.pub}}/packages/flame [flip-blog]: {{site.google-blog}}/2023/05/how-its-made-io-flip-adds-twist-to.html [flip-game]: https://flip.withgoogle.com/#/ [game-discord]: https://discord.gg/qUyQFVbV45 [game-repo]: {{games-gh}} [pinball-game]: https://pinball.flutter.dev/#/ [runner-template-readme]: {{games-gh}}/blob/main/templates/endless_runner/README.md [runner-template]: {{games-gh}}/tree/main/templates/endless_runner [Add AdMob ads to a Flutter app]: {{site.codelabs}}/codelabs/admob-ads-in-flutter [Build next generation UIs in Flutter]: {{site.codelabs}}/codelabs/flutter-next-gen-uis [firebase-crashlytics]: {{site.firebase}}/docs/crashlytics/get-started?platform=flutter [ads-recipe]: /cookbook/plugins/google-mobile-ads [iap-recipe]: {{site.codelabs}}/codelabs/flutter-in-app-purchases#0 [leaderboard-recipe]: /cookbook/games/achievements-leaderboard [multiplayer-recipe]: /cookbook/games/firestore-multiplayer [firebase-auth]: {{site.firebase}}/codelabs/firebase-auth-in-flutter-apps#0 [Use the Foreign Function Interface in a Flutter plugin]: {{site.codelabs}}/codelabs/flutter-ffigen [bonfire-pkg]: {{site.pub}}/packages/bonfire [CraftPix]: https://craftpix.net [Add Firebase to your Flutter game]: {{site.firebase}}/docs/flutter/setup [GIMP]: https://www.gimp.org [Game Developer Studio]: https://www.gamedeveloperstudio.com [Gaming UX and Revenue Optimizations for Apps]: {{site.main-url}}/go/games-revenue [Paint API]: {{site.api}}/flutter/dart-ui/Paint-class.html [Special effects]: /cookbook/effects [Spriter Pro]: https://store.steampowered.com/app/332360/Spriter_Pro/ [app_review]: {{site.pub-pkg}}/app_review [audioplayers]: {{site.pub-pkg}}/audioplayers [cbl_flutter]: {{site.pub-pkg}}/cbl_flutter [firebase_crashlytics]: {{site.pub-pkg}}/firebase_crashlytics [forge2d]: {{site.pub-pkg}}/forge2d [game-svc-pkg]: {{site.pub-pkg}}/games_services [rive]: {{site.pub-pkg}}/rive [shared_preferences]: {{site.pub-pkg}}/shared_preferences [spriteWidget]: {{site.pub-pkg}}/spritewidget [sqflite]: {{site.pub-pkg}}/sqflite [win32_gamepad]: {{site.pub-pkg}}/win32_gamepad [read how the game was created in 6 weeks]: {{site.flutter-medium}}/how-we-built-the-new-super-dash-demo-in-flutter-and-flame-in-just-six-weeks-9c7aa2a5ad31 [view the open source code repo]: {{site.github}}/flutter/super_dash [web]: https://superdash.flutter.dev/ [Tiled]: https://www.mapeditor.org/
website/src/resources/games-toolkit.md/0
{ "file_path": "website/src/resources/games-toolkit.md", "repo_id": "website", "token_count": 4439 }
1,446
--- title: Use a native language debugger short-title: debuggers description: How to connect a native debugger to your running Flutter app. --- <?code-excerpt path-base="testing/native_debugging"?> {{site.alert.note}} This guide presumes you understand general debugging, have installed Flutter and git, and have familiarity with the Dart language as well as one of the following languages: Java, Kotlin, Swift, or Objective-C. {{site.alert.end}} If you write Flutter apps only with Dart code, you can debug your code using your IDE's debugger. The Flutter team recommends VS Code. If you write a platform-specific plugin or use platform-specific libraries, you can debug that portion of your code with a native debugger. - To debug iOS or macOS code written in Swift or Objective-C, you can use Xcode. - To debug Android code written in Java or Kotlin, you can use Android Studio. - To debug Windows code written in C++, you can use Visual Studio. This guide shows you how you can connect _two_ debuggers to your Dart app, one for Dart, and one for the native code. ## Debug Dart code This guide describes how to use VS Code to debug your Flutter app. You can also use your preferred IDE with the Flutter and Dart plugins installed and configured. ## Debug Dart code using VS Code The following procedure explains how to use the Dart debugger with the default sample Flutter app. The featured components in VS Code work and appear when debugging your own Flutter project as well. 1. Create a basic Flutter app. ```terminal $ flutter create my_app ``` ```terminal Creating project my_app... Resolving dependencies in my_app... Got dependencies in my_app. Wrote 129 files. All done! You can find general documentation for Flutter at: https://docs.flutter.dev/ Detailed API documentation is available at: https://api.flutter.dev/ If you prefer video documentation, consider: https://www.youtube.com/c/flutterdev In order to run your application, type: $ cd my_app $ flutter run Your application code is in my_app/lib/main.dart. ``` ```terminal $ cd my_app ``` 1. Open the `lib\main.dart` file in the Flutter app using VS Code. 1. Click the bug icon (![VS Code's bug icon to trigger the debugging mode of a Flutter app](/assets/images/docs/testing/debugging/vscode-ui/icons/debug.png)). This opens the following panes in VS Code: - **Debug** - **Debug Console** - **Widget Inspector** The first time you run the debugger takes the longest. {% comment %} ![VS Code window with debug panes opened](/assets/images/docs/testing/debugging/vscode-ui/screens/vscode-debugger.png){:width="100%"} {% endcomment %} 1. Test the debugger. a. In `main.dart`, click on this line: ```dart _counter++; ``` b. Press <kbd>Shift</kbd> + <kbd>F9</kbd>. This adds a breakpoint where the `_counter` variable increments. c. In the app, click the **+** button to increment the counter. The app pauses. {% comment %} ![Flutter test app paused](/assets/images/docs/testing/debugging/native/macos/basic-app.png){:width="50%"} <div class="figure-caption"> Default Flutter app as rendered on macOS. </div> {% endcomment %} d. At this point, VS Code displays: - In the **Editor Groups**: - The highlighted breakpoint in `main.dart` - The widget hierarchy for the Flutter app in the **Widget Tree** of the **Widget Inspector** - In the **side bar**: - The state of the app in the **Call Stack** section - The value of the `this` local variable in the **Variables** section - In the **panel**: - The log of the Flutter app in the **Debug console** {% comment %} ![VS Code window with Flutter app paused](/assets/images/docs/testing/debugging/vscode-ui/screens/vscode-debugger-paused.png){:width="100%"} {% endcomment %} ### VS Code Flutter debugger The Flutter plugin for VS Code adds a number of components to the VS Code user interface. #### Changes to VS Code interface When launched, the Flutter debugger adds debugging tools to the VS Code interface. The following screenshot and table explain the purpose of each tool. ![VS Code with the Flutter plugin UI additions](/assets/images/docs/testing/debugging/vscode-ui/screens/debugger-parts.png) <div class="table-wrapper" markdown="1"> | Highlight Color in Screenshot | Bar, Panel, or Tab | Contents | |-------------------------------|---------------------|-----------------------------------------------------------------------------------| | **Yellow** | Variables | List of current values of variables in the Flutter app | | | Watch | List of items you chose to track in the Flutter app | | | Call Stack | Stack of active subroutines in the Flutter app | | | Breakpoints | List of exceptions and set breakpoints that you set | | **Green** | `<Flutter files>` | Files that you are editing | | **Pink** | Widget Inspector | Hierarchy of widgets in the running Flutter app | | **Blue** | Layout Explorer | Visual of how Flutter placed the widget you selected in the Widget Inspector | | | Widget Details Tree | List of properties of the widget selected in the Widget Inspector | | **Orange** | Problems | List of issues the Dart analyzer found in the current Dart file | | | Output | Response that the Flutter app returns when building an app | | | Debug Console | Logs or error messages that the Flutter app generates while debugging | | | Terminal | System shell prompt contained in VS Code | {:.table.table-striped} </div> To change where the panel (in **orange**) appears in VS Code, go to **View** > **Appearance** > **Panel Position**. #### VS Code Flutter debugging toolbar The toolbar allows you to debug using any debugger. You can step in, out, and over Dart statements, hot reload, or resume the app. ![Flutter debugger toolbar in VS Code](/assets/images/docs/testing/debugging/vscode-ui/screens/debug-toolbar.png) <div class="table-wrapper" markdown="1"> | Icon | Action | Default Keyboard Shortcut | |-----------------------------------------------------------|-----------------------|-------------------------------------------------------| | {% include_relative vscode-flutter-bar/_play.md %} | Start or Resume | <kbd>F5</kbd> | | {% include_relative vscode-flutter-bar/_pause.md %} | Pause | <kbd>F6</kbd> | | {% include_relative vscode-flutter-bar/_step-over.md %} | Step Over | <kbd>F10</kbd> | | {% include_relative vscode-flutter-bar/_step-into.md %} | Step Into | <kbd>F11</kbd> | | {% include_relative vscode-flutter-bar/_step-out.md %} | Step Out | <kbd>Shift</kbd> + <kbd>F11</kbd> | | {% include_relative vscode-flutter-bar/_hot-reload.md %} | Hot Reload | <kbd>Ctrl</kbd> + <kbd>F5</kbd> | | {% include_relative vscode-flutter-bar/_hot-restart.md %} | Hot Restart | <kbd>Shift</kbd> + <kbd>Special</kbd> + <kbd>F5</kbd> | | {% include_relative vscode-flutter-bar/_stop.md %} | Stop | <kbd>Shift</kbd> + <kbd>F5</kbd> | | {% include_relative vscode-flutter-bar/_inspector.md %} | Open Widget Inspector | | {:.table.table-striped} </div> ## Update test Flutter app For the remainder of this guide, you need to update the test Flutter app. This update adds native code to debug. 1. Open the `lib/main.dart` file using your preferred IDE. 1. Replace the contents of `main.dart` with the following code. <details> <summary>Expand to see Flutter code for this example</summary> <?code-excerpt title="lib/main.dart"?> ```dart // Copyright 2023 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. import 'package:flutter/material.dart'; 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 MaterialApp( title: 'URL Launcher', theme: ThemeData( colorSchemeSeed: Colors.purple, brightness: Brightness.light, ), home: const MyHomePage(title: 'URL Launcher'), ); } } class MyHomePage extends StatefulWidget { const MyHomePage({super.key, required this.title}); final String title; @override State<MyHomePage> createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { Future<void>? _launched; Future<void> _launchInBrowser(Uri url) async { if (!await launchUrl( url, mode: LaunchMode.externalApplication, )) { throw Exception('Could not launch $url'); } } Future<void> _launchInWebView(Uri url) async { if (!await launchUrl( url, mode: LaunchMode.inAppWebView, )) { throw Exception('Could not launch $url'); } } Widget _launchStatus(BuildContext context, AsyncSnapshot<void> snapshot) { if (snapshot.hasError) { return Text('Error: ${snapshot.error}'); } else { return const Text(''); } } @override Widget build(BuildContext context) { final Uri toLaunch = Uri( scheme: 'https', host: 'docs.flutter.dev', path: 'testing/native-debugging'); return Scaffold( appBar: AppBar( title: Text(widget.title), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Padding( padding: const EdgeInsets.all(16), child: Text(toLaunch.toString()), ), FilledButton( onPressed: () => setState(() { _launched = _launchInBrowser(toLaunch); }), child: const Text('Launch in browser'), ), const Padding(padding: EdgeInsets.all(16)), FilledButton( onPressed: () => setState(() { _launched = _launchInWebView(toLaunch); }), child: const Text('Launch in app'), ), const Padding(padding: EdgeInsets.all(16.0)), FutureBuilder<void>(future: _launched, builder: _launchStatus), ], ), ), ); } } ``` </details> 1. To add the `url_launcher` package as a dependency, run `flutter pub add`: ```terminal $ flutter pub add url_launcher ``` ```terminal Resolving dependencies... collection 1.17.1 (1.17.2 available) + flutter_web_plugins 0.0.0 from sdk flutter matcher 0.12.15 (0.12.16 available) material_color_utilities 0.2.0 (0.8.0 available) + plugin_platform_interface 2.1.4 source_span 1.9.1 (1.10.0 available) stream_channel 2.1.1 (2.1.2 available) test_api 0.5.1 (0.6.1 available) + url_launcher 6.1.11 + url_launcher_android 6.0.36 + url_launcher_ios 6.1.4 + url_launcher_linux 3.0.5 + url_launcher_macos 3.0.5 + url_launcher_platform_interface 2.1.3 + url_launcher_web 2.0.17 + url_launcher_windows 3.0.6 Changed 10 dependencies! ``` 1. To check what changed with the codebase: {: type="a"} 1. In Linux or macOS, run this `find` command. ```terminal $ find ./ -mmin -120 ``` ```terminal ./ios/Flutter/Debug.xcconfig ./ios/Flutter/Release.xcconfig ./linux/flutter/generated_plugin_registrant.cc ./linux/flutter/generated_plugins.cmake ./macos/Flutter/Flutter-Debug.xcconfig ./macos/Flutter/Flutter-Release.xcconfig ./macos/Flutter/GeneratedPluginRegistrant.swift ./pubspec.lock ./pubspec.yaml ./windows/flutter/generated_plugin_registrant.cc ./windows/flutter/generated_plugins.cmake ``` 1. In Windows, run this command in the command prompt. ```posh Get-ChildItem C:\dev\example\ -Rescurse | Where-Object {$_.LastWriteTime -gt (Get-Date).AddDays(-1)} ``` ```posh C:\dev\example\ios\Flutter\ Mode LastWriteTime Length Name ---- ------------- ------ ---- 8/1/2025 9:15 AM Debug.xcconfig 8/1/2025 9:15 AM Release.xcconfig C:\dev\example\linux\flutter\ Mode LastWriteTime Length Name ---- ------------- ------ ---- 8/1/2025 9:15 AM generated_plugin_registrant.cc 8/1/2025 9:15 AM generated_plugins.cmake C:\dev\example\macos\Flutter\ Mode LastWriteTime Length Name ---- ------------- ------ ---- 8/1/2025 9:15 AM Flutter-Debug.xcconfig 8/1/2025 9:15 AM Flutter-Release.xcconfig 8/1/2025 9:15 AM GeneratedPluginRegistrant.swift C:\dev\example\ Mode LastWriteTime Length Name ---- ------------- ------ ---- 8/1/2025 9:15 AM pubspec.lock 8/1/2025 9:15 AM pubspec.yaml C:\dev\example\windows\flutter\ Mode LastWriteTime Length Name ---- ------------- ------ ---- 8/1/2025 9:15 AM generated_plugin_registrant.cc 8/1/2025 9:15 AM generated_plugins.cmake ``` Installing `url_launcher` added config files and code files for all target platforms in the Flutter app directory. ## Debug Dart and native language code at the same time This section explains how to debug the Dart code in your Flutter app and any native code with its regular debugger. This capability allows you to leverage Flutter's hot reload when editing native code. ### Debug Dart and Android code using Android Studio To debug native Android code, you need a Flutter app that contains Android code. In this section, you learn how to connect the Dart, Java, and Kotlin debuggers to your app. You don't need VS Code to debug both Dart and Android code. This guide includes the VS Code instructions to be consistent with the Xcode and Visual Studio guides. These section uses the same example Flutter `url_launcher` app created in [Update test Flutter app](#update-test-flutter-app). {% include docs/debug/debug-flow-android.md %} ### Debug Dart and iOS code using Xcode To debug iOS code, you need a Flutter app that contains iOS code. In this section, you learn to connect two debuggers to your app: Flutter via VS Code and Xcode. You need to run both VS Code and Xcode. These section uses the same example Flutter `url_launcher` app created in [Update test Flutter app](#update-test-flutter-app). {% include docs/debug/debug-flow-ios.md %} ### Debug Dart and macOS code using Xcode To debug macOS code, you need a Flutter app that contains macOS code. In this section, you learn to connect two debuggers to your app: Flutter via VS Code and Xcode. You need to run both VS Code and Xcode. These section uses the same example Flutter `url_launcher` app created in [Update test Flutter app](#update-test-flutter-app). {% include docs/debug/debug-flow-macos.md %} ### Debug Dart and C++ code using Visual Studio To debug C++ code, you need a Flutter app that contains C++ code. In this section, you learn to connect two debuggers to your app: Flutter via VS Code and Visual Studio. You need to run both VS Code and Visual Studio. These section uses the same example Flutter `url_launcher` app created in [Update test Flutter app](#update-test-flutter-app). {% include docs/debug/debug-flow-windows.md %} ## Resources Check out the following resources on debugging Flutter, iOS, Android, macOS and Windows: ### Flutter - [Debugging Flutter apps][] - [Flutter inspector][] and the [DevTools][] docs - [Performance profiling][] [Debugging Flutter apps]: /testing/debugging [Performance profiling]: /perf/ui-performance ### Android You can find the following debugging resources on [developer.android.com][]. - [Debug your app][] - [Android Debug Bridge (adb)][] ### iOS and macOS You can find the following debugging resources on [developer.apple.com][]. - [Debugging][] - [Instruments Help][] ### Windows You can find debugging resources on [Microsoft Learn][]. - [Visual Studio Debugger][] - [Learn to debug C++ code using Visual Studio][] [Android Debug Bridge (adb)]: {{site.android-dev}}/studio/command-line/adb [Debug your app]: {{site.android-dev}}/studio/debug [Debugging]: {{site.apple-dev}}/support/debugging/ [developer.android.com]: {{site.android-dev}} [developer.apple.com]: {{site.apple-dev}} [DevTools]: /tools/devtools [Flutter inspector]: /tools/devtools/inspector [Instruments Help]: https://help.apple.com/instruments/mac/current/ [Microsoft Learn]: https://learn.microsoft.com/visualstudio/ [Visual Studio Debugger]: https://learn.microsoft.com/visualstudio/debugger/?view=vs-2022 [Learn to debug C++ code using Visual Studio]: https://learn.microsoft.com/visualstudio/debugger/getting-started-with-the-debugger-cpp?view=vs-2022
website/src/testing/native-debugging.md/0
{ "file_path": "website/src/testing/native-debugging.md", "repo_id": "website", "token_count": 8100 }
1,447
--- title: DevTools description: How to use the DevTools with Flutter. --- ## What is DevTools? DevTools is a suite of performance and debugging tools for Dart and Flutter. ![Dart DevTools Screens](/assets/images/docs/tools/devtools/dart-devtools.gif){:width="100%"} For a video introduction to DevTools, check out the following deep dive and use case walkthrough: <iframe width="560" height="315" src="{{site.yt.embed}}/_EYk-E29edo" title="Dive in to Flutter DevTools" {{site.yt.set}}></iframe> [Dive in to DevTools]({{site.yt.watch}}?v=_EYk-E29edo) ## What can I do with DevTools? Here are some of the things you can do with DevTools: * Inspect the UI layout and state of a Flutter app. * Diagnose UI jank performance issues in a Flutter app. * CPU profiling for a Flutter or Dart app. * Network profiling for a Flutter app. * Source-level debugging of a Flutter or Dart app. * Debug memory issues in a Flutter or Dart command-line app. * View general log and diagnostics information about a running Flutter or Dart command-line app. * Analyze code and app size. We expect you to use DevTools in conjunction with your existing IDE or command-line based development workflow. <a id="how-do-i-install-devtools"></a> <a id="install-devtools"></a> ## How to start DevTools {#start} See the [VS Code][], [Android Studio/IntelliJ][], or [command line][] pages for instructions on how to start DevTools. ## Troubleshooting some standard issues **Question**: My app looks janky or stutters. How do I fix it? **Answer**: Performance issues can cause [UI frames][] to be janky and/or slow down some operations. 1. To detect which code impacts concrete late frames, start at [Performance > Timeline][]. 2. To learn which code takes the most CPU time in the background, use the [CPU profiler][]. For more information, check out the [Performance][] page. **Question**: I see a lot of garbage collection (GC) events occurring. Is this a problem? **Answer**: Frequent GC events might display on the DevTools > Memory > Memory chart. In most cases, it's not a problem. If your app has frequent background activity with some idle time, Flutter might use that opportunity to collect the created objects without performance impact. [CPU profiler]: /tools/devtools/cpu-profiler [Performance]: /perf [Performance > Timeline]: /tools/devtools/performance#timeline-events-tab [UI frames]: /perf/ui-performance ## Providing feedback Please give DevTools a try, provide feedback, and file issues in the [DevTools issue tracker][]. Thanks! ## Other resources For more information on debugging and profiling Flutter apps, see the [Debugging][] page and, in particular, its list of [other resources][]. For more information on using DevTools with Dart command-line apps, see the [DevTools documentation on dart.dev]({{site.dart-site}}/tools/dart-devtools). [Android Studio/IntelliJ]: /tools/devtools/android-studio [VS Code]: /tools/devtools/vscode [command line]: /tools/devtools/cli [DevTools issue tracker]: {{site.github}}/flutter/devtools/issues [Debugging]: /testing/debugging [Other resources]: /testing/debugging#other-resources
website/src/tools/devtools/overview.md/0
{ "file_path": "website/src/tools/devtools/overview.md", "repo_id": "website", "token_count": 925 }
1,448
# DevTools 2.11.2 release notes The 2.11.2 release of the Dart and Flutter DevTools includes the following changes among other general improvements. To learn more about DevTools, check out the [DevTools overview](https://docs.flutter.dev/tools/devtools/overview). ## General updates * This release included a lot of cleanup and reduction in technical debt. ## CPU profiler updates * Added the source line number to file uris in CPU profiles - [#3718](https://github.com/flutter/devtools/pull/3718) ![cpu stack frame line numbers](/tools/devtools/release-notes/images-2.11.2/image1.png "cpu stack frame line numbers") ## Debugger updates * File opener UX improvements, including support for clicking the source file name to open the file search window - [#3612](https://github.com/flutter/devtools/pull/3612), [#3758](https://github.com/flutter/devtools/pull/3758) * Added support for auto-scrolling the File Explorer to the selected file - [#3786](https://github.com/flutter/devtools/pull/3786), [#3794](https://github.com/flutter/devtools/pull/3794) ![debugger file explorer scrolling](/tools/devtools/release-notes/images-2.11.2/image2.gif "debugger file explorer scrolling") ## Full commit history To find a complete list of changes since the previous release, check out [the diff on GitHub](https://github.com/flutter/devtools/compare/v2.10.0...v2.11.2).
website/src/tools/devtools/release-notes/release-notes-2.11.2-src.md/0
{ "file_path": "website/src/tools/devtools/release-notes/release-notes-2.11.2-src.md", "repo_id": "website", "token_count": 421 }
1,449
# DevTools 2.18.0 release notes The 2.18.0 release of the Dart and Flutter DevTools includes the following changes among other general improvements. To learn more about DevTools, check out the [DevTools overview](https://docs.flutter.dev/tools/devtools/overview). ## Inspector updates - Auto scrolling behavior improved when snapping a widget into focus - [#4283](https://github.com/flutter/devtools/pull/4283) - Fix issue where widget inspector wouldn't load when connecting to a paused app - [#4527](https://github.com/flutter/devtools/pull/4527) - Improve widget inspector hover cards to show progress while waiting for data - [#4488](https://github.com/flutter/devtools/pull/4488) ## Performance updates - Fix issue where scrollbar would go out of sync with the frame content - [#4503](https://github.com/flutter/devtools/pull/4503) - Add offline support for raster stats - [#4491](https://github.com/flutter/devtools/pull/4491) - Add 'Rendering time' column to Raster Metrics tab - [#4474](https://github.com/flutter/devtools/pull/4474) ![render-time-column](/tools/devtools/release-notes/images-2.18.0/render-time-column.png "Rendering time column in the Raster Metrics tab") ## CPU profiler updates - Fix crash when an empty frame is filtered - [#4502](https://github.com/flutter/devtools/pull/4502) - Fix bugs in CPU profile trees - [#4413](https://github.com/flutter/devtools/pull/4413) - UI Cleanup - [#4404](https://github.com/flutter/devtools/pull/4404) ## Memory updates - Add Profile and Allocation Tracing sub-tabs - [#4523](https://github.com/flutter/devtools/pull/4523) ![profile](/tools/devtools/release-notes/images-2.18.0/profile.png "Profile in Memory tab") ![allocation-tracing](/tools/devtools/release-notes/images-2.18.0/allocation-tracing.png "Allocation Tracing in Memory tab") - Implement snapshot visualization - [#4473](https://github.com/flutter/devtools/pull/4473) ## Debugger updates - Fix bug for file opener and search - [#4525](https://github.com/flutter/devtools/pull/4525) - Fix the code view's scrollable area - [#4448](https://github.com/flutter/devtools/pull/4448) - Allow syntax highlighting on nested captures in parser - [#4427](https://github.com/flutter/devtools/pull/4427) ## Network profiler updates - When on the Network tab, network recordings now continue working after the app hot restarts - [#4438](https://github.com/flutter/devtools/pull/4438) ## Logging updates - Log messages from non-stdout sources are now shown - [#4487](https://github.com/flutter/devtools/pull/4487) ## Full commit history To find a complete list of changes since the previous release, check out [the diff on GitHub](https://github.com/flutter/devtools/compare/v2.17.0...v2.18.0).
website/src/tools/devtools/release-notes/release-notes-2.18.0-src.md/0
{ "file_path": "website/src/tools/devtools/release-notes/release-notes-2.18.0-src.md", "repo_id": "website", "token_count": 893 }
1,450
# DevTools 2.26.1 release notes The 2.26.1 release of the Dart and Flutter DevTools includes the following changes among other general improvements. To learn more about DevTools, check out the [DevTools overview](https://docs.flutter.dev/tools/devtools/overview). ## General updates - Added a new "Home" screen in DevTools that either shows the "Connect" dialog or a summary of your connected app, depending on the connection status in DevTools. Keep an eye on this screen for cool new features in the future. This change also enables support for static tooling (tools that don't require a connected app) in DevTools - [#6010](https://github.com/flutter/devtools/pull/6010) ![home screen](/tools/devtools/release-notes/images-2.26.1/home_screen.png "DevTools home screen") - Fixed overlay notifications so that they cover the area that their background blocks - [#5975](https://github.com/flutter/devtools/pull/5975) ## Memory updates - Added a context menu to rename or delete a heap snapshot from the list - [#5997](https://github.com/flutter/devtools/pull/5997) - Warn users when HTTP logging may be affecting their app's memory consumption - [#5998](https://github.com/flutter/devtools/pull/5998) ## Debugger updates - Improvements to text selection and copy behavior in the code view, console, and variables windows - [#6020](https://github.com/flutter/devtools/pull/6020) ## Network profiler updates - Added a selector to customize the display type of text and json responses (thanks to @hhacker1999!) - [#5816](https://github.com/flutter/devtools/pull/5816) ## Full commit history To find a complete list of changes since the previous release, check out [the diff on GitHub](https://github.com/flutter/devtools/compare/v2.25.0...v2.26.1).
website/src/tools/devtools/release-notes/release-notes-2.26.1-src.md/0
{ "file_path": "website/src/tools/devtools/release-notes/release-notes-2.26.1-src.md", "repo_id": "website", "token_count": 522 }
1,451
# DevTools 2.30.0 release notes The 2.30.0 release of the Dart and Flutter DevTools includes the following changes among other general improvements. To learn more about DevTools, check out the [DevTools overview](https://docs.flutter.dev/tools/devtools/overview). ## Performance updates * Add an indicator of the rendering engine to the Flutter Frames chart. - [#6771](https://github.com/flutter/devtools/pull/6771) ![Flutter rendering engine text](/tools/devtools/release-notes/images-2.30.0/flutter_frames_engine_text.png "Text describing the current flutter rendering engine") * Improve messaging when we do not have analysis data available for a Flutter frame. - [#6768](https://github.com/flutter/devtools/pull/6768) ## VS Code Sidebar updates * The Flutter Sidebar provided to VS Code now has the ability to enable new platforms if a device is available for a platform that is not enabled for the current project. This also requires a corresponding Dart extension for VS Code update to appear. - [#6688](https://github.com/flutter/devtools/pull/6688) * The DevTools menu in the sidebar now has an entry "Open in Browser" that opens DevTools in an external browser window even when VS Code settings are set to usually use embedded DevTools. - [#6736](https://github.com/flutter/devtools/pull/6736) ## Full commit history To find a complete list of changes in this release, check out the [DevTools git log](https://github.com/flutter/devtools/tree/v2.30.0).
website/src/tools/devtools/release-notes/release-notes-2.30.0-src.md/0
{ "file_path": "website/src/tools/devtools/release-notes/release-notes-2.30.0-src.md", "repo_id": "website", "token_count": 418 }
1,452
--- permalink: /f/devtools-releases.json layout: none --- {%- assign releases = site.data.devtools_releases.releases -%} {%- assign latest = releases | first -%} { "latest": "{{latest}}", "releases": { {%- for release in releases %} "{{release}}": "/tools/devtools/release-notes/release-notes-{{release}}-src.md"{%- unless forloop.last -%},{%- endunless -%} {%- endfor %} } }
website/src/tools/devtools/release-notes/releases.liquid/0
{ "file_path": "website/src/tools/devtools/release-notes/releases.liquid", "repo_id": "website", "token_count": 150 }
1,453
--- title: Animations API overview short-title: API overview description: An overview of animation concepts. --- The animation system in Flutter is based on typed [`Animation`][] objects. Widgets can either incorporate these animations in their build functions directly by reading their current value and listening to their state changes or they can use the animations as the basis of more elaborate animations that they pass along to other widgets. ## Animation The primary building block of the animation system is the [`Animation`][] class. An animation represents a value of a specific type that can change over the lifetime of the animation. Most widgets that perform an animation receive an `Animation` object as a parameter, from which they read the current value of the animation and to which they listen for changes to that value. ### `addListener` Whenever the animation's value changes, the animation notifies all the listeners added with [`addListener`][]. Typically, a [`State`][] object that listens to an animation calls [`setState`][] on itself in its listener callback to notify the widget system that it needs to rebuild with the new value of the animation. This pattern is so common that there are two widgets that help widgets rebuild when animations change value: [`AnimatedWidget`][] and [`AnimatedBuilder`][]. The first, `AnimatedWidget`, is most useful for stateless animated widgets. To use `AnimatedWidget`, simply subclass it and implement the [`build`][] function. The second, `AnimatedBuilder`, is useful for more complex widgets that wish to include an animation as part of a larger build function. To use `AnimatedBuilder`, simply construct the widget and pass it a `builder` function. ### `addStatusListener` Animations also provide an [`AnimationStatus`][], which indicates how the animation will evolve over time. Whenever the animation's status changes, the animation notifies all the listeners added with [`addStatusListener`][]. Typically, animations start out in the `dismissed` status, which means they're at the beginning of their range. For example, animations that progress from 0.0 to 1.0 will be `dismissed` when their value is 0.0. An animation might then run `forward` (from 0.0 to 1.0) or perhaps in `reverse` (from 1.0 to 0.0). Eventually, if the animation reaches the end of its range (1.0), the animation reaches the `completed` status. ## Animation&shy;Controller To create an animation, first create an [`AnimationController`][]. As well as being an animation itself, an `AnimationController` lets you control the animation. For example, you can tell the controller to play the animation [`forward`][] or [`stop`][] the animation. You can also [`fling`][] animations, which uses a physical simulation, such as a spring, to drive the animation. Once you've created an animation controller, you can start building other animations based on it. For example, you can create a [`ReverseAnimation`][] that mirrors the original animation but runs in the opposite direction (from 1.0 to 0.0). Similarly, you can create a [`CurvedAnimation`][] whose value is adjusted by a [`Curve`][]. ## Tweens To animate beyond the 0.0 to 1.0 interval, you can use a [`Tween<T>`][], which interpolates between its [`begin`][] and [`end`][] values. Many types have specific `Tween` subclasses that provide type-specific interpolation. For example, [`ColorTween`][] interpolates between colors and [`RectTween`][] interpolates between rects. You can define your own interpolations by creating your own subclass of `Tween` and overriding its [`lerp`][] function. By itself, a tween just defines how to interpolate between two values. To get a concrete value for the current frame of an animation, you also need an animation to determine the current state. There are two ways to combine a tween with an animation to get a concrete value: 1. You can [`evaluate`][] the tween at the current value of an animation. This approach is most useful for widgets that are already listening to the animation and hence rebuilding whenever the animation changes value. 2. You can [`animate`][] the tween based on the animation. Rather than returning a single value, the animate function returns a new `Animation` that incorporates the tween. This approach is most useful when you want to give the newly created animation to another widget, which can then read the current value that incorporates the tween as well as listen for changes to the value. ## Architecture Animations are actually built from a number of core building blocks. ### Scheduler The [`SchedulerBinding`][] is a singleton class that exposes the Flutter scheduling primitives. For this discussion, the key primitive is the frame callbacks. Each time a frame needs to be shown on the screen, Flutter's engine triggers a "begin frame" callback that the scheduler multiplexes to all the listeners registered using [`scheduleFrameCallback()`][]. All these callbacks are given the official time stamp of the frame, in the form of a `Duration` from some arbitrary epoch. Since all the callbacks have the same time, any animations triggered from these callbacks will appear to be exactly synchronised even if they take a few milliseconds to be executed. ### Tickers The [`Ticker`][] class hooks into the scheduler's [`scheduleFrameCallback()`][] mechanism to invoke a callback every tick. A `Ticker` can be started and stopped. When started, it returns a `Future` that will resolve when it is stopped. Each tick, the `Ticker` provides the callback with the duration since the first tick after it was started. Because tickers always give their elapsed time relative to the first tick after they were started; tickers are all synchronised. If you start three tickers at different times between two ticks, they will all nonetheless be synchronised with the same starting time, and will subsequently tick in lockstep. Like people at a bus-stop, all the tickers wait for a regularly occurring event (the tick) to begin moving (counting time). ### Simulations The [`Simulation`][] abstract class maps a relative time value (an elapsed time) to a double value, and has a notion of completion. In principle simulations are stateless but in practice some simulations (for example, [`BouncingScrollSimulation`][] and [`ClampingScrollSimulation`][]) change state irreversibly when queried. There are [various concrete implementations][] of the `Simulation` class for different effects. ### Animatables The [`Animatable`][] abstract class maps a double to a value of a particular type. `Animatable` classes are stateless and immutable. #### Tweens The [`Tween<T>`][] abstract class maps a double value nominally in the range 0.0-1.0 to a typed value (for example, a `Color`, or another double). It is an `Animatable`. It has a notion of an output type (`T`), a `begin` value and an `end` value of that type, and a way to interpolate (`lerp`) between the begin and end values for a given input value (the double nominally in the range 0.0-1.0). `Tween` classes are stateless and immutable. #### Composing animatables Passing an `Animatable<double>` (the parent) to an `Animatable`'s `chain()` method creates a new `Animatable` subclass that applies the parent's mapping then the child's mapping. ### Curves The [`Curve`][] abstract class maps doubles nominally in the range 0.0-1.0 to doubles nominally in the range 0.0-1.0. `Curve` classes are stateless and immutable. ### Animations The [`Animation`][] abstract class provides a value of a given type, a concept of animation direction and animation status, and a listener interface to register callbacks that get invoked when the value or status change. Some subclasses of `Animation` have values that never change ([`kAlwaysCompleteAnimation`][], [`kAlwaysDismissedAnimation`][], [`AlwaysStoppedAnimation`][]); registering callbacks on these has no effect as the callbacks are never called. The `Animation<double>` variant is special because it can be used to represent a double nominally in the range 0.0-1.0, which is the input expected by `Curve` and `Tween` classes, as well as some further subclasses of `Animation`. Some `Animation` subclasses are stateless, merely forwarding listeners to their parents. Some are very stateful. #### Composable animations Most `Animation` subclasses take an explicit "parent" `Animation<double>`. They are driven by that parent. The `CurvedAnimation` subclass takes an `Animation<double>` class (the parent) and a couple of `Curve` classes (the forward and reverse curves) as input, and uses the value of the parent as input to the curves to determine its output. `CurvedAnimation` is immutable and stateless. The `ReverseAnimation` subclass takes an `Animation<double>` class as its parent and reverses all the values of the animation. It assumes the parent is using a value nominally in the range 0.0-1.0 and returns a value in the range 1.0-0.0. The status and direction of the parent animation are also reversed. `ReverseAnimation` is immutable and stateless. The `ProxyAnimation` subclass takes an `Animation<double>` class as its parent and merely forwards the current state of that parent. However, the parent is mutable. The `TrainHoppingAnimation` subclass takes two parents, and switches between them when their values cross. #### Animation controllers The [`AnimationController`][] is a stateful `Animation<double>` that uses a `Ticker` to give itself life. It can be started and stopped. At each tick, it takes the time elapsed since it was started and passes it to a `Simulation` to obtain a value. That is then the value it reports. If the `Simulation` reports that at that time it has ended, then the controller stops itself. The animation controller can be given a lower and upper bound to animate between, and a duration. In the simple case (using `forward()` or `reverse()`), the animation controller simply does a linear interpolation from the lower bound to the upper bound (or vice versa, for the reverse direction) over the given duration. When using `repeat()`, the animation controller uses a linear interpolation between the given bounds over the given duration, but does not stop. When using `animateTo()`, the animation controller does a linear interpolation over the given duration from the current value to the given target. If no duration is given to the method, the default duration of the controller and the range described by the controller's lower bound and upper bound is used to determine the velocity of the animation. When using `fling()`, a `Force` is used to create a specific simulation which is then used to drive the controller. When using `animateWith()`, the given simulation is used to drive the controller. These methods all return the future that the `Ticker` provides and which will resolve when the controller next stops or changes simulation. #### Attaching animatables to animations Passing an `Animation<double>` (the new parent) to an `Animatable`'s `animate()` method creates a new `Animation` subclass that acts like the `Animatable` but is driven from the given parent. [`addListener`]: {{site.api}}/flutter/animation/Animation/addListener.html [`addStatusListener`]: {{site.api}}/flutter/animation/Animation/addStatusListener.html [`AlwaysStoppedAnimation`]: {{site.api}}/flutter/animation/AlwaysStoppedAnimation-class.html [`Animatable`]: {{site.api}}/flutter/animation/Animatable-class.html [`animate`]: {{site.api}}/flutter/animation/Animatable/animate.html [`AnimatedBuilder`]: {{site.api}}/flutter/widgets/AnimatedBuilder-class.html [`AnimationController`]: {{site.api}}/flutter/animation/AnimationController-class.html [`AnimatedWidget`]: {{site.api}}/flutter/widgets/AnimatedWidget-class.html [`Animation`]: {{site.api}}/flutter/animation/Animation-class.html [`AnimationStatus`]: {{site.api}}/flutter/animation/AnimationStatus.html [`begin`]: {{site.api}}/flutter/animation/Tween/begin.html [`BouncingScrollSimulation`]: {{site.api}}/flutter/widgets/BouncingScrollSimulation-class.html [`build`]: {{site.api}}/flutter/widgets/AnimatedWidget/build.html [`ClampingScrollSimulation`]: {{site.api}}/flutter/widgets/ClampingScrollSimulation-class.html [`ColorTween`]: {{site.api}}/flutter/animation/ColorTween-class.html [`Curve`]: {{site.api}}/flutter/animation/Curves-class.html [`CurvedAnimation`]: {{site.api}}/flutter/animation/CurvedAnimation-class.html [`end`]: {{site.api}}/flutter/animation/Tween/end.html [`evaluate`]: {{site.api}}/flutter/animation/Animatable/evaluate.html [`fling`]: {{site.api}}/flutter/animation/AnimationController/fling.html [`forward`]: {{site.api}}/flutter/animation/AnimationController/forward.html [`kAlwaysCompleteAnimation`]: {{site.api}}/flutter/animation/kAlwaysCompleteAnimation-constant.html [`kAlwaysDismissedAnimation`]: {{site.api}}/flutter/animation/kAlwaysDismissedAnimation-constant.html [`lerp`]: {{site.api}}/flutter/animation/Tween/lerp.html [`RectTween`]: {{site.api}}/flutter/animation/RectTween-class.html [`ReverseAnimation`]: {{site.api}}/flutter/animation/ReverseAnimation-class.html [`scheduleFrameCallback()`]: {{site.api}}/flutter/scheduler/SchedulerBinding/scheduleFrameCallback.html [`SchedulerBinding`]: {{site.api}}/flutter/scheduler/SchedulerBinding-mixin.html [`setState`]: {{site.api}}/flutter/widgets/State/setState.html [`Simulation`]: {{site.api}}/flutter/physics/Simulation-class.html [`State`]: {{site.api}}/flutter/widgets/State-class.html [`stop`]: {{site.api}}/flutter/animation/AnimationController/stop.html [`Ticker`]: {{site.api}}/flutter/scheduler/Ticker-class.html [`Tween<T>`]: {{site.api}}/flutter/animation/Tween-class.html [various concrete implementations]: {{site.api}}/flutter/physics/physics-library.html
website/src/ui/animations/overview.md/0
{ "file_path": "website/src/ui/animations/overview.md", "repo_id": "website", "token_count": 3815 }
1,454
--- title: Add interactivity to your Flutter app description: How to implement a stateful widget that responds to taps. short-title: Interactivity diff2html: true --- {% capture examples -%} {{site.repo.this}}/tree/{{site.branch}}/examples {%- endcapture -%} {{site.alert.secondary}} <h4>What you'll learn</h4> * How to respond to taps. * How to create a custom widget. * The difference between stateless and stateful widgets. {{site.alert.end}} How do you modify your app to make it react to user input? In this tutorial, you'll add interactivity to an app that contains only non-interactive widgets. Specifically, you'll modify an icon to make it tappable by creating a custom stateful widget that manages two stateless widgets. The [building layouts tutorial][] showed you how to create the layout for the following screenshot. {% include docs/app-figure.md img-class="site-mobile-screenshot border" image="ui/layout/lakes.jpg" caption="The layout tutorial app" %} When the app first launches, the star is solid red, indicating that this lake has previously been favorited. The number next to the star indicates that 41 people have favorited this lake. After completing this tutorial, tapping the star removes its favorited status, replacing the solid star with an outline and decreasing the count. Tapping again favorites the lake, drawing a solid star and increasing the count. <img src='/assets/images/docs/ui/favorited-not-favorited.png' class="mw-100" alt="The custom widget you'll create" width="200px"> {:.text-center} To accomplish this, you'll create a single custom widget that includes both the star and the count, which are themselves widgets. Tapping the star changes state for both widgets, so the same widget should manage both. You can get right to touching the code in [Step 2: Subclass StatefulWidget](#step-2). If you want to try different ways of managing state, skip to [Managing state][]. ## Stateful and stateless widgets A widget is either stateful or stateless. If a widget can change&mdash;when a user interacts with it, for example&mdash;it's stateful. A _stateless_ widget never changes. [`Icon`][], [`IconButton`][], and [`Text`][] are examples of stateless widgets. Stateless widgets subclass [`StatelessWidget`][]. A _stateful_ widget is dynamic: for example, it can change its appearance in response to events triggered by user interactions or when it receives data. [`Checkbox`][], [`Radio`][], [`Slider`][], [`InkWell`][], [`Form`][], and [`TextField`][] are examples of stateful widgets. Stateful widgets subclass [`StatefulWidget`][]. A widget's state is stored in a [`State`][] object, separating the widget's state from its appearance. The state consists of values that can change, like a slider's current value or whether a checkbox is checked. When the widget's state changes, the state object calls `setState()`, telling the framework to redraw the widget. ## Creating a stateful widget {{site.alert.secondary}} <h4>What's the point?</h4> * A stateful widget is implemented by two classes: a subclass of `StatefulWidget` and a subclass of `State`. * The state class contains the widget's mutable state and the widget's `build()` method. * When the widget's state changes, the state object calls `setState()`, telling the framework to redraw the widget. {{site.alert.end}} In this section, you'll create a custom stateful widget. You'll replace two stateless widgets&mdash;the solid red star and the numeric count next to it&mdash;with a single custom stateful widget that manages a row with two children widgets: an `IconButton` and `Text`. Implementing a custom stateful widget requires creating two classes: * A subclass of `StatefulWidget` that defines the widget. * A subclass of `State` that contains the state for that widget and defines the widget's `build()` method. This section shows you how to build a stateful widget, called `FavoriteWidget`, for the lakes app. After setting up, your first step is choosing how state is managed for `FavoriteWidget`. ### Step 0: Get ready If you've already built the app in the [building layouts tutorial][], skip to the next section. 1. Make sure you've [set up][] your environment. 1. [Create a new Flutter app][new-flutter-app]. 1. Replace the `lib/main.dart` file with [`main.dart`][]. 1. Replace the `pubspec.yaml` file with [`pubspec.yaml`][]. 1. Create an `images` directory in your project, and add [`lake.jpg`][]. Once you have a connected and enabled device, or you've launched the [iOS simulator][] (part of the Flutter install) or the [Android emulator][] (part of the Android Studio install), you are good to go! <a id="step-1"></a> ### Step 1: Decide which object manages the widget's state A widget's state can be managed in several ways, but in our example the widget itself, `FavoriteWidget`, will manage its own state. In this example, toggling the star is an isolated action that doesn't affect the parent widget or the rest of the UI, so the widget can handle its state internally. Learn more about the separation of widget and state, and how state might be managed, in [Managing state][]. <a id="step-2"></a> ### Step 2: Subclass StatefulWidget The `FavoriteWidget` class manages its own state, so it overrides `createState()` to create a `State` object. The framework calls `createState()` when it wants to build the widget. In this example, `createState()` returns an instance of `_FavoriteWidgetState`, which you'll implement in the next step. <?code-excerpt path-base="layout/lakes/interactive"?> <?code-excerpt "lib/main.dart (FavoriteWidget)" title?> ```dart class FavoriteWidget extends StatefulWidget { const FavoriteWidget({super.key}); @override State<FavoriteWidget> createState() => _FavoriteWidgetState(); } ``` {{site.alert.note}} Members or classes that start with an underscore (`_`) are private. For more information, see [Libraries and imports][], a section in the [Dart language documentation][]. {{site.alert.end}} <a id="step-3"></a> ### Step 3: Subclass State The `_FavoriteWidgetState` class stores the mutable data that can change over the lifetime of the widget. When the app first launches, the UI displays a solid red star, indicating that the lake has "favorite" status, along with 41 likes. These values are stored in the `_isFavorited` and `_favoriteCount` fields: <?code-excerpt "lib/main.dart (_FavoriteWidgetState fields)" replace="/(bool|int) .*/[!$&!]/g" title?> ```dart class _FavoriteWidgetState extends State<FavoriteWidget> { [!bool _isFavorited = true;!] [!int _favoriteCount = 41;!] // ··· } ``` The class also defines a `build()` method, which creates a row containing a red `IconButton`, and `Text`. You use [`IconButton`][] (instead of `Icon`) because it has an `onPressed` property that defines the callback function (`_toggleFavorite`) for handling a tap. You'll define the callback function next. <?code-excerpt "lib/main.dart (_FavoriteWidgetState build)" replace="/build|icon.*|onPressed.*|child: Text.*/[!$&!]/g" title?> ```dart class _FavoriteWidgetState extends State<FavoriteWidget> { // ··· @override Widget [!build!](BuildContext context) { return Row( mainAxisSize: MainAxisSize.min, children: [ Container( padding: const EdgeInsets.all(0), child: IconButton( padding: const EdgeInsets.all(0), alignment: Alignment.centerRight, [!icon: (_isFavorited!] ? const Icon(Icons.star) : const Icon(Icons.star_border)), color: Colors.red[500], [!onPressed: _toggleFavorite,!] ), ), SizedBox( width: 18, child: SizedBox( [!child: Text('$_favoriteCount'),!] ), ), ], ); } } ``` {{site.alert.tip}} Placing the `Text` in a [`SizedBox`][] and setting its width prevents a discernible "jump" when the text changes between the values of 40 and 41 &mdash; a jump would otherwise occur because those values have different widths. {{site.alert.end}} The `_toggleFavorite()` method, which is called when the `IconButton` is pressed, calls `setState()`. Calling `setState()` is critical, because this tells the framework that the widget's state has changed and that the widget should be redrawn. The function argument to `setState()` toggles the UI between these two states: * A `star` icon and the number 41 * A `star_border` icon and the number 40 <?code-excerpt "lib/main.dart (_toggleFavorite)"?> ```dart void _toggleFavorite() { setState(() { if (_isFavorited) { _favoriteCount -= 1; _isFavorited = false; } else { _favoriteCount += 1; _isFavorited = true; } }); } ``` <a id="step-4"></a> ### Step 4: Plug the stateful widget into the widget tree Add your custom stateful widget to the widget tree in the app's `build()` method. First, locate the code that creates the `Icon` and `Text`, and delete it. In the same location, create the stateful widget: <?code-excerpt path-base=""?> <?code-excerpt "layout/lakes/{step6,interactive}/lib/main.dart" remove="*3*" from="class MyApp" to="/^[ ]+\);$/"?> ```diff --- layout/lakes/step6/lib/main.dart +++ layout/lakes/interactive/lib/main.dart @@ -83,11 +83,7 @@ ], ), ), - Icon( - Icons.star, - color: Colors.red[500], - ), - const Text('41'), + const FavoriteWidget(), ], ), ); ``` That's it! When you hot reload the app, the star icon should now respond to taps. ### Problems? If you can't get your code to run, look in your IDE for possible errors. [Debugging Flutter apps][] might help. If you still can't find the problem, check your code against the interactive lakes example on GitHub. {% comment %} TODO: replace the following links with tabbed code panes. {% endcomment -%} * [`lib/main.dart`]({{site.repo.this}}/tree/{{site.branch}}/examples/layout/lakes/interactive/lib/main.dart) * [`pubspec.yaml`]({{site.repo.this}}/tree/{{site.branch}}/examples/layout/lakes/interactive/pubspec.yaml) * [`lakes.jpg`]({{site.repo.this}}/tree/{{site.branch}}/examples/layout/lakes/interactive/images/lake.jpg) If you still have questions, refer to any one of the developer [community][] channels. --- The rest of this page covers several ways a widget's state can be managed, and lists other available interactive widgets. ## Managing state {{site.alert.secondary}} <h4>What's the point?</h4> * There are different approaches for managing state. * You, as the widget designer, choose which approach to use. * If in doubt, start by managing state in the parent widget. {{site.alert.end}} Who manages the stateful widget's state? The widget itself? The parent widget? Both? Another object? The answer is... it depends. There are several valid ways to make your widget interactive. You, as the widget designer, make the decision based on how you expect your widget to be used. Here are the most common ways to manage state: * [The widget manages its own state](#self-managed) * [The parent manages the widget's state](#parent-managed) * [A mix-and-match approach](#mix-and-match) How do you decide which approach to use? The following principles should help you decide: * If the state in question is user data, for example the checked or unchecked mode of a checkbox, or the position of a slider, then the state is best managed by the parent widget. * If the state in question is aesthetic, for example an animation, then the state is best managed by the widget itself. If in doubt, start by managing state in the parent widget. We'll give examples of the different ways of managing state by creating three simple examples: TapboxA, TapboxB, and TapboxC. The examples all work similarly&mdash;each creates a container that, when tapped, toggles between a green or grey box. The `_active` boolean determines the color: green for active or grey for inactive. <div class="row mb-4"> <div class="col-12 text-center"> <img src='/assets/images/docs/ui/tapbox-active-state.png' class="border mt-1 mb-1 mw-100" width="150px" alt="Active state"> <img src='/assets/images/docs/ui/tapbox-inactive-state.png' class="border mt-1 mb-1 mw-100" width="150px" alt="Inactive state"> </div> </div> These examples use [`GestureDetector`][] to capture activity on the `Container`. <a id="self-managed"></a> ### The widget manages its own state Sometimes it makes the most sense for the widget to manage its state internally. For example, [`ListView`][] automatically scrolls when its content exceeds the render box. Most developers using `ListView` don't want to manage `ListView`'s scrolling behavior, so `ListView` itself manages its scroll offset. The `_TapboxAState` class: * Manages state for `TapboxA`. * Defines the `_active` boolean which determines the box's current color. * Defines the `_handleTap()` function, which updates `_active` when the box is tapped and calls the `setState()` function to update the UI. * Implements all interactive behavior for the widget. <?code-excerpt path-base="development/ui/interactive/"?> <?code-excerpt "lib/self_managed.dart"?> ```dart import 'package:flutter/material.dart'; // TapboxA manages its own state. //------------------------- TapboxA ---------------------------------- class TapboxA extends StatefulWidget { const TapboxA({super.key}); @override State<TapboxA> createState() => _TapboxAState(); } class _TapboxAState extends State<TapboxA> { bool _active = false; void _handleTap() { setState(() { _active = !_active; }); } @override Widget build(BuildContext context) { return GestureDetector( onTap: _handleTap, child: Container( width: 200, height: 200, decoration: BoxDecoration( color: _active ? Colors.lightGreen[700] : Colors.grey[600], ), child: Center( child: Text( _active ? 'Active' : 'Inactive', style: const TextStyle(fontSize: 32, color: Colors.white), ), ), ), ); } } //------------------------- MyApp ---------------------------------- class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', home: Scaffold( appBar: AppBar( title: const Text('Flutter Demo'), ), body: const Center( child: TapboxA(), ), ), ); } } ``` <hr> <a id="parent-managed"></a> ### The parent widget manages the widget's state Often it makes the most sense for the parent widget to manage the state and tell its child widget when to update. For example, [`IconButton`][] allows you to treat an icon as a tappable button. `IconButton` is a stateless widget because we decided that the parent widget needs to know whether the button has been tapped, so it can take appropriate action. In the following example, TapboxB exports its state to its parent through a callback. Because TapboxB doesn't manage any state, it subclasses StatelessWidget. The ParentWidgetState class: * Manages the `_active` state for TapboxB. * Implements `_handleTapboxChanged()`, the method called when the box is tapped. * When the state changes, calls `setState()` to update the UI. The TapboxB class: * Extends StatelessWidget because all state is handled by its parent. * When a tap is detected, it notifies the parent. <?code-excerpt "lib/parent_managed.dart"?> ```dart import 'package:flutter/material.dart'; // ParentWidget manages the state for TapboxB. //------------------------ ParentWidget -------------------------------- class ParentWidget extends StatefulWidget { const ParentWidget({super.key}); @override State<ParentWidget> createState() => _ParentWidgetState(); } class _ParentWidgetState extends State<ParentWidget> { bool _active = false; void _handleTapboxChanged(bool newValue) { setState(() { _active = newValue; }); } @override Widget build(BuildContext context) { return SizedBox( child: TapboxB( active: _active, onChanged: _handleTapboxChanged, ), ); } } //------------------------- TapboxB ---------------------------------- class TapboxB extends StatelessWidget { const TapboxB({ super.key, this.active = false, required this.onChanged, }); final bool active; final ValueChanged<bool> onChanged; void _handleTap() { onChanged(!active); } @override Widget build(BuildContext context) { return GestureDetector( onTap: _handleTap, child: Container( width: 200, height: 200, decoration: BoxDecoration( color: active ? Colors.lightGreen[700] : Colors.grey[600], ), child: Center( child: Text( active ? 'Active' : 'Inactive', style: const TextStyle(fontSize: 32, color: Colors.white), ), ), ), ); } } ``` <hr> <a id="mix-and-match"></a> ### A mix-and-match approach For some widgets, a mix-and-match approach makes the most sense. In this scenario, the stateful widget manages some of the state, and the parent widget manages other aspects of the state. In the `TapboxC` example, on tap down, a dark green border appears around the box. On tap up, the border disappears and the box's color changes. `TapboxC` exports its `_active` state to its parent but manages its `_highlight` state internally. This example has two `State` objects, `_ParentWidgetState` and `_TapboxCState`. The `_ParentWidgetState` object: * Manages the `_active` state. * Implements `_handleTapboxChanged()`, the method called when the box is tapped. * Calls `setState()` to update the UI when a tap occurs and the `_active` state changes. The `_TapboxCState` object: * Manages the `_highlight` state. * The `GestureDetector` listens to all tap events. As the user taps down, it adds the highlight (implemented as a dark green border). As the user releases the tap, it removes the highlight. * Calls `setState()` to update the UI on tap down, tap up, or tap cancel, and the `_highlight` state changes. * On a tap event, passes that state change to the parent widget to take appropriate action using the [`widget`][] property. <?code-excerpt "lib/mixed.dart"?> ```dart import 'package:flutter/material.dart'; //---------------------------- ParentWidget ---------------------------- class ParentWidget extends StatefulWidget { const ParentWidget({super.key}); @override State<ParentWidget> createState() => _ParentWidgetState(); } class _ParentWidgetState extends State<ParentWidget> { bool _active = false; void _handleTapboxChanged(bool newValue) { setState(() { _active = newValue; }); } @override Widget build(BuildContext context) { return SizedBox( child: TapboxC( active: _active, onChanged: _handleTapboxChanged, ), ); } } //----------------------------- TapboxC ------------------------------ class TapboxC extends StatefulWidget { const TapboxC({ super.key, this.active = false, required this.onChanged, }); final bool active; final ValueChanged<bool> onChanged; @override State<TapboxC> createState() => _TapboxCState(); } class _TapboxCState extends State<TapboxC> { bool _highlight = false; void _handleTapDown(TapDownDetails details) { setState(() { _highlight = true; }); } void _handleTapUp(TapUpDetails details) { setState(() { _highlight = false; }); } void _handleTapCancel() { setState(() { _highlight = false; }); } void _handleTap() { widget.onChanged(!widget.active); } @override Widget build(BuildContext context) { // This example adds a green border on tap down. // On tap up, the square changes to the opposite state. return GestureDetector( onTapDown: _handleTapDown, // Handle the tap events in the order that onTapUp: _handleTapUp, // they occur: down, up, tap, cancel onTap: _handleTap, onTapCancel: _handleTapCancel, child: Container( width: 200, height: 200, decoration: BoxDecoration( color: widget.active ? Colors.lightGreen[700] : Colors.grey[600], border: _highlight ? Border.all( color: Colors.teal[700]!, width: 10, ) : null, ), child: Center( child: Text(widget.active ? 'Active' : 'Inactive', style: const TextStyle(fontSize: 32, color: Colors.white)), ), ), ); } } ``` An alternate implementation might have exported the highlight state to the parent while keeping the active state internal, but if you asked someone to use that tap box, they'd probably complain that it doesn't make much sense. The developer cares whether the box is active. The developer probably doesn't care how the highlighting is managed, and prefers that the tap box handles those details. <hr> ## Other interactive widgets Flutter offers a variety of buttons and similar interactive widgets. Most of these widgets implement the [Material Design guidelines][], which define a set of components with an opinionated UI. If you prefer, you can use [`GestureDetector`][] to build interactivity into any custom widget. You can find examples of `GestureDetector` in [Managing state][]. Learn more about the `GestureDetector` in [Handle taps][], a recipe in the [Flutter cookbook][]. {{site.alert.tip}} Flutter also provides a set of iOS-style widgets called [`Cupertino`][]. {{site.alert.end}} When you need interactivity, it's easiest to use one of the prefabricated widgets. Here's a partial list: ### Standard widgets * [`Form`][] * [`FormField`][] ### Material Components * [`Checkbox`][] * [`DropdownButton`][] * [`TextButton`][] * [`FloatingActionButton`][] * [`IconButton`][] * [`Radio`][] * [`ElevatedButton`][] * [`Slider`][] * [`Switch`][] * [`TextField`][] ## Resources The following resources might help when adding interactivity to your app. [Gestures][], a section in the [Flutter cookbook][]. [Handling gestures][] : How to create a button and make it respond to input. [Gestures in Flutter][] : A description of Flutter's gesture mechanism. [Flutter API documentation][] : Reference documentation for all of the Flutter libraries. Wonderous app [running app][wonderous-app], [repo][wonderous-repo] : Flutter showcase app with a custom design and engaging interactions. [Flutter's Layered Design][] (video) : This video includes information about state and stateless widgets. Presented by Google engineer, Ian Hickson. [Android emulator]: /get-started/install/windows/mobile?tab=virtual#configure-your-target-android-device [`Checkbox`]: {{site.api}}/flutter/material/Checkbox-class.html [`Cupertino`]: {{site.api}}/flutter/cupertino/cupertino-library.html [Dart language documentation]: {{site.dart-site}}/language [Debugging Flutter apps]: /testing/debugging [`DropdownButton`]: {{site.api}}/flutter/material/DropdownButton-class.html [`TextButton`]: {{site.api}}/flutter/material/TextButton-class.html [`FloatingActionButton`]: {{site.api}}/flutter/material/FloatingActionButton-class.html [Flutter API documentation]: {{site.api}} [Flutter cookbook]: /cookbook [Flutter's Layered Design]: {{site.yt.watch}}?v=dkyY9WCGMi0 [`FormField`]: {{site.api}}/flutter/widgets/FormField-class.html [`Form`]: {{site.api}}/flutter/widgets/Form-class.html [`GestureDetector`]: {{site.api}}/flutter/widgets/GestureDetector-class.html [Gestures]: /cookbook/gestures [Gestures in Flutter]: /ui/interactivity/gestures [Handling gestures]: /ui#handling-gestures [new-flutter-app]: /get-started/test-drive [`IconButton`]: {{site.api}}/flutter/material/IconButton-class.html [`Icon`]: {{site.api}}/flutter/widgets/Icon-class.html [`InkWell`]: {{site.api}}/flutter/material/InkWell-class.html [iOS simulator]: /get-started/install/macos/mobile-ios#configure-your-target-ios-device [building layouts tutorial]: /ui/layout/tutorial [community]: {{site.main-url}}/community [Handle taps]: /cookbook/gestures/handling-taps [`lake.jpg`]: {{examples}}/layout/lakes/step6/images/lake.jpg [Libraries and imports]: {{site.dart-site}}/language/libraries [`ListView`]: {{site.api}}/flutter/widgets/ListView-class.html [`main.dart`]: {{examples}}/layout/lakes/step6/lib/main.dart [Managing state]: #managing-state [Material Design guidelines]: {{site.material}}/styles [`pubspec.yaml`]: {{examples}}/layout/lakes/step6/pubspec.yaml [`Radio`]: {{site.api}}/flutter/material/Radio-class.html [`ElevatedButton`]: {{site.api}}/flutter/material/ElevatedButton-class.html [wonderous-app]: {{site.wonderous}}/web [wonderous-repo]: {{site.repo.wonderous}} [set up]: /get-started/install [`SizedBox`]: {{site.api}}/flutter/widgets/SizedBox-class.html [`Slider`]: {{site.api}}/flutter/material/Slider-class.html [`State`]: {{site.api}}/flutter/widgets/State-class.html [`StatefulWidget`]: {{site.api}}/flutter/widgets/StatefulWidget-class.html [`StatelessWidget`]: {{site.api}}/flutter/widgets/StatelessWidget-class.html [`Switch`]: {{site.api}}/flutter/material/Switch-class.html [`TextField`]: {{site.api}}/flutter/material/TextField-class.html [`Text`]: {{site.api}}/flutter/widgets/Text-class.html [`widget`]: {{site.api}}/flutter/widgets/State/widget.html
website/src/ui/interactivity/index.md/0
{ "file_path": "website/src/ui/interactivity/index.md", "repo_id": "website", "token_count": 8547 }
1,455
--- title: Assets, images, and icon widgets short-title: Assets description: A catalog of Flutter's asset widgets. --- {% include docs/catalogpage.html category="Assets, Images, and Icons" %}
website/src/ui/widgets/assets.md/0
{ "file_path": "website/src/ui/widgets/assets.md", "repo_id": "website", "token_count": 57 }
1,456
// Copyright 2024 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. import 'dart:io'; import 'package:args/command_runner.dart'; import 'package:flutter_site/flutter_site.dart'; import 'package:io/io.dart' as io; import 'package:path/path.dart' as path; void main(List<String> args) async { // Verify that we are running from the root of the website repository. if (!Directory(path.join('tool', 'flutter_site')).existsSync()) { throw Exception( 'Error: Wrong directory, run from root of the repository.', ); } final runner = FlutterSiteCommandRunner(); try { final result = await runner.run(args).whenComplete(io.sharedStdIn.terminate); exit(result is int ? result : 0); } on UsageException catch (e) { stderr.writeln(e); exit(64); } catch (e, stackTrace) { stderr.writeln(e); stderr.writeln(stackTrace); exit(1); } }
website/tool/flutter_site/bin/flutter_site.dart/0
{ "file_path": "website/tool/flutter_site/bin/flutter_site.dart", "repo_id": "website", "token_count": 350 }
1,457
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility in the flutter_test package. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:adaptive_app/main.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('Counter increments smoke test', (tester) async { // Build our app and trigger a frame. await tester.pumpWidget(const MyApp()); }); }
codelabs/adaptive_app/step_03/test/widget_test.dart/0
{ "file_path": "codelabs/adaptive_app/step_03/test/widget_test.dart", "repo_id": "codelabs", "token_count": 181 }
0
org.gradle.jvmargs=-Xmx4G android.useAndroidX=true android.enableJetifier=true
codelabs/adaptive_app/step_05/android/gradle.properties/0
{ "file_path": "codelabs/adaptive_app/step_05/android/gradle.properties", "repo_id": "codelabs", "token_count": 30 }
1
org.gradle.jvmargs=-Xmx4G android.useAndroidX=true android.enableJetifier=true
codelabs/adaptive_app/step_07/android/gradle.properties/0
{ "file_path": "codelabs/adaptive_app/step_07/android/gradle.properties", "repo_id": "codelabs", "token_count": 30 }
2
#include "ephemeral/Flutter-Generated.xcconfig"
codelabs/animated-responsive-layout/step_04/macos/Flutter/Flutter-Debug.xcconfig/0
{ "file_path": "codelabs/animated-responsive-layout/step_04/macos/Flutter/Flutter-Debug.xcconfig", "repo_id": "codelabs", "token_count": 19 }
3
#include "../../Flutter/Flutter-Debug.xcconfig" #include "Warnings.xcconfig"
codelabs/animated-responsive-layout/step_05/macos/Runner/Configs/Debug.xcconfig/0
{ "file_path": "codelabs/animated-responsive-layout/step_05/macos/Runner/Configs/Debug.xcconfig", "repo_id": "codelabs", "token_count": 32 }
4
#include "../../Flutter/Flutter-Release.xcconfig" #include "Warnings.xcconfig"
codelabs/animated-responsive-layout/step_06/macos/Runner/Configs/Release.xcconfig/0
{ "file_path": "codelabs/animated-responsive-layout/step_06/macos/Runner/Configs/Release.xcconfig", "repo_id": "codelabs", "token_count": 32 }
5
// Copyright 2022 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. import 'package:flutter/material.dart'; import '../animations.dart'; import '../destinations.dart'; import '../transitions/nav_rail_transition.dart'; import 'animated_floating_action_button.dart'; class DisappearingNavigationRail extends StatelessWidget { const DisappearingNavigationRail({ super.key, required this.railAnimation, required this.railFabAnimation, required this.backgroundColor, required this.selectedIndex, this.onDestinationSelected, }); final RailAnimation railAnimation; final RailFabAnimation railFabAnimation; final Color backgroundColor; final int selectedIndex; final ValueChanged<int>? onDestinationSelected; @override Widget build(BuildContext context) { return NavRailTransition( animation: railAnimation, backgroundColor: backgroundColor, child: NavigationRail( selectedIndex: selectedIndex, backgroundColor: backgroundColor, onDestinationSelected: onDestinationSelected, leading: Column( children: [ IconButton( onPressed: () {}, icon: const Icon(Icons.menu), ), const SizedBox(height: 8), AnimatedFloatingActionButton( animation: railFabAnimation, elevation: 0, onPressed: () {}, child: const Icon(Icons.add), ), ], ), groupAlignment: -0.85, destinations: destinations.map((d) { return NavigationRailDestination( icon: Icon(d.icon), label: Text(d.label), ); }).toList(), ), ); } }
codelabs/animated-responsive-layout/step_07/lib/widgets/disappearing_navigation_rail.dart/0
{ "file_path": "codelabs/animated-responsive-layout/step_07/lib/widgets/disappearing_navigation_rail.dart", "repo_id": "codelabs", "token_count": 734 }
6
#include "ephemeral/Flutter-Generated.xcconfig"
codelabs/animated-responsive-layout/step_07/macos/Flutter/Flutter-Release.xcconfig/0
{ "file_path": "codelabs/animated-responsive-layout/step_07/macos/Flutter/Flutter-Release.xcconfig", "repo_id": "codelabs", "token_count": 19 }
7
// Copyright 2022 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. import 'dart:ui'; import 'package:flutter/material.dart'; import '../animations.dart'; class ListDetailTransition extends StatefulWidget { const ListDetailTransition({ super.key, required this.animation, required this.one, required this.two, }); final Animation<double> animation; final Widget one; final Widget two; @override State<ListDetailTransition> createState() => _ListDetailTransitionState(); } class _ListDetailTransitionState extends State<ListDetailTransition> { Animation<double> widthAnimation = const AlwaysStoppedAnimation(0); late final Animation<double> sizeAnimation = SizeAnimation(parent: widget.animation); late final Animation<Offset> offsetAnimation = Tween<Offset>( begin: const Offset(1, 0), end: Offset.zero, ).animate(OffsetAnimation(parent: sizeAnimation)); double currentFlexFactor = 0; @override void didChangeDependencies() { super.didChangeDependencies(); // When the app's width is < 800, widgets one and two get 1/2 of // the available width, As the app gets wider, the allocation // gradually changes to 1/3 and 2/3 for widgets one and two. When // the window is wider than 1600, the allocation changes to 1/4 3/4. final double width = MediaQuery.of(context).size.width; double nextFlexFactor = switch (width) { >= 800 && < 1200 => lerpDouble(1000, 2000, (width - 800) / 400)!, >= 1200 && < 1600 => lerpDouble(2000, 3000, (width - 1200) / 400)!, >= 1600 => 3000, _ => 1000, }; // Continue along the current animation curve if the // destionation flex factor has not changed. if (nextFlexFactor == currentFlexFactor) { return; } if (currentFlexFactor == 0) { widthAnimation = Tween<double>(begin: 0, end: nextFlexFactor).animate(sizeAnimation); } else { final TweenSequence<double> sequence = TweenSequence([ if (sizeAnimation.value > 0) ...[ TweenSequenceItem( tween: Tween(begin: 0, end: widthAnimation.value), weight: sizeAnimation.value, ), ], if (sizeAnimation.value < 1) ...[ TweenSequenceItem( tween: Tween(begin: widthAnimation.value, end: nextFlexFactor), weight: 1 - sizeAnimation.value, ), ], ]); widthAnimation = sequence.animate(sizeAnimation); } currentFlexFactor = nextFlexFactor; } @override Widget build(BuildContext context) { return widthAnimation.value.toInt() == 0 ? widget.one : Row( children: [ Flexible( flex: 1000, child: widget.one, ), Flexible( flex: widthAnimation.value.toInt(), child: FractionalTranslation( translation: offsetAnimation.value, child: widget.two, ), ), ], ); } }
codelabs/animated-responsive-layout/step_08/lib/transitions/list_detail_transition.dart/0
{ "file_path": "codelabs/animated-responsive-layout/step_08/lib/transitions/list_detail_transition.dart", "repo_id": "codelabs", "token_count": 1263 }
8
include: ../../analysis_options.yaml
codelabs/brick_breaker/step_03/analysis_options.yaml/0
{ "file_path": "codelabs/brick_breaker/step_03/analysis_options.yaml", "repo_id": "codelabs", "token_count": 12 }
9
org.gradle.jvmargs=-Xmx4G android.useAndroidX=true android.enableJetifier=true
codelabs/brick_breaker/step_04/android/gradle.properties/0
{ "file_path": "codelabs/brick_breaker/step_04/android/gradle.properties", "repo_id": "codelabs", "token_count": 30 }
10
import 'package:flame/components.dart'; import 'package:flutter/material.dart'; class Ball extends CircleComponent { Ball({ required this.velocity, required super.position, required double radius, }) : super( radius: radius, anchor: Anchor.center, paint: Paint() ..color = const Color(0xff1e6091) ..style = PaintingStyle.fill); final Vector2 velocity; @override void update(double dt) { super.update(dt); position += velocity * dt; } }
codelabs/brick_breaker/step_05/lib/src/components/ball.dart/0
{ "file_path": "codelabs/brick_breaker/step_05/lib/src/components/ball.dart", "repo_id": "codelabs", "token_count": 219 }
11
#import "GeneratedPluginRegistrant.h"
codelabs/brick_breaker/step_06/ios/Runner/Runner-Bridging-Header.h/0
{ "file_path": "codelabs/brick_breaker/step_06/ios/Runner/Runner-Bridging-Header.h", "repo_id": "codelabs", "token_count": 13 }
12
org.gradle.jvmargs=-Xmx4G android.useAndroidX=true android.enableJetifier=true
codelabs/brick_breaker/step_08/android/gradle.properties/0
{ "file_path": "codelabs/brick_breaker/step_08/android/gradle.properties", "repo_id": "codelabs", "token_count": 30 }
13
import 'package:flame/game.dart'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import '../brick_breaker.dart'; import '../config.dart'; import 'overlay_screen.dart'; import 'score_card.dart'; class GameApp extends StatefulWidget { const GameApp({super.key}); @override State<GameApp> createState() => _GameAppState(); } class _GameAppState extends State<GameApp> { late final BrickBreaker game; @override void initState() { super.initState(); game = BrickBreaker(); } @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, theme: ThemeData( useMaterial3: true, textTheme: GoogleFonts.pressStart2pTextTheme().apply( bodyColor: const Color(0xff184e77), displayColor: const Color(0xff184e77), ), ), home: Scaffold( body: Container( decoration: const BoxDecoration( gradient: LinearGradient( begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [ Color(0xffa9d6e5), Color(0xfff2e8cf), ], ), ), child: SafeArea( child: Padding( padding: const EdgeInsets.all(16), child: Center( child: Column( children: [ ScoreCard(score: game.score), Expanded( child: FittedBox( child: SizedBox( width: gameWidth, height: gameHeight, child: GameWidget( game: game, overlayBuilderMap: { PlayState.welcome.name: (context, game) => const OverlayScreen( title: 'TAP TO PLAY', subtitle: 'Use arrow keys or swipe', ), PlayState.gameOver.name: (context, game) => const OverlayScreen( title: 'G A M E O V E R', subtitle: 'Tap to Play Again', ), PlayState.won.name: (context, game) => const OverlayScreen( title: 'Y O U W O N ! ! !', subtitle: 'Tap to Play Again', ), }, ), ), ), ), ], ), ), ), ), ), ), ); } }
codelabs/brick_breaker/step_10/lib/src/widgets/game_app.dart/0
{ "file_path": "codelabs/brick_breaker/step_10/lib/src/widgets/game_app.dart", "repo_id": "codelabs", "token_count": 1788 }
14
#include "../../Flutter/Flutter-Release.xcconfig" #include "Warnings.xcconfig"
codelabs/dart-patterns-and-records/step_03/macos/Runner/Configs/Release.xcconfig/0
{ "file_path": "codelabs/dart-patterns-and-records/step_03/macos/Runner/Configs/Release.xcconfig", "repo_id": "codelabs", "token_count": 32 }
15
org.gradle.jvmargs=-Xmx4G android.useAndroidX=true android.enableJetifier=true
codelabs/dart-patterns-and-records/step_06_a/android/gradle.properties/0
{ "file_path": "codelabs/dart-patterns-and-records/step_06_a/android/gradle.properties", "repo_id": "codelabs", "token_count": 30 }
16
#include "Generated.xcconfig"
codelabs/dart-patterns-and-records/step_07_b/ios/Flutter/Release.xcconfig/0
{ "file_path": "codelabs/dart-patterns-and-records/step_07_b/ios/Flutter/Release.xcconfig", "repo_id": "codelabs", "token_count": 12 }
17
#include "ephemeral/Flutter-Generated.xcconfig"
codelabs/dart-patterns-and-records/step_07_b/macos/Flutter/Flutter-Debug.xcconfig/0
{ "file_path": "codelabs/dart-patterns-and-records/step_07_b/macos/Flutter/Flutter-Debug.xcconfig", "repo_id": "codelabs", "token_count": 19 }
18
#import "GeneratedPluginRegistrant.h"
codelabs/dart-patterns-and-records/step_08/ios/Runner/Runner-Bridging-Header.h/0
{ "file_path": "codelabs/dart-patterns-and-records/step_08/ios/Runner/Runner-Bridging-Header.h", "repo_id": "codelabs", "token_count": 13 }
19
#include "../../Flutter/Flutter-Release.xcconfig" #include "Warnings.xcconfig"
codelabs/dart-patterns-and-records/step_09/macos/Runner/Configs/Release.xcconfig/0
{ "file_path": "codelabs/dart-patterns-and-records/step_09/macos/Runner/Configs/Release.xcconfig", "repo_id": "codelabs", "token_count": 32 }
20
org.gradle.jvmargs=-Xmx4G android.useAndroidX=true android.enableJetifier=true
codelabs/dart-patterns-and-records/step_11_b/android/gradle.properties/0
{ "file_path": "codelabs/dart-patterns-and-records/step_11_b/android/gradle.properties", "repo_id": "codelabs", "token_count": 30 }
21
package com.example.deeplink_cookbook import io.flutter.embedding.android.FlutterActivity class MainActivity: FlutterActivity() { }
codelabs/deeplink_cookbook/android/app/src/main/kotlin/com/example/deeplink_cookbook/MainActivity.kt/0
{ "file_path": "codelabs/deeplink_cookbook/android/app/src/main/kotlin/com/example/deeplink_cookbook/MainActivity.kt", "repo_id": "codelabs", "token_count": 42 }
22
org.gradle.jvmargs=-Xmx4G android.useAndroidX=true android.enableJetifier=true
codelabs/ffigen_codelab/step_05/example/android/gradle.properties/0
{ "file_path": "codelabs/ffigen_codelab/step_05/example/android/gradle.properties", "repo_id": "codelabs", "token_count": 30 }
23
/* * duk_config.h configuration header generated by genconfig.py. * * Git commit: 03d4d728f8365021de6955c649e6dcd05dcca99f * Git describe: 03d4d72-dirty * Git branch: HEAD * * Supported platforms: * - Mac OSX, iPhone, Darwin * - Orbis * - OpenBSD * - Generic BSD * - Atari ST TOS * - AmigaOS * - Durango (XboxOne) * - Windows * - Flashplayer (Crossbridge) * - QNX * - TI-Nspire * - Emscripten * - Android * - Linux * - Solaris * - AIX * - HPUX * - Generic POSIX * - Cygwin * - Generic UNIX * - Generic fallback * * Supported architectures: * - x86 * - x64 * - x32 * - ARM 32-bit * - ARM 64-bit * - MIPS 32-bit * - MIPS 64-bit * - PowerPC 32-bit * - PowerPC 64-bit * - SPARC 32-bit * - SPARC 64-bit * - RISC-V 32-bit * - RISC-V 64-bit * - SuperH * - Motorola 68k * - Emscripten * - Generic * * Supported compilers: * - Clang * - GCC * - MSVC * - Emscripten * - TinyC * - VBCC * - Bruce's C compiler * - Generic * */ #if !defined(DUK_CONFIG_H_INCLUDED) #define DUK_CONFIG_H_INCLUDED /* * Intermediate helper defines */ /* DLL build detection */ /* not configured for DLL build */ #undef DUK_F_DLL_BUILD /* Apple OSX, iOS */ #if defined(__APPLE__) #define DUK_F_APPLE #endif /* FreeBSD */ #if defined(__FreeBSD__) || defined(__FreeBSD) #define DUK_F_FREEBSD #endif /* Orbis (PS4) variant */ #if defined(DUK_F_FREEBSD) && defined(__ORBIS__) #define DUK_F_ORBIS #endif /* OpenBSD */ #if defined(__OpenBSD__) || defined(__OpenBSD) #define DUK_F_OPENBSD #endif /* NetBSD */ #if defined(__NetBSD__) || defined(__NetBSD) #define DUK_F_NETBSD #endif /* BSD variant */ #if defined(DUK_F_FREEBSD) || defined(DUK_F_NETBSD) || defined(DUK_F_OPENBSD) || \ defined(__bsdi__) || defined(__DragonFly__) #define DUK_F_BSD #endif /* Atari ST TOS. __TOS__ defined by PureC. No platform define in VBCC * apparently, so to use with VBCC user must define __TOS__ manually. */ #if defined(__TOS__) #define DUK_F_TOS #endif /* Motorola 68K. Not defined by VBCC, so user must define one of these * manually when using VBCC. */ #if defined(__m68k__) || defined(M68000) || defined(__MC68K__) #define DUK_F_M68K #endif /* AmigaOS. Neither AMIGA nor __amigaos__ is defined on VBCC, so user must * define 'AMIGA' manually when using VBCC. */ #if defined(AMIGA) || defined(__amigaos__) #define DUK_F_AMIGAOS #endif /* PowerPC */ #if defined(__powerpc) || defined(__powerpc__) || defined(__PPC__) #define DUK_F_PPC #if defined(__PPC64__) || defined(__LP64__) || defined(_LP64) #define DUK_F_PPC64 #else #define DUK_F_PPC32 #endif #endif /* Durango (Xbox One) */ #if defined(_DURANGO) || defined(_XBOX_ONE) #define DUK_F_DURANGO #endif /* Windows, both 32-bit and 64-bit */ #if defined(_WIN32) || defined(WIN32) || defined(_WIN64) || defined(WIN64) || \ defined(__WIN32__) || defined(__TOS_WIN__) || defined(__WINDOWS__) #define DUK_F_WINDOWS #if defined(_WIN64) || defined(WIN64) #define DUK_F_WIN64 #else #define DUK_F_WIN32 #endif #endif /* Flash player (e.g. Crossbridge) */ #if defined(__FLASHPLAYER__) #define DUK_F_FLASHPLAYER #endif /* QNX */ #if defined(__QNX__) #define DUK_F_QNX #endif /* TI-Nspire (using Ndless) */ #if defined(_TINSPIRE) #define DUK_F_TINSPIRE #endif /* Emscripten (provided explicitly by user), improve if possible */ #if defined(EMSCRIPTEN) #define DUK_F_EMSCRIPTEN #endif /* BCC (Bruce's C compiler): this is a "torture target" for compilation */ #if defined(__BCC__) || defined(__BCC_VERSION__) #define DUK_F_BCC #endif #if defined(ANDROID) || defined(__ANDROID__) #define DUK_F_ANDROID #endif /* Linux */ #if defined(__linux) || defined(__linux__) || defined(linux) #define DUK_F_LINUX #endif /* illumos / Solaris */ #if defined(__sun) && defined(__SVR4) #define DUK_F_SUN #if defined(__SUNPRO_C) && (__SUNPRO_C < 0x550) #define DUK_F_OLD_SOLARIS /* Defines _ILP32 / _LP64 required by DUK_F_X86/DUK_F_X64. Platforms * are processed before architectures, so this happens before the * DUK_F_X86/DUK_F_X64 detection is emitted. */ #include <sys/isa_defs.h> #endif #endif /* AIX */ #if defined(_AIX) /* defined(__xlc__) || defined(__IBMC__): works but too wide */ #define DUK_F_AIX #endif /* HPUX */ #if defined(__hpux) #define DUK_F_HPUX #if defined(__ia64) #define DUK_F_HPUX_ITANIUM #endif #endif /* POSIX */ #if defined(__posix) #define DUK_F_POSIX #endif /* Cygwin */ #if defined(__CYGWIN__) #define DUK_F_CYGWIN #endif /* Generic Unix (includes Cygwin) */ #if defined(__unix) || defined(__unix__) || defined(unix) || \ defined(DUK_F_LINUX) || defined(DUK_F_BSD) #define DUK_F_UNIX #endif /* Intel x86 (32-bit), x64 (64-bit) or x32 (64-bit but 32-bit pointers), * define only one of DUK_F_X86, DUK_F_X64, DUK_F_X32. * https://sites.google.com/site/x32abi/ * * With DUK_F_OLD_SOLARIS the <sys/isa_defs.h> header must be included * before this. */ #if defined(__amd64__) || defined(__amd64) || \ defined(__x86_64__) || defined(__x86_64) || \ defined(_M_X64) || defined(_M_AMD64) #if defined(__ILP32__) || defined(_ILP32) #define DUK_F_X32 #else #define DUK_F_X64 #endif #elif defined(i386) || defined(__i386) || defined(__i386__) || \ defined(__i486__) || defined(__i586__) || defined(__i686__) || \ defined(__IA32__) || defined(_M_IX86) || defined(__X86__) || \ defined(_X86_) || defined(__THW_INTEL__) || defined(__I86__) #if defined(__LP64__) || defined(_LP64) /* This should not really happen, but would indicate x64. */ #define DUK_F_X64 #else #define DUK_F_X86 #endif #endif /* ARM */ #if defined(__arm__) || defined(__thumb__) || defined(_ARM) || defined(_M_ARM) || defined(_M_ARM64) || defined(__aarch64__) #define DUK_F_ARM #if defined(__LP64__) || defined(_LP64) || defined(__arm64) || defined(__arm64__) || defined(_M_ARM64) || defined(__aarch64__) #define DUK_F_ARM64 #else #define DUK_F_ARM32 #endif #endif /* MIPS. Related defines: __MIPSEB__, __MIPSEL__, __mips_isa_rev, __LP64__ */ #if defined(__mips__) || defined(mips) || defined(_MIPS_ISA) || \ defined(_R3000) || defined(_R4000) || defined(_R5900) || \ defined(_MIPS_ISA_MIPS1) || defined(_MIPS_ISA_MIPS2) || \ defined(_MIPS_ISA_MIPS3) || defined(_MIPS_ISA_MIPS4) || \ defined(__mips) || defined(__MIPS__) #define DUK_F_MIPS #if defined(__LP64__) || defined(_LP64) || defined(__mips64) || \ defined(__mips64__) || defined(__mips_n64) #define DUK_F_MIPS64 #else #define DUK_F_MIPS32 #endif #endif /* SPARC */ #if defined(sparc) || defined(__sparc) || defined(__sparc__) #define DUK_F_SPARC #if defined(__LP64__) || defined(_LP64) #define DUK_F_SPARC64 #else #define DUK_F_SPARC32 #endif #endif /* RISC-V, https://github.com/riscv/riscv-toolchain-conventions#cc-preprocessor-definitions */ #if defined(__riscv) #define DUK_F_RISCV #if defined(__riscv_xlen) #if (__riscv_xlen == 32) #define DUK_F_RISCV32 #elif (__riscv_xlen == 64) #define DUK_F_RISCV64 #else #error __riscv_xlen has unsupported value (not 32 or 64) #endif #else #error __riscv defined without __riscv_xlen #endif #endif /* __riscv */ /* SuperH */ #if defined(__sh__) || \ defined(__sh1__) || defined(__SH1__) || \ defined(__sh2__) || defined(__SH2__) || \ defined(__sh3__) || defined(__SH3__) || \ defined(__sh4__) || defined(__SH4__) || \ defined(__sh5__) || defined(__SH5__) #define DUK_F_SUPERH #endif /* Clang */ #if defined(__clang__) #define DUK_F_CLANG #endif /* C++ */ #undef DUK_F_CPP #if defined(__cplusplus) #define DUK_F_CPP #endif /* C99 or above */ #undef DUK_F_C99 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) #define DUK_F_C99 #endif /* C++11 or above */ #undef DUK_F_CPP11 #if defined(__cplusplus) && (__cplusplus >= 201103L) #define DUK_F_CPP11 #endif /* GCC. Clang also defines __GNUC__ so don't detect GCC if using Clang. */ #if defined(__GNUC__) && !defined(__clang__) && !defined(DUK_F_CLANG) #define DUK_F_GCC #if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) /* Convenience, e.g. gcc 4.5.1 == 40501; http://stackoverflow.com/questions/6031819/emulating-gccs-builtin-unreachable */ #define DUK_F_GCC_VERSION (__GNUC__ * 10000L + __GNUC_MINOR__ * 100L + __GNUC_PATCHLEVEL__) #else #error cannot figure out gcc version #endif #endif /* MinGW. Also GCC flags (DUK_F_GCC) are enabled now. */ #if defined(__MINGW32__) || defined(__MINGW64__) #define DUK_F_MINGW #endif /* MSVC */ #if defined(_MSC_VER) /* MSVC preprocessor defines: http://msdn.microsoft.com/en-us/library/b0084kay.aspx * _MSC_FULL_VER includes the build number, but it has at least two formats, see e.g. * BOOST_MSVC_FULL_VER in http://www.boost.org/doc/libs/1_52_0/boost/config/compiler/visualc.hpp */ #define DUK_F_MSVC #if defined(_MSC_FULL_VER) #if (_MSC_FULL_VER > 100000000) #define DUK_F_MSVC_FULL_VER _MSC_FULL_VER #else #define DUK_F_MSCV_FULL_VER (_MSC_FULL_VER * 10) #endif #endif #endif /* _MSC_VER */ /* TinyC */ #if defined(__TINYC__) /* http://bellard.org/tcc/tcc-doc.html#SEC9 */ #define DUK_F_TINYC #endif /* VBCC */ #if defined(__VBCC__) #define DUK_F_VBCC #endif /* Atari Mint */ #if defined(__MINT__) #define DUK_F_MINT #endif /* * Platform autodetection */ /* Workaround for older C++ compilers before including <inttypes.h>, * see e.g.: https://sourceware.org/bugzilla/show_bug.cgi?id=15366 */ #if defined(__cplusplus) && !defined(__STDC_LIMIT_MACROS) #define __STDC_LIMIT_MACROS #endif #if defined(__cplusplus) && !defined(__STDC_CONSTANT_MACROS) #define __STDC_CONSTANT_MACROS #endif #if defined(DUK_F_APPLE) /* --- Mac OSX, iPhone, Darwin --- */ #define DUK_USE_DATE_NOW_GETTIMEOFDAY #define DUK_USE_DATE_TZO_GMTIME_R #define DUK_USE_DATE_PRS_STRPTIME #define DUK_USE_DATE_FMT_STRFTIME #include <TargetConditionals.h> #include <architecture/byte_order.h> #include <sys/param.h> #include <sys/time.h> #include <time.h> /* http://stackoverflow.com/questions/5919996/how-to-detect-reliably-mac-os-x-ios-linux-windows-in-c-preprocessor */ #if TARGET_IPHONE_SIMULATOR #define DUK_USE_OS_STRING "iphone-sim" #elif TARGET_OS_IPHONE #define DUK_USE_OS_STRING "iphone" #elif TARGET_OS_MAC #define DUK_USE_OS_STRING "osx" #else #define DUK_USE_OS_STRING "osx-unknown" #endif /* Use _setjmp() on Apple by default, see GH-55. */ #define DUK_JMPBUF_TYPE jmp_buf #define DUK_SETJMP(jb) _setjmp((jb)) #define DUK_LONGJMP(jb) _longjmp((jb), 1) #elif defined(DUK_F_ORBIS) /* --- Orbis --- */ /* Orbis = PS4 */ #define DUK_USE_DATE_NOW_GETTIMEOFDAY #define DUK_USE_DATE_TZO_GMTIME_S /* no parsing (not an error) */ #define DUK_USE_DATE_FMT_STRFTIME #include <sys/types.h> #include <machine/endian.h> #include <sys/param.h> #include <sys/time.h> #include <time.h> #define DUK_USE_OS_STRING "orbis" #elif defined(DUK_F_OPENBSD) /* --- OpenBSD --- */ /* http://www.monkey.org/openbsd/archive/ports/0401/msg00089.html */ #define DUK_USE_DATE_NOW_GETTIMEOFDAY #define DUK_USE_DATE_TZO_GMTIME_R #define DUK_USE_DATE_PRS_STRPTIME #define DUK_USE_DATE_FMT_STRFTIME #include <sys/types.h> #include <sys/endian.h> #include <sys/param.h> #include <sys/time.h> #include <time.h> #define DUK_USE_OS_STRING "openbsd" #elif defined(DUK_F_BSD) /* --- Generic BSD --- */ #define DUK_USE_DATE_NOW_GETTIMEOFDAY #define DUK_USE_DATE_TZO_GMTIME_R #define DUK_USE_DATE_PRS_STRPTIME #define DUK_USE_DATE_FMT_STRFTIME #include <sys/types.h> #include <sys/endian.h> #include <sys/param.h> #include <sys/time.h> #include <time.h> #define DUK_USE_OS_STRING "bsd" #elif defined(DUK_F_TOS) /* --- Atari ST TOS --- */ #define DUK_USE_DATE_NOW_TIME #define DUK_USE_DATE_TZO_GMTIME /* no parsing (not an error) */ #define DUK_USE_DATE_FMT_STRFTIME #include <time.h> #define DUK_USE_OS_STRING "tos" /* TOS on M68K is always big endian. */ #if !defined(DUK_USE_BYTEORDER) && defined(DUK_F_M68K) #define DUK_USE_BYTEORDER 3 #endif #elif defined(DUK_F_AMIGAOS) /* --- AmigaOS --- */ #if defined(DUK_F_M68K) /* AmigaOS on M68k */ #define DUK_USE_DATE_NOW_TIME #define DUK_USE_DATE_TZO_GMTIME /* no parsing (not an error) */ #define DUK_USE_DATE_FMT_STRFTIME #include <time.h> #elif defined(DUK_F_PPC) #define DUK_USE_DATE_NOW_GETTIMEOFDAY #define DUK_USE_DATE_TZO_GMTIME_R #define DUK_USE_DATE_PRS_STRPTIME #define DUK_USE_DATE_FMT_STRFTIME #include <time.h> #if !defined(UINTPTR_MAX) #define UINTPTR_MAX UINT_MAX #endif #else #error AmigaOS but not M68K/PPC, not supported now #endif #define DUK_USE_OS_STRING "amigaos" /* AmigaOS on M68K or PPC is always big endian. */ #if !defined(DUK_USE_BYTEORDER) && (defined(DUK_F_M68K) || defined(DUK_F_PPC)) #define DUK_USE_BYTEORDER 3 #endif #elif defined(DUK_F_DURANGO) /* --- Durango (XboxOne) --- */ /* Durango = XboxOne * Configuration is nearly identical to Windows, except for * DUK_USE_DATE_TZO_WINDOWS. */ /* Initial fix: disable secure CRT related warnings when compiling Duktape * itself (must be defined before including Windows headers). Don't define * for user code including duktape.h. */ #if defined(DUK_COMPILING_DUKTAPE) && !defined(_CRT_SECURE_NO_WARNINGS) #define _CRT_SECURE_NO_WARNINGS #endif /* MSVC does not have sys/param.h */ #define DUK_USE_DATE_NOW_WINDOWS #define DUK_USE_DATE_TZO_WINDOWS_NO_DST /* Note: PRS and FMT are intentionally left undefined for now. This means * there is no platform specific date parsing/formatting but there is still * the ISO 8601 standard format. */ #if defined(DUK_COMPILING_DUKTAPE) /* Only include when compiling Duktape to avoid polluting application build * with a lot of unnecessary defines. */ #include <windows.h> #endif #define DUK_USE_OS_STRING "durango" #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 1 #endif #elif defined(DUK_F_WINDOWS) /* --- Windows --- */ /* Windows version can't obviously be determined at compile time, * but _WIN32_WINNT indicates the minimum version targeted: * - https://msdn.microsoft.com/en-us/library/6sehtctf.aspx */ /* Initial fix: disable secure CRT related warnings when compiling Duktape * itself (must be defined before including Windows headers). Don't define * for user code including duktape.h. */ #if defined(DUK_COMPILING_DUKTAPE) && !defined(_CRT_SECURE_NO_WARNINGS) #define _CRT_SECURE_NO_WARNINGS #endif /* Windows 32-bit and 64-bit are currently the same. */ /* MSVC does not have sys/param.h */ #if defined(DUK_COMPILING_DUKTAPE) /* Only include when compiling Duktape to avoid polluting application build * with a lot of unnecessary defines. */ #include <windows.h> #endif /* GetSystemTimePreciseAsFileTime() available from Windows 8: * https://msdn.microsoft.com/en-us/library/windows/desktop/hh706895(v=vs.85).aspx */ #if defined(DUK_USE_DATE_NOW_WINDOWS_SUBMS) || defined(DUK_USE_DATE_NOW_WINDOWS) /* User forced provider. */ #else #if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0602) #define DUK_USE_DATE_NOW_WINDOWS_SUBMS #else #define DUK_USE_DATE_NOW_WINDOWS #endif #endif #define DUK_USE_DATE_TZO_WINDOWS /* Note: PRS and FMT are intentionally left undefined for now. This means * there is no platform specific date parsing/formatting but there is still * the ISO 8601 standard format. */ /* QueryPerformanceCounter() may go backwards in Windows XP, so enable for * Vista and later: https://msdn.microsoft.com/en-us/library/windows/desktop/dn553408(v=vs.85).aspx#qpc_support_in_windows_versions */ #if !defined(DUK_USE_GET_MONOTONIC_TIME_WINDOWS_QPC) && \ defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0600) #define DUK_USE_GET_MONOTONIC_TIME_WINDOWS_QPC #endif #define DUK_USE_OS_STRING "windows" /* On Windows, assume we're little endian. Even Itanium which has a * configurable endianness runs little endian in Windows. */ #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 1 #endif #elif defined(DUK_F_FLASHPLAYER) /* --- Flashplayer (Crossbridge) --- */ #define DUK_USE_DATE_NOW_GETTIMEOFDAY #define DUK_USE_DATE_TZO_GMTIME_R #define DUK_USE_DATE_PRS_STRPTIME #define DUK_USE_DATE_FMT_STRFTIME #include <endian.h> #include <sys/param.h> #include <sys/time.h> #include <time.h> #define DUK_USE_OS_STRING "flashplayer" #if !defined(DUK_USE_BYTEORDER) && defined(DUK_F_FLASHPLAYER) #define DUK_USE_BYTEORDER 1 #endif #elif defined(DUK_F_QNX) /* --- QNX --- */ #if defined(DUK_F_QNX) && defined(DUK_COMPILING_DUKTAPE) /* See: /opt/qnx650/target/qnx6/usr/include/sys/platform.h */ #define _XOPEN_SOURCE 600 #define _POSIX_C_SOURCE 200112L #endif #define DUK_USE_DATE_NOW_GETTIMEOFDAY #define DUK_USE_DATE_TZO_GMTIME_R #define DUK_USE_DATE_PRS_STRPTIME #define DUK_USE_DATE_FMT_STRFTIME #include <sys/types.h> #include <sys/param.h> #include <sys/time.h> #include <time.h> #define DUK_USE_OS_STRING "qnx" #elif defined(DUK_F_TINSPIRE) /* --- TI-Nspire --- */ #if defined(DUK_COMPILING_DUKTAPE) && !defined(_XOPEN_SOURCE) #define _XOPEN_SOURCE /* e.g. strptime */ #endif #define DUK_USE_DATE_NOW_GETTIMEOFDAY #define DUK_USE_DATE_TZO_GMTIME_R #define DUK_USE_DATE_PRS_STRPTIME #define DUK_USE_DATE_FMT_STRFTIME #include <sys/types.h> #include <sys/param.h> #include <sys/time.h> #include <time.h> #define DUK_USE_OS_STRING "tinspire" #elif defined(DUK_F_EMSCRIPTEN) /* --- Emscripten --- */ #if defined(DUK_COMPILING_DUKTAPE) #if !defined(_POSIX_C_SOURCE) #define _POSIX_C_SOURCE 200809L #endif #if !defined(_GNU_SOURCE) #define _GNU_SOURCE /* e.g. getdate_r */ #endif #if !defined(_XOPEN_SOURCE) #define _XOPEN_SOURCE /* e.g. strptime */ #endif #endif /* DUK_COMPILING_DUKTAPE */ #include <sys/types.h> #if defined(DUK_F_BCC) /* no endian.h */ #else #include <endian.h> #endif /* DUK_F_BCC */ #include <sys/param.h> #include <sys/time.h> #include <time.h> #include <stdint.h> #define DUK_USE_DATE_NOW_GETTIMEOFDAY #define DUK_USE_DATE_TZO_GMTIME_R #define DUK_USE_DATE_PRS_STRPTIME #define DUK_USE_DATE_FMT_STRFTIME #define DUK_USE_OS_STRING "emscripten" #elif defined(DUK_F_ANDROID) /* --- Android --- */ #if defined(DUK_COMPILING_DUKTAPE) #if !defined(_POSIX_C_SOURCE) #define _POSIX_C_SOURCE 200809L #endif #if !defined(_GNU_SOURCE) #define _GNU_SOURCE /* e.g. getdate_r */ #endif #if !defined(_XOPEN_SOURCE) #define _XOPEN_SOURCE /* e.g. strptime */ #endif #endif /* DUK_COMPILING_DUKTAPE */ #include <sys/types.h> #if defined(DUK_F_BCC) /* no endian.h or stdint.h */ #else #include <endian.h> #include <stdint.h> #endif /* DUK_F_BCC */ #include <sys/param.h> #include <sys/time.h> #include <time.h> #define DUK_USE_DATE_NOW_GETTIMEOFDAY #define DUK_USE_DATE_TZO_GMTIME_R #define DUK_USE_DATE_PRS_STRPTIME #define DUK_USE_DATE_FMT_STRFTIME #if 0 /* XXX: safe condition? */ #define DUK_USE_GET_MONOTONIC_TIME_CLOCK_GETTIME #endif #define DUK_USE_OS_STRING "android" #elif defined(DUK_F_LINUX) /* --- Linux --- */ #if defined(DUK_COMPILING_DUKTAPE) #if !defined(_POSIX_C_SOURCE) #define _POSIX_C_SOURCE 200809L #endif #if !defined(_GNU_SOURCE) #define _GNU_SOURCE /* e.g. getdate_r */ #endif #if !defined(_XOPEN_SOURCE) #define _XOPEN_SOURCE /* e.g. strptime */ #endif #endif /* DUK_COMPILING_DUKTAPE */ #include <sys/types.h> #if defined(DUK_F_BCC) /* no endian.h or stdint.h */ #else #include <endian.h> #include <stdint.h> #endif /* DUK_F_BCC */ #include <sys/param.h> #include <sys/time.h> #include <time.h> #define DUK_USE_DATE_NOW_GETTIMEOFDAY #define DUK_USE_DATE_TZO_GMTIME_R #define DUK_USE_DATE_PRS_STRPTIME #define DUK_USE_DATE_FMT_STRFTIME #if 0 /* XXX: safe condition? */ #define DUK_USE_GET_MONOTONIC_TIME_CLOCK_GETTIME #endif #define DUK_USE_OS_STRING "linux" #elif defined(DUK_F_SUN) /* --- Solaris --- */ #define DUK_USE_DATE_NOW_GETTIMEOFDAY #define DUK_USE_DATE_TZO_GMTIME_R #define DUK_USE_DATE_PRS_STRPTIME #define DUK_USE_DATE_FMT_STRFTIME #include <sys/types.h> #if defined(DUK_F_OLD_SOLARIS) /* Old Solaris with no endian.h, stdint.h */ #define DUK_F_NO_STDINT_H #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 3 #endif #else /* DUK_F_OLD_SOLARIS */ #include <sys/param.h> #endif /* DUK_F_OLD_SOLARIS */ #include <sys/param.h> #include <sys/time.h> #include <time.h> #define DUK_USE_OS_STRING "solaris" #elif defined(DUK_F_AIX) /* --- AIX --- */ #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 3 #endif #define DUK_USE_DATE_NOW_GETTIMEOFDAY #define DUK_USE_DATE_TZO_GMTIME_R #define DUK_USE_DATE_PRS_STRPTIME #define DUK_USE_DATE_FMT_STRFTIME #include <sys/param.h> #include <sys/time.h> #include <time.h> #define DUK_USE_OS_STRING "aix" #elif defined(DUK_F_HPUX) /* --- HPUX --- */ #define DUK_F_NO_STDINT_H #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 3 #endif #define DUK_USE_DATE_NOW_GETTIMEOFDAY #define DUK_USE_DATE_TZO_GMTIME_R #define DUK_USE_DATE_PRS_STRPTIME #define DUK_USE_DATE_FMT_STRFTIME #include <sys/param.h> #include <sys/time.h> #include <time.h> #define DUK_USE_OS_STRING "hpux" #elif defined(DUK_F_POSIX) /* --- Generic POSIX --- */ #define DUK_USE_DATE_NOW_GETTIMEOFDAY #define DUK_USE_DATE_TZO_GMTIME_R #define DUK_USE_DATE_PRS_STRPTIME #define DUK_USE_DATE_FMT_STRFTIME #include <sys/types.h> #include <endian.h> #include <sys/param.h> #include <sys/time.h> #include <time.h> #define DUK_USE_OS_STRING "posix" #elif defined(DUK_F_CYGWIN) /* --- Cygwin --- */ /* don't use strptime() for now */ #define DUK_USE_DATE_NOW_GETTIMEOFDAY #define DUK_USE_DATE_TZO_GMTIME_R #define DUK_USE_DATE_FMT_STRFTIME #include <sys/types.h> #include <endian.h> #include <sys/param.h> #include <sys/time.h> #include <time.h> #define DUK_JMPBUF_TYPE jmp_buf #define DUK_SETJMP(jb) _setjmp((jb)) #define DUK_LONGJMP(jb) _longjmp((jb), 1) #define DUK_USE_OS_STRING "windows" #elif defined(DUK_F_UNIX) /* --- Generic UNIX --- */ #define DUK_USE_DATE_NOW_GETTIMEOFDAY #define DUK_USE_DATE_TZO_GMTIME_R #define DUK_USE_DATE_PRS_STRPTIME #define DUK_USE_DATE_FMT_STRFTIME #include <time.h> #include <sys/time.h> #define DUK_USE_OS_STRING "unknown" #else /* --- Generic fallback --- */ /* The most portable current time provider is time(), but it only has a * one second resolution. */ #define DUK_USE_DATE_NOW_TIME /* The most portable way to figure out local time offset is gmtime(), * but it's not thread safe so use with caution. */ #define DUK_USE_DATE_TZO_GMTIME /* Avoid custom date parsing and formatting for portability. */ #undef DUK_USE_DATE_PRS_STRPTIME #undef DUK_USE_DATE_FMT_STRFTIME /* Rely on C89 headers only; time.h must be here. */ #include <time.h> #define DUK_USE_OS_STRING "unknown" #endif /* autodetect platform */ /* Shared includes: C89 */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdarg.h> /* varargs */ #include <setjmp.h> #include <stddef.h> /* e.g. ptrdiff_t */ #include <math.h> #include <limits.h> /* date.h is omitted, and included per platform */ /* Shared includes: stdint.h is C99 */ #if defined(DUK_F_NO_STDINT_H) /* stdint.h not available */ #else /* Technically C99 (C++11) but found in many systems. On some systems * __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS must be defined before * including stdint.h (see above). */ #include <stdint.h> #endif /* <exception> is only included if needed, based on DUK_USE_xxx flags. */ /* * Architecture autodetection */ #if defined(DUK_F_X86) /* --- x86 --- */ #define DUK_USE_ARCH_STRING "x86" #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 1 #endif #define DUK_USE_PACKED_TVAL /* FreeBSD, -m32, and clang prior to 5.0 has union aliasing issues which * break duk_tval copying. Disable packed duk_tval automatically. */ #if defined(DUK_F_FREEBSD) && defined(DUK_F_X86) && \ defined(__clang__) && defined(__clang_major__) && (__clang_major__ < 5) #undef DUK_USE_PACKED_TVAL #endif #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_X64) /* --- x64 --- */ #define DUK_USE_ARCH_STRING "x64" #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 1 #endif #undef DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_X32) /* --- x32 --- */ #define DUK_USE_ARCH_STRING "x32" #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 1 #endif #define DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_ARM32) /* --- ARM 32-bit --- */ #define DUK_USE_ARCH_STRING "arm32" /* Byte order varies, so rely on autodetect. */ #define DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_ARM64) /* --- ARM 64-bit --- */ #define DUK_USE_ARCH_STRING "arm64" /* Byte order varies, so rely on autodetect. */ #undef DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_MIPS32) /* --- MIPS 32-bit --- */ #define DUK_USE_ARCH_STRING "mips32" /* MIPS byte order varies so rely on autodetection. */ #define DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_MIPS64) /* --- MIPS 64-bit --- */ #define DUK_USE_ARCH_STRING "mips64" /* MIPS byte order varies so rely on autodetection. */ #undef DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_PPC32) /* --- PowerPC 32-bit --- */ #define DUK_USE_ARCH_STRING "ppc32" #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 3 #endif #define DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_PPC64) /* --- PowerPC 64-bit --- */ #define DUK_USE_ARCH_STRING "ppc64" /* No forced byteorder (both little and big endian are possible). */ #undef DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_SPARC32) /* --- SPARC 32-bit --- */ #define DUK_USE_ARCH_STRING "sparc32" /* SPARC byte order varies so rely on autodetection. */ #define DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_SPARC64) /* --- SPARC 64-bit --- */ #define DUK_USE_ARCH_STRING "sparc64" /* SPARC byte order varies so rely on autodetection. */ #undef DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_RISCV32) /* --- RISC-V 32-bit --- */ #define DUK_USE_ARCH_STRING "riscv32" #define DUK_USE_BYTEORDER 1 #define DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_RISCV64) /* --- RISC-V 64-bit --- */ #define DUK_USE_ARCH_STRING "riscv64" #define DUK_USE_BYTEORDER 1 #undef DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_SUPERH) /* --- SuperH --- */ #define DUK_USE_ARCH_STRING "sh" /* Byte order varies, rely on autodetection. */ #define DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_M68K) /* --- Motorola 68k --- */ #define DUK_USE_ARCH_STRING "m68k" #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 3 #endif #define DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_EMSCRIPTEN) /* --- Emscripten --- */ #define DUK_USE_ARCH_STRING "emscripten" #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 1 #endif #undef DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #else /* --- Generic --- */ /* These are necessary wild guesses. */ #define DUK_USE_ARCH_STRING "generic" /* Rely on autodetection for byte order, alignment, and packed tval. */ #endif /* autodetect architecture */ /* * Compiler autodetection */ #if defined(DUK_F_CLANG) /* --- Clang --- */ #if defined(DUK_F_C99) || defined(DUK_F_CPP11) /* C99 / C++11 and above: rely on va_copy() which is required. */ #define DUK_VA_COPY(dest,src) va_copy(dest,src) #else /* Clang: assume we have __va_copy() in non-C99 mode. */ #define DUK_VA_COPY(dest,src) __va_copy(dest,src) #endif #define DUK_NORETURN(decl) decl __attribute__((noreturn)) #if defined(__clang__) && defined(__has_builtin) #if __has_builtin(__builtin_unreachable) #define DUK_UNREACHABLE() do { __builtin_unreachable(); } while (0) #endif #endif #define DUK_USE_BRANCH_HINTS #define DUK_LIKELY(x) __builtin_expect((x), 1) #define DUK_UNLIKELY(x) __builtin_expect((x), 0) #if defined(__clang__) && defined(__has_builtin) #if __has_builtin(__builtin_unpredictable) #define DUK_UNPREDICTABLE(x) __builtin_unpredictable((x)) #endif #endif #if defined(DUK_F_C99) || defined(DUK_F_CPP11) #define DUK_NOINLINE __attribute__((noinline)) #define DUK_INLINE inline #define DUK_ALWAYS_INLINE inline __attribute__((always_inline)) #endif /* DUK_HOT */ /* DUK_COLD */ #if defined(DUK_F_DLL_BUILD) && defined(DUK_F_WINDOWS) /* MSVC dllexport/dllimport: appropriate __declspec depends on whether we're * compiling Duktape or the application. */ #if defined(DUK_COMPILING_DUKTAPE) #define DUK_EXTERNAL_DECL extern __declspec(dllexport) #define DUK_EXTERNAL __declspec(dllexport) #else #define DUK_EXTERNAL_DECL extern __declspec(dllimport) #define DUK_EXTERNAL should_not_happen #endif #if defined(DUK_SINGLE_FILE) #define DUK_INTERNAL_DECL static #define DUK_INTERNAL static #else #define DUK_INTERNAL_DECL extern #define DUK_INTERNAL /*empty*/ #endif #define DUK_LOCAL_DECL static #define DUK_LOCAL static #else #define DUK_EXTERNAL_DECL __attribute__ ((visibility("default"))) extern #define DUK_EXTERNAL __attribute__ ((visibility("default"))) #if defined(DUK_SINGLE_FILE) #if (defined(DUK_F_GCC_VERSION) && DUK_F_GCC_VERSION >= 30101) || defined(DUK_F_CLANG) /* Minimize warnings for unused internal functions with GCC >= 3.1.1 and * Clang. Based on documentation it should suffice to have the attribute * in the declaration only, but in practice some warnings are generated unless * the attribute is also applied to the definition. */ #define DUK_INTERNAL_DECL static __attribute__ ((unused)) #define DUK_INTERNAL static __attribute__ ((unused)) #else #define DUK_INTERNAL_DECL static #define DUK_INTERNAL static #endif #else #if (defined(DUK_F_GCC_VERSION) && DUK_F_GCC_VERSION >= 30101) || defined(DUK_F_CLANG) #define DUK_INTERNAL_DECL __attribute__ ((visibility("hidden"))) __attribute__ ((unused)) extern #define DUK_INTERNAL __attribute__ ((visibility("hidden"))) __attribute__ ((unused)) #else #define DUK_INTERNAL_DECL __attribute__ ((visibility("hidden"))) extern #define DUK_INTERNAL __attribute__ ((visibility("hidden"))) #endif #endif #define DUK_LOCAL_DECL static #define DUK_LOCAL static #endif #if defined(DUK_F_CPP) #define DUK_USE_COMPILER_STRING "clang" #else #define DUK_USE_COMPILER_STRING "clang" #endif #undef DUK_USE_VARIADIC_MACROS #if defined(DUK_F_C99) || defined(DUK_F_CPP11) #define DUK_USE_VARIADIC_MACROS #endif #define DUK_USE_UNION_INITIALIZERS #undef DUK_USE_FLEX_C99 #undef DUK_USE_FLEX_ZEROSIZE #undef DUK_USE_FLEX_ONESIZE #if defined(DUK_F_C99) #define DUK_USE_FLEX_C99 #else #define DUK_USE_FLEX_ZEROSIZE #endif #define DUK_USE_CLANG_PRAGMAS #define DUK_USE_PACK_CLANG_ATTR #if defined(__clang__) && defined(__has_builtin) #if __has_builtin(__builtin_bswap64) #define DUK_BSWAP64(x) ((duk_uint64_t) __builtin_bswap64((duk_uint64_t) (x))) #endif #if __has_builtin(__builtin_bswap32) #define DUK_BSWAP32(x) ((duk_uint32_t) __builtin_bswap32((duk_uint32_t) (x))) #endif #if __has_builtin(__builtin_bswap16) #define DUK_BSWAP16(x) ((duk_uint16_t) __builtin_bswap16((duk_uint16_t) (x))) #endif #endif #elif defined(DUK_F_GCC) /* --- GCC --- */ #if defined(DUK_F_C99) || defined(DUK_F_CPP11) /* C99 / C++11 and above: rely on va_copy() which is required. */ #define DUK_VA_COPY(dest,src) va_copy(dest,src) #else /* GCC: assume we have __va_copy() in non-C99 mode. */ #define DUK_VA_COPY(dest,src) __va_copy(dest,src) #endif #if defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 20500L) && (DUK_F_GCC_VERSION < 50000L) /* Since gcc-2.5. * * Disabled temporarily in GCC 5+ because of an unresolved noreturn-related * issue: https://github.com/svaarala/duktape/issues/2155. */ #define DUK_NORETURN(decl) decl __attribute__((noreturn)) #endif #if defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 40500L) /* Since gcc-4.5. */ #define DUK_UNREACHABLE() do { __builtin_unreachable(); } while (0) #endif #define DUK_USE_BRANCH_HINTS #if defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 40500L) /* GCC: test not very accurate; enable only in relatively recent builds * because of bugs in gcc-4.4 (http://lists.debian.org/debian-gcc/2010/04/msg00000.html) */ #define DUK_LIKELY(x) __builtin_expect((x), 1) #define DUK_UNLIKELY(x) __builtin_expect((x), 0) #endif /* XXX: equivalent of clang __builtin_unpredictable? */ #if (defined(DUK_F_C99) || defined(DUK_F_CPP11)) && \ defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 30101) #define DUK_NOINLINE __attribute__((noinline)) #define DUK_INLINE inline #define DUK_ALWAYS_INLINE inline __attribute__((always_inline)) #endif #if (defined(DUK_F_C99) || defined(DUK_F_CPP11)) && \ defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 40300) #define DUK_HOT __attribute__((hot)) #define DUK_COLD __attribute__((cold)) #endif #if defined(DUK_F_DLL_BUILD) && defined(DUK_F_WINDOWS) /* MSVC dllexport/dllimport: appropriate __declspec depends on whether we're * compiling Duktape or the application. */ #if defined(DUK_COMPILING_DUKTAPE) #define DUK_EXTERNAL_DECL extern __declspec(dllexport) #define DUK_EXTERNAL __declspec(dllexport) #else #define DUK_EXTERNAL_DECL extern __declspec(dllimport) #define DUK_EXTERNAL should_not_happen #endif #if defined(DUK_SINGLE_FILE) #define DUK_INTERNAL_DECL static #define DUK_INTERNAL static #else #define DUK_INTERNAL_DECL extern #define DUK_INTERNAL /*empty*/ #endif #define DUK_LOCAL_DECL static #define DUK_LOCAL static #elif defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 40000) #define DUK_EXTERNAL_DECL __attribute__ ((visibility("default"))) extern #define DUK_EXTERNAL __attribute__ ((visibility("default"))) #if defined(DUK_SINGLE_FILE) #if (defined(DUK_F_GCC_VERSION) && DUK_F_GCC_VERSION >= 30101) || defined(DUK_F_CLANG) /* Minimize warnings for unused internal functions with GCC >= 3.1.1 and * Clang. Based on documentation it should suffice to have the attribute * in the declaration only, but in practice some warnings are generated unless * the attribute is also applied to the definition. */ #define DUK_INTERNAL_DECL static __attribute__ ((unused)) #define DUK_INTERNAL static __attribute__ ((unused)) #else #define DUK_INTERNAL_DECL static #define DUK_INTERNAL static #endif #else #if (defined(DUK_F_GCC_VERSION) && DUK_F_GCC_VERSION >= 30101) || defined(DUK_F_CLANG) #define DUK_INTERNAL_DECL __attribute__ ((visibility("hidden"))) __attribute__ ((unused)) extern #define DUK_INTERNAL __attribute__ ((visibility("hidden"))) __attribute__ ((unused)) #else #define DUK_INTERNAL_DECL __attribute__ ((visibility("hidden"))) extern #define DUK_INTERNAL __attribute__ ((visibility("hidden"))) #endif #endif #define DUK_LOCAL_DECL static #define DUK_LOCAL static #endif #if defined(DUK_F_MINGW) #if defined(DUK_F_CPP) #define DUK_USE_COMPILER_STRING "mingw++" #else #define DUK_USE_COMPILER_STRING "mingw" #endif #else #if defined(DUK_F_CPP) #define DUK_USE_COMPILER_STRING "g++" #else #define DUK_USE_COMPILER_STRING "gcc" #endif #endif #undef DUK_USE_VARIADIC_MACROS #if defined(DUK_F_C99) || (defined(DUK_F_CPP11) && defined(__GNUC__)) #define DUK_USE_VARIADIC_MACROS #endif #define DUK_USE_UNION_INITIALIZERS #undef DUK_USE_FLEX_C99 #undef DUK_USE_FLEX_ZEROSIZE #undef DUK_USE_FLEX_ONESIZE #if defined(DUK_F_C99) #define DUK_USE_FLEX_C99 #else #define DUK_USE_FLEX_ZEROSIZE #endif /* Since 4.6 one can '#pragma GCC diagnostic push/pop'. */ #if defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 40600) #define DUK_USE_GCC_PRAGMAS #else #undef DUK_USE_GCC_PRAGMAS #endif #define DUK_USE_PACK_GCC_ATTR /* Availability varies based on platform (between GCC 4.4 and 4.8), and there * are apparently some bugs in GCC 4.x. Check for GCC 5.0 before enabling * these to be safe. */ #if defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 50000L) #define DUK_BSWAP64(x) ((duk_uint64_t) __builtin_bswap64((duk_uint64_t) (x))) #define DUK_BSWAP32(x) ((duk_uint32_t) __builtin_bswap32((duk_uint32_t) (x))) #define DUK_BSWAP16(x) ((duk_uint16_t) __builtin_bswap16((duk_uint16_t) (x))) #endif #elif defined(DUK_F_MSVC) /* --- MSVC --- */ /* http://msdn.microsoft.com/en-us/library/aa235362(VS.60).aspx */ #define DUK_NORETURN(decl) __declspec(noreturn) decl /* XXX: DUK_UNREACHABLE for msvc? */ #undef DUK_USE_BRANCH_HINTS /* XXX: DUK_LIKELY, DUK_UNLIKELY for msvc? */ /* XXX: DUK_NOINLINE, DUK_INLINE, DUK_ALWAYS_INLINE for msvc? */ #if defined(DUK_F_DLL_BUILD) && defined(DUK_F_WINDOWS) /* MSVC dllexport/dllimport: appropriate __declspec depends on whether we're * compiling Duktape or the application. */ #if defined(DUK_COMPILING_DUKTAPE) #define DUK_EXTERNAL_DECL extern __declspec(dllexport) #define DUK_EXTERNAL __declspec(dllexport) #else #define DUK_EXTERNAL_DECL extern __declspec(dllimport) #define DUK_EXTERNAL should_not_happen #endif #if defined(DUK_SINGLE_FILE) #define DUK_INTERNAL_DECL static #define DUK_INTERNAL static #else #define DUK_INTERNAL_DECL extern #define DUK_INTERNAL /*empty*/ #endif #define DUK_LOCAL_DECL static #define DUK_LOCAL static #endif #if defined(DUK_F_CPP) #define DUK_USE_COMPILER_STRING "msvc++" #else #define DUK_USE_COMPILER_STRING "msvc" #endif #undef DUK_USE_VARIADIC_MACROS #if defined(DUK_F_C99) #define DUK_USE_VARIADIC_MACROS #elif defined(_MSC_VER) && (_MSC_VER >= 1400) /* VS2005+ should have variadic macros even when they're not C99. */ #define DUK_USE_VARIADIC_MACROS #endif #undef DUK_USE_UNION_INITIALIZERS #if defined(_MSC_VER) && (_MSC_VER >= 1800) /* VS2013+ supports union initializers but there's a bug involving union-inside-struct: * https://connect.microsoft.com/VisualStudio/feedback/details/805981 * The bug was fixed (at least) in VS2015 so check for VS2015 for now: * https://blogs.msdn.microsoft.com/vcblog/2015/07/01/c-compiler-front-end-fixes-in-vs2015/ * Manually tested using VS2013, CL reports 18.00.31101, so enable for VS2013 too. */ #define DUK_USE_UNION_INITIALIZERS #endif #undef DUK_USE_FLEX_C99 #undef DUK_USE_FLEX_ZEROSIZE #undef DUK_USE_FLEX_ONESIZE #if defined(DUK_F_C99) #define DUK_USE_FLEX_C99 #else #define DUK_USE_FLEX_ZEROSIZE #endif #undef DUK_USE_GCC_PRAGMAS #define DUK_USE_PACK_MSVC_PRAGMA /* These have been tested from VS2008 onwards; may work in older VS versions * too but not enabled by default. */ #if defined(_MSC_VER) && (_MSC_VER >= 1500) #define DUK_NOINLINE __declspec(noinline) #define DUK_INLINE __inline #define DUK_ALWAYS_INLINE __forceinline #endif #if defined(_MSC_VER) && (_MSC_VER >= 1900) #define DUK_SNPRINTF snprintf #define DUK_VSNPRINTF vsnprintf #else /* (v)snprintf() is missing before MSVC 2015. Note that _(v)snprintf() does * NOT NUL terminate on truncation, but Duktape code never assumes that. * http://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010 */ #define DUK_SNPRINTF _snprintf #define DUK_VSNPRINTF _vsnprintf #endif /* Avoid warning when doing DUK_UNREF(some_function). */ #if defined(_MSC_VER) && (_MSC_VER < 1500) #pragma warning(disable: 4100 4101 4550 4551) #define DUK_UNREF(x) #else #define DUK_UNREF(x) do { __pragma(warning(suppress:4100 4101 4550 4551)) (x); } while (0) #endif /* Older versions of MSVC don't support the LL/ULL suffix. */ #define DUK_U64_CONSTANT(x) x##ui64 #define DUK_I64_CONSTANT(x) x##i64 #elif defined(DUK_F_EMSCRIPTEN) /* --- Emscripten --- */ #define DUK_NORETURN(decl) decl __attribute__((noreturn)) #if defined(__clang__) && defined(__has_builtin) #if __has_builtin(__builtin_unreachable) #define DUK_UNREACHABLE() do { __builtin_unreachable(); } while (0) #endif #endif #define DUK_USE_BRANCH_HINTS #define DUK_LIKELY(x) __builtin_expect((x), 1) #define DUK_UNLIKELY(x) __builtin_expect((x), 0) #if defined(__clang__) && defined(__has_builtin) #if __has_builtin(__builtin_unpredictable) #define DUK_UNPREDICTABLE(x) __builtin_unpredictable((x)) #endif #endif #if defined(DUK_F_C99) || defined(DUK_F_CPP11) #define DUK_NOINLINE __attribute__((noinline)) #define DUK_INLINE inline #define DUK_ALWAYS_INLINE inline __attribute__((always_inline)) #endif #define DUK_EXTERNAL_DECL __attribute__ ((visibility("default"))) extern #define DUK_EXTERNAL __attribute__ ((visibility("default"))) #if defined(DUK_SINGLE_FILE) #if (defined(DUK_F_GCC_VERSION) && DUK_F_GCC_VERSION >= 30101) || defined(DUK_F_CLANG) /* Minimize warnings for unused internal functions with GCC >= 3.1.1 and * Clang. Based on documentation it should suffice to have the attribute * in the declaration only, but in practice some warnings are generated unless * the attribute is also applied to the definition. */ #define DUK_INTERNAL_DECL static __attribute__ ((unused)) #define DUK_INTERNAL static __attribute__ ((unused)) #else #define DUK_INTERNAL_DECL static #define DUK_INTERNAL static #endif #else #if (defined(DUK_F_GCC_VERSION) && DUK_F_GCC_VERSION >= 30101) || defined(DUK_F_CLANG) #define DUK_INTERNAL_DECL __attribute__ ((visibility("hidden"))) __attribute__ ((unused)) extern #define DUK_INTERNAL __attribute__ ((visibility("hidden"))) __attribute__ ((unused)) #else #define DUK_INTERNAL_DECL __attribute__ ((visibility("hidden"))) extern #define DUK_INTERNAL __attribute__ ((visibility("hidden"))) #endif #endif #define DUK_LOCAL_DECL static #define DUK_LOCAL static #define DUK_USE_COMPILER_STRING "emscripten" #undef DUK_USE_VARIADIC_MACROS #if defined(DUK_F_C99) || defined(DUK_F_CPP11) #define DUK_USE_VARIADIC_MACROS #endif #define DUK_USE_UNION_INITIALIZERS #undef DUK_USE_FLEX_C99 #undef DUK_USE_FLEX_ZEROSIZE #undef DUK_USE_FLEX_ONESIZE #if defined(DUK_F_C99) #define DUK_USE_FLEX_C99 #else #define DUK_USE_FLEX_ZEROSIZE #endif #undef DUK_USE_GCC_PRAGMAS #define DUK_USE_PACK_CLANG_ATTR #elif defined(DUK_F_TINYC) /* --- TinyC --- */ #undef DUK_USE_BRANCH_HINTS #if defined(DUK_F_CPP) #define DUK_USE_COMPILER_STRING "tinyc++" #else #define DUK_USE_COMPILER_STRING "tinyc" #endif /* http://bellard.org/tcc/tcc-doc.html#SEC7 */ #define DUK_USE_VARIADIC_MACROS #define DUK_USE_UNION_INITIALIZERS /* Most portable, wastes space */ #define DUK_USE_FLEX_ONESIZE /* Most portable, potentially wastes space */ #define DUK_USE_PACK_DUMMY_MEMBER #elif defined(DUK_F_VBCC) /* --- VBCC --- */ #undef DUK_USE_BRANCH_HINTS #if defined(DUK_F_CPP) #define DUK_USE_COMPILER_STRING "vbcc-c++" #else #define DUK_USE_COMPILER_STRING "vbcc" #endif #undef DUK_USE_VARIADIC_MACROS #if defined(DUK_F_C99) || defined(DUK_F_CPP11) #define DUK_USE_VARIADIC_MACROS #endif /* VBCC supports C99 so check only for C99 for union initializer support. * Designated union initializers would possibly work even without a C99 check. */ #undef DUK_USE_UNION_INITIALIZERS #if defined(DUK_F_C99) #define DUK_USE_UNION_INITIALIZERS #endif #define DUK_USE_FLEX_ZEROSIZE #define DUK_USE_PACK_DUMMY_MEMBER #elif defined(DUK_F_BCC) /* --- Bruce's C compiler --- */ #undef DUK_USE_BRANCH_HINTS #if defined(DUK_F_CPP) #define DUK_USE_COMPILER_STRING "bcc++" #else #define DUK_USE_COMPILER_STRING "bcc" #endif /* Most portable */ #undef DUK_USE_VARIADIC_MACROS /* Most portable, wastes space */ #undef DUK_USE_UNION_INITIALIZERS /* Most portable, wastes space */ #define DUK_USE_FLEX_ONESIZE /* Most portable, potentially wastes space */ #define DUK_USE_PACK_DUMMY_MEMBER /* BCC, assume we're on x86. */ #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 1 #endif #else /* --- Generic --- */ #undef DUK_USE_BRANCH_HINTS #if defined(DUK_F_CPP) #define DUK_USE_COMPILER_STRING "generic-c++" #else #define DUK_USE_COMPILER_STRING "generic" #endif #undef DUK_USE_VARIADIC_MACROS #if defined(DUK_F_C99) || defined(DUK_F_CPP11) #define DUK_USE_VARIADIC_MACROS #endif /* C++ doesn't have standard designated union initializers ({ .foo = 1 }). */ #undef DUK_USE_UNION_INITIALIZERS #if defined(DUK_F_C99) #define DUK_USE_UNION_INITIALIZERS #endif /* Most portable, wastes space */ #define DUK_USE_FLEX_ONESIZE /* Most portable, potentially wastes space */ #define DUK_USE_PACK_DUMMY_MEMBER #endif /* autodetect compiler */ /* uclibc */ #if defined(__UCLIBC__) #define DUK_F_UCLIBC #endif /* * Wrapper typedefs and constants for integer types, also sanity check types. * * C99 typedefs are quite good but not always available, and we want to avoid * forcibly redefining the C99 typedefs. So, there are Duktape wrappers for * all C99 typedefs and Duktape code should only use these typedefs. Type * detection when C99 is not supported is best effort and may end up detecting * some types incorrectly. * * Pointer sizes are a portability problem: pointers to different types may * have a different size and function pointers are very difficult to manage * portably. * * http://en.wikipedia.org/wiki/C_data_types#Fixed-width_integer_types * * Note: there's an interesting corner case when trying to define minimum * signed integer value constants which leads to the current workaround of * defining e.g. -0x80000000 as (-0x7fffffffL - 1L). See doc/code-issues.txt * for a longer discussion. * * Note: avoid typecasts and computations in macro integer constants as they * can then no longer be used in macro relational expressions (such as * #if DUK_SIZE_MAX < 0xffffffffUL). There is internal code which relies on * being able to compare DUK_SIZE_MAX against a limit. */ /* XXX: add feature options to force basic types from outside? */ #if !defined(INT_MAX) #error INT_MAX not defined #endif /* Check that architecture is two's complement, standard C allows e.g. * INT_MIN to be -2**31+1 (instead of -2**31). */ #if defined(INT_MAX) && defined(INT_MIN) #if INT_MAX != -(INT_MIN + 1) #error platform does not seem complement of two #endif #else #error cannot check complement of two #endif /* Pointer size determination based on __WORDSIZE or architecture when * that's not available. */ #if defined(DUK_F_X86) || defined(DUK_F_X32) || \ defined(DUK_F_M68K) || defined(DUK_F_PPC32) || \ defined(DUK_F_BCC) || \ (defined(__WORDSIZE) && (__WORDSIZE == 32)) || \ ((defined(DUK_F_OLD_SOLARIS) || defined(DUK_F_AIX) || \ defined(DUK_F_HPUX)) && defined(_ILP32)) || \ defined(DUK_F_ARM32) #define DUK_F_32BIT_PTRS #elif defined(DUK_F_X64) || \ (defined(__WORDSIZE) && (__WORDSIZE == 64)) || \ ((defined(DUK_F_OLD_SOLARIS) || defined(DUK_F_AIX) || \ defined(DUK_F_HPUX)) && defined(_LP64)) || \ defined(DUK_F_ARM64) #define DUK_F_64BIT_PTRS #else /* not sure, not needed with C99 anyway */ #endif /* Intermediate define for 'have inttypes.h' */ #undef DUK_F_HAVE_INTTYPES #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \ !(defined(DUK_F_AMIGAOS) && defined(DUK_F_VBCC)) /* vbcc + AmigaOS has C99 but no inttypes.h */ #define DUK_F_HAVE_INTTYPES #elif defined(__cplusplus) && (__cplusplus >= 201103L) /* C++11 apparently ratified stdint.h */ #define DUK_F_HAVE_INTTYPES #endif /* Basic integer typedefs and limits, preferably from inttypes.h, otherwise * through automatic detection. */ #if defined(DUK_F_HAVE_INTTYPES) /* C99 or compatible */ #define DUK_F_HAVE_64BIT #include <inttypes.h> typedef uint8_t duk_uint8_t; typedef int8_t duk_int8_t; typedef uint16_t duk_uint16_t; typedef int16_t duk_int16_t; typedef uint32_t duk_uint32_t; typedef int32_t duk_int32_t; typedef uint64_t duk_uint64_t; typedef int64_t duk_int64_t; typedef uint_least8_t duk_uint_least8_t; typedef int_least8_t duk_int_least8_t; typedef uint_least16_t duk_uint_least16_t; typedef int_least16_t duk_int_least16_t; typedef uint_least32_t duk_uint_least32_t; typedef int_least32_t duk_int_least32_t; typedef uint_least64_t duk_uint_least64_t; typedef int_least64_t duk_int_least64_t; typedef uint_fast8_t duk_uint_fast8_t; typedef int_fast8_t duk_int_fast8_t; typedef uint_fast16_t duk_uint_fast16_t; typedef int_fast16_t duk_int_fast16_t; typedef uint_fast32_t duk_uint_fast32_t; typedef int_fast32_t duk_int_fast32_t; typedef uint_fast64_t duk_uint_fast64_t; typedef int_fast64_t duk_int_fast64_t; typedef uintptr_t duk_uintptr_t; typedef intptr_t duk_intptr_t; typedef uintmax_t duk_uintmax_t; typedef intmax_t duk_intmax_t; #define DUK_UINT8_MIN 0 #define DUK_UINT8_MAX UINT8_MAX #define DUK_INT8_MIN INT8_MIN #define DUK_INT8_MAX INT8_MAX #define DUK_UINT_LEAST8_MIN 0 #define DUK_UINT_LEAST8_MAX UINT_LEAST8_MAX #define DUK_INT_LEAST8_MIN INT_LEAST8_MIN #define DUK_INT_LEAST8_MAX INT_LEAST8_MAX #define DUK_UINT_FAST8_MIN 0 #define DUK_UINT_FAST8_MAX UINT_FAST8_MAX #define DUK_INT_FAST8_MIN INT_FAST8_MIN #define DUK_INT_FAST8_MAX INT_FAST8_MAX #define DUK_UINT16_MIN 0 #define DUK_UINT16_MAX UINT16_MAX #define DUK_INT16_MIN INT16_MIN #define DUK_INT16_MAX INT16_MAX #define DUK_UINT_LEAST16_MIN 0 #define DUK_UINT_LEAST16_MAX UINT_LEAST16_MAX #define DUK_INT_LEAST16_MIN INT_LEAST16_MIN #define DUK_INT_LEAST16_MAX INT_LEAST16_MAX #define DUK_UINT_FAST16_MIN 0 #define DUK_UINT_FAST16_MAX UINT_FAST16_MAX #define DUK_INT_FAST16_MIN INT_FAST16_MIN #define DUK_INT_FAST16_MAX INT_FAST16_MAX #define DUK_UINT32_MIN 0 #define DUK_UINT32_MAX UINT32_MAX #define DUK_INT32_MIN INT32_MIN #define DUK_INT32_MAX INT32_MAX #define DUK_UINT_LEAST32_MIN 0 #define DUK_UINT_LEAST32_MAX UINT_LEAST32_MAX #define DUK_INT_LEAST32_MIN INT_LEAST32_MIN #define DUK_INT_LEAST32_MAX INT_LEAST32_MAX #define DUK_UINT_FAST32_MIN 0 #define DUK_UINT_FAST32_MAX UINT_FAST32_MAX #define DUK_INT_FAST32_MIN INT_FAST32_MIN #define DUK_INT_FAST32_MAX INT_FAST32_MAX #define DUK_UINT64_MIN 0 #define DUK_UINT64_MAX UINT64_MAX #define DUK_INT64_MIN INT64_MIN #define DUK_INT64_MAX INT64_MAX #define DUK_UINT_LEAST64_MIN 0 #define DUK_UINT_LEAST64_MAX UINT_LEAST64_MAX #define DUK_INT_LEAST64_MIN INT_LEAST64_MIN #define DUK_INT_LEAST64_MAX INT_LEAST64_MAX #define DUK_UINT_FAST64_MIN 0 #define DUK_UINT_FAST64_MAX UINT_FAST64_MAX #define DUK_INT_FAST64_MIN INT_FAST64_MIN #define DUK_INT_FAST64_MAX INT_FAST64_MAX #define DUK_UINTPTR_MIN 0 #define DUK_UINTPTR_MAX UINTPTR_MAX #define DUK_INTPTR_MIN INTPTR_MIN #define DUK_INTPTR_MAX INTPTR_MAX #define DUK_UINTMAX_MIN 0 #define DUK_UINTMAX_MAX UINTMAX_MAX #define DUK_INTMAX_MIN INTMAX_MIN #define DUK_INTMAX_MAX INTMAX_MAX #define DUK_SIZE_MIN 0 #define DUK_SIZE_MAX SIZE_MAX #undef DUK_SIZE_MAX_COMPUTED #else /* C99 types */ /* When C99 types are not available, we use heuristic detection to get * the basic 8, 16, 32, and (possibly) 64 bit types. The fast/least * types are then assumed to be exactly the same for now: these could * be improved per platform but C99 types are very often now available. * 64-bit types are not available on all platforms; this is OK at least * on 32-bit platforms. * * This detection code is necessarily a bit hacky and can provide typedefs * and defines that won't work correctly on some exotic platform. */ #if (defined(CHAR_BIT) && (CHAR_BIT == 8)) || \ (defined(UCHAR_MAX) && (UCHAR_MAX == 255)) typedef unsigned char duk_uint8_t; typedef signed char duk_int8_t; #else #error cannot detect 8-bit type #endif #if defined(USHRT_MAX) && (USHRT_MAX == 65535UL) typedef unsigned short duk_uint16_t; typedef signed short duk_int16_t; #elif defined(UINT_MAX) && (UINT_MAX == 65535UL) /* On some platforms int is 16-bit but long is 32-bit (e.g. PureC) */ typedef unsigned int duk_uint16_t; typedef signed int duk_int16_t; #else #error cannot detect 16-bit type #endif #if defined(UINT_MAX) && (UINT_MAX == 4294967295UL) typedef unsigned int duk_uint32_t; typedef signed int duk_int32_t; #elif defined(ULONG_MAX) && (ULONG_MAX == 4294967295UL) /* On some platforms int is 16-bit but long is 32-bit (e.g. PureC) */ typedef unsigned long duk_uint32_t; typedef signed long duk_int32_t; #else #error cannot detect 32-bit type #endif /* 64-bit type detection is a bit tricky. * * ULLONG_MAX is a standard define. __LONG_LONG_MAX__ and __ULONG_LONG_MAX__ * are used by at least GCC (even if system headers don't provide ULLONG_MAX). * Some GCC variants may provide __LONG_LONG_MAX__ but not __ULONG_LONG_MAX__. * * ULL / LL constants are rejected / warned about by some compilers, even if * the compiler has a 64-bit type and the compiler/system headers provide an * unsupported constant (ULL/LL)! Try to avoid using ULL / LL constants. * As a side effect we can only check that e.g. ULONG_MAX is larger than 32 * bits but can't be sure it is exactly 64 bits. Self tests will catch such * cases. */ #undef DUK_F_HAVE_64BIT #if !defined(DUK_F_HAVE_64BIT) && defined(ULONG_MAX) #if (ULONG_MAX > 4294967295UL) #define DUK_F_HAVE_64BIT typedef unsigned long duk_uint64_t; typedef signed long duk_int64_t; #endif #endif #if !defined(DUK_F_HAVE_64BIT) && defined(ULLONG_MAX) #if (ULLONG_MAX > 4294967295UL) #define DUK_F_HAVE_64BIT typedef unsigned long long duk_uint64_t; typedef signed long long duk_int64_t; #endif #endif #if !defined(DUK_F_HAVE_64BIT) && defined(__ULONG_LONG_MAX__) #if (__ULONG_LONG_MAX__ > 4294967295UL) #define DUK_F_HAVE_64BIT typedef unsigned long long duk_uint64_t; typedef signed long long duk_int64_t; #endif #endif #if !defined(DUK_F_HAVE_64BIT) && defined(__LONG_LONG_MAX__) #if (__LONG_LONG_MAX__ > 2147483647L) #define DUK_F_HAVE_64BIT typedef unsigned long long duk_uint64_t; typedef signed long long duk_int64_t; #endif #endif #if !defined(DUK_F_HAVE_64BIT) && defined(DUK_F_MINGW) #define DUK_F_HAVE_64BIT typedef unsigned long duk_uint64_t; typedef signed long duk_int64_t; #endif #if !defined(DUK_F_HAVE_64BIT) && defined(DUK_F_MSVC) #define DUK_F_HAVE_64BIT typedef unsigned __int64 duk_uint64_t; typedef signed __int64 duk_int64_t; #endif #if !defined(DUK_F_HAVE_64BIT) /* cannot detect 64-bit type, not always needed so don't error */ #endif typedef duk_uint8_t duk_uint_least8_t; typedef duk_int8_t duk_int_least8_t; typedef duk_uint16_t duk_uint_least16_t; typedef duk_int16_t duk_int_least16_t; typedef duk_uint32_t duk_uint_least32_t; typedef duk_int32_t duk_int_least32_t; typedef duk_uint8_t duk_uint_fast8_t; typedef duk_int8_t duk_int_fast8_t; typedef duk_uint16_t duk_uint_fast16_t; typedef duk_int16_t duk_int_fast16_t; typedef duk_uint32_t duk_uint_fast32_t; typedef duk_int32_t duk_int_fast32_t; #if defined(DUK_F_HAVE_64BIT) typedef duk_uint64_t duk_uint_least64_t; typedef duk_int64_t duk_int_least64_t; typedef duk_uint64_t duk_uint_fast64_t; typedef duk_int64_t duk_int_fast64_t; #endif #if defined(DUK_F_HAVE_64BIT) typedef duk_uint64_t duk_uintmax_t; typedef duk_int64_t duk_intmax_t; #else typedef duk_uint32_t duk_uintmax_t; typedef duk_int32_t duk_intmax_t; #endif /* Note: the funny looking computations for signed minimum 16-bit, 32-bit, and * 64-bit values are intentional as the obvious forms (e.g. -0x80000000L) are * -not- portable. See code-issues.txt for a detailed discussion. */ #define DUK_UINT8_MIN 0UL #define DUK_UINT8_MAX 0xffUL #define DUK_INT8_MIN (-0x80L) #define DUK_INT8_MAX 0x7fL #define DUK_UINT_LEAST8_MIN 0UL #define DUK_UINT_LEAST8_MAX 0xffUL #define DUK_INT_LEAST8_MIN (-0x80L) #define DUK_INT_LEAST8_MAX 0x7fL #define DUK_UINT_FAST8_MIN 0UL #define DUK_UINT_FAST8_MAX 0xffUL #define DUK_INT_FAST8_MIN (-0x80L) #define DUK_INT_FAST8_MAX 0x7fL #define DUK_UINT16_MIN 0UL #define DUK_UINT16_MAX 0xffffUL #define DUK_INT16_MIN (-0x7fffL - 1L) #define DUK_INT16_MAX 0x7fffL #define DUK_UINT_LEAST16_MIN 0UL #define DUK_UINT_LEAST16_MAX 0xffffUL #define DUK_INT_LEAST16_MIN (-0x7fffL - 1L) #define DUK_INT_LEAST16_MAX 0x7fffL #define DUK_UINT_FAST16_MIN 0UL #define DUK_UINT_FAST16_MAX 0xffffUL #define DUK_INT_FAST16_MIN (-0x7fffL - 1L) #define DUK_INT_FAST16_MAX 0x7fffL #define DUK_UINT32_MIN 0UL #define DUK_UINT32_MAX 0xffffffffUL #define DUK_INT32_MIN (-0x7fffffffL - 1L) #define DUK_INT32_MAX 0x7fffffffL #define DUK_UINT_LEAST32_MIN 0UL #define DUK_UINT_LEAST32_MAX 0xffffffffUL #define DUK_INT_LEAST32_MIN (-0x7fffffffL - 1L) #define DUK_INT_LEAST32_MAX 0x7fffffffL #define DUK_UINT_FAST32_MIN 0UL #define DUK_UINT_FAST32_MAX 0xffffffffUL #define DUK_INT_FAST32_MIN (-0x7fffffffL - 1L) #define DUK_INT_FAST32_MAX 0x7fffffffL /* 64-bit constants. Since LL / ULL constants are not always available, * use computed values. These values can't be used in preprocessor * comparisons; flag them as such. */ #if defined(DUK_F_HAVE_64BIT) #define DUK_UINT64_MIN ((duk_uint64_t) 0) #define DUK_UINT64_MAX ((duk_uint64_t) -1) #define DUK_INT64_MIN ((duk_int64_t) (~(DUK_UINT64_MAX >> 1))) #define DUK_INT64_MAX ((duk_int64_t) (DUK_UINT64_MAX >> 1)) #define DUK_UINT_LEAST64_MIN DUK_UINT64_MIN #define DUK_UINT_LEAST64_MAX DUK_UINT64_MAX #define DUK_INT_LEAST64_MIN DUK_INT64_MIN #define DUK_INT_LEAST64_MAX DUK_INT64_MAX #define DUK_UINT_FAST64_MIN DUK_UINT64_MIN #define DUK_UINT_FAST64_MAX DUK_UINT64_MAX #define DUK_INT_FAST64_MIN DUK_INT64_MIN #define DUK_INT_FAST64_MAX DUK_INT64_MAX #define DUK_UINT64_MIN_COMPUTED #define DUK_UINT64_MAX_COMPUTED #define DUK_INT64_MIN_COMPUTED #define DUK_INT64_MAX_COMPUTED #define DUK_UINT_LEAST64_MIN_COMPUTED #define DUK_UINT_LEAST64_MAX_COMPUTED #define DUK_INT_LEAST64_MIN_COMPUTED #define DUK_INT_LEAST64_MAX_COMPUTED #define DUK_UINT_FAST64_MIN_COMPUTED #define DUK_UINT_FAST64_MAX_COMPUTED #define DUK_INT_FAST64_MIN_COMPUTED #define DUK_INT_FAST64_MAX_COMPUTED #endif #if defined(DUK_F_HAVE_64BIT) #define DUK_UINTMAX_MIN DUK_UINT64_MIN #define DUK_UINTMAX_MAX DUK_UINT64_MAX #define DUK_INTMAX_MIN DUK_INT64_MIN #define DUK_INTMAX_MAX DUK_INT64_MAX #define DUK_UINTMAX_MIN_COMPUTED #define DUK_UINTMAX_MAX_COMPUTED #define DUK_INTMAX_MIN_COMPUTED #define DUK_INTMAX_MAX_COMPUTED #else #define DUK_UINTMAX_MIN 0UL #define DUK_UINTMAX_MAX 0xffffffffUL #define DUK_INTMAX_MIN (-0x7fffffffL - 1L) #define DUK_INTMAX_MAX 0x7fffffffL #endif /* This detection is not very reliable. */ #if defined(DUK_F_32BIT_PTRS) typedef duk_int32_t duk_intptr_t; typedef duk_uint32_t duk_uintptr_t; #define DUK_UINTPTR_MIN DUK_UINT32_MIN #define DUK_UINTPTR_MAX DUK_UINT32_MAX #define DUK_INTPTR_MIN DUK_INT32_MIN #define DUK_INTPTR_MAX DUK_INT32_MAX #elif defined(DUK_F_64BIT_PTRS) && defined(DUK_F_HAVE_64BIT) typedef duk_int64_t duk_intptr_t; typedef duk_uint64_t duk_uintptr_t; #define DUK_UINTPTR_MIN DUK_UINT64_MIN #define DUK_UINTPTR_MAX DUK_UINT64_MAX #define DUK_INTPTR_MIN DUK_INT64_MIN #define DUK_INTPTR_MAX DUK_INT64_MAX #define DUK_UINTPTR_MIN_COMPUTED #define DUK_UINTPTR_MAX_COMPUTED #define DUK_INTPTR_MIN_COMPUTED #define DUK_INTPTR_MAX_COMPUTED #else #error cannot determine intptr type #endif /* SIZE_MAX may be missing so use an approximate value for it. */ #undef DUK_SIZE_MAX_COMPUTED #if !defined(SIZE_MAX) #define DUK_SIZE_MAX_COMPUTED #define SIZE_MAX ((size_t) (-1)) #endif #define DUK_SIZE_MIN 0 #define DUK_SIZE_MAX SIZE_MAX #endif /* C99 types */ /* A few types are assumed to always exist. */ typedef size_t duk_size_t; typedef ptrdiff_t duk_ptrdiff_t; /* The best type for an "all around int" in Duktape internals is "at least * 32 bit signed integer" which is most convenient. Same for unsigned type. * Prefer 'int' when large enough, as it is almost always a convenient type. */ #if defined(UINT_MAX) && (UINT_MAX >= 0xffffffffUL) typedef int duk_int_t; typedef unsigned int duk_uint_t; #define DUK_INT_MIN INT_MIN #define DUK_INT_MAX INT_MAX #define DUK_UINT_MIN 0 #define DUK_UINT_MAX UINT_MAX #else typedef duk_int_fast32_t duk_int_t; typedef duk_uint_fast32_t duk_uint_t; #define DUK_INT_MIN DUK_INT_FAST32_MIN #define DUK_INT_MAX DUK_INT_FAST32_MAX #define DUK_UINT_MIN DUK_UINT_FAST32_MIN #define DUK_UINT_MAX DUK_UINT_FAST32_MAX #endif /* Same as 'duk_int_t' but guaranteed to be a 'fast' variant if this * distinction matters for the CPU. These types are used mainly in the * executor where it might really matter. */ typedef duk_int_fast32_t duk_int_fast_t; typedef duk_uint_fast32_t duk_uint_fast_t; #define DUK_INT_FAST_MIN DUK_INT_FAST32_MIN #define DUK_INT_FAST_MAX DUK_INT_FAST32_MAX #define DUK_UINT_FAST_MIN DUK_UINT_FAST32_MIN #define DUK_UINT_FAST_MAX DUK_UINT_FAST32_MAX /* Small integers (16 bits or more) can fall back to the 'int' type, but * have a typedef so they are marked "small" explicitly. */ typedef int duk_small_int_t; typedef unsigned int duk_small_uint_t; #define DUK_SMALL_INT_MIN INT_MIN #define DUK_SMALL_INT_MAX INT_MAX #define DUK_SMALL_UINT_MIN 0 #define DUK_SMALL_UINT_MAX UINT_MAX /* Fast variants of small integers, again for really fast paths like the * executor. */ typedef duk_int_fast16_t duk_small_int_fast_t; typedef duk_uint_fast16_t duk_small_uint_fast_t; #define DUK_SMALL_INT_FAST_MIN DUK_INT_FAST16_MIN #define DUK_SMALL_INT_FAST_MAX DUK_INT_FAST16_MAX #define DUK_SMALL_UINT_FAST_MIN DUK_UINT_FAST16_MIN #define DUK_SMALL_UINT_FAST_MAX DUK_UINT_FAST16_MAX /* Boolean values are represented with the platform 'unsigned int'. */ typedef duk_small_uint_t duk_bool_t; #define DUK_BOOL_MIN DUK_SMALL_UINT_MIN #define DUK_BOOL_MAX DUK_SMALL_UINT_MAX /* Index values must have at least 32-bit signed range. */ typedef duk_int_t duk_idx_t; #define DUK_IDX_MIN DUK_INT_MIN #define DUK_IDX_MAX DUK_INT_MAX /* Unsigned index variant. */ typedef duk_uint_t duk_uidx_t; #define DUK_UIDX_MIN DUK_UINT_MIN #define DUK_UIDX_MAX DUK_UINT_MAX /* Array index values, could be exact 32 bits. * Currently no need for signed duk_arridx_t. */ typedef duk_uint_t duk_uarridx_t; #define DUK_UARRIDX_MIN DUK_UINT_MIN #define DUK_UARRIDX_MAX DUK_UINT_MAX /* Duktape/C function return value, platform int is enough for now to * represent 0, 1, or negative error code. Must be compatible with * assigning truth values (e.g. duk_ret_t rc = (foo == bar);). */ typedef duk_small_int_t duk_ret_t; #define DUK_RET_MIN DUK_SMALL_INT_MIN #define DUK_RET_MAX DUK_SMALL_INT_MAX /* Error codes are represented with platform int. High bits are used * for flags and such, so 32 bits are needed. */ typedef duk_int_t duk_errcode_t; #define DUK_ERRCODE_MIN DUK_INT_MIN #define DUK_ERRCODE_MAX DUK_INT_MAX /* Codepoint type. Must be 32 bits or more because it is used also for * internal codepoints. The type is signed because negative codepoints * are used as internal markers (e.g. to mark EOF or missing argument). * (X)UTF-8/CESU-8 encode/decode take and return an unsigned variant to * ensure duk_uint32_t casts back and forth nicely. Almost everything * else uses the signed one. */ typedef duk_int_t duk_codepoint_t; typedef duk_uint_t duk_ucodepoint_t; #define DUK_CODEPOINT_MIN DUK_INT_MIN #define DUK_CODEPOINT_MAX DUK_INT_MAX #define DUK_UCODEPOINT_MIN DUK_UINT_MIN #define DUK_UCODEPOINT_MAX DUK_UINT_MAX /* IEEE float/double typedef. */ typedef float duk_float_t; typedef double duk_double_t; /* We're generally assuming that we're working on a platform with a 32-bit * address space. If DUK_SIZE_MAX is a typecast value (which is necessary * if SIZE_MAX is missing), the check must be avoided because the * preprocessor can't do a comparison. */ #if !defined(DUK_SIZE_MAX) #error DUK_SIZE_MAX is undefined, probably missing SIZE_MAX #elif !defined(DUK_SIZE_MAX_COMPUTED) #if DUK_SIZE_MAX < 0xffffffffUL /* On some systems SIZE_MAX can be smaller than max unsigned 32-bit value * which seems incorrect if size_t is (at least) an unsigned 32-bit type. * However, it doesn't seem useful to error out compilation if this is the * case. */ #endif #endif /* Type used in public API declarations and user code. Typedef maps to * 'struct duk_hthread' like the 'duk_hthread' typedef which is used * exclusively in internals. */ typedef struct duk_hthread duk_context; /* Check whether we should use 64-bit integers or not. * * Quite incomplete now. Use 64-bit types if detected (C99 or other detection) * unless they are known to be unreliable. For instance, 64-bit types are * available on VBCC but seem to misbehave. */ #if defined(DUK_F_HAVE_64BIT) && !defined(DUK_F_VBCC) #define DUK_USE_64BIT_OPS #else #undef DUK_USE_64BIT_OPS #endif /* * Fill-ins for platform, architecture, and compiler */ /* An abort()-like primitive is needed by the default fatal error handler. */ #if !defined(DUK_ABORT) #define DUK_ABORT abort #endif #if !defined(DUK_SETJMP) #define DUK_JMPBUF_TYPE jmp_buf #define DUK_SETJMP(jb) setjmp((jb)) #define DUK_LONGJMP(jb) longjmp((jb), 1) #endif #if 0 /* sigsetjmp() alternative */ #define DUK_JMPBUF_TYPE sigjmp_buf #define DUK_SETJMP(jb) sigsetjmp((jb)) #define DUK_LONGJMP(jb) siglongjmp((jb), 1) #endif /* Special naming to avoid conflict with e.g. DUK_FREE() in duk_heap.h * (which is unfortunately named). May sometimes need replacement, e.g. * some compilers don't handle zero length or NULL correctly in realloc(). */ #if !defined(DUK_ANSI_MALLOC) #define DUK_ANSI_MALLOC malloc #endif #if !defined(DUK_ANSI_REALLOC) #define DUK_ANSI_REALLOC realloc #endif #if !defined(DUK_ANSI_CALLOC) #define DUK_ANSI_CALLOC calloc #endif #if !defined(DUK_ANSI_FREE) #define DUK_ANSI_FREE free #endif /* ANSI C (various versions) and some implementations require that the * pointer arguments to memset(), memcpy(), and memmove() be valid values * even when byte size is 0 (even a NULL pointer is considered invalid in * this context). Zero-size operations as such are allowed, as long as their * pointer arguments point to a valid memory area. The DUK_MEMSET(), * DUK_MEMCPY(), and DUK_MEMMOVE() macros require this same behavior, i.e.: * (1) pointers must be valid and non-NULL, (2) zero size must otherwise be * allowed. If these are not fulfilled, a macro wrapper is needed. * * http://stackoverflow.com/questions/5243012/is-it-guaranteed-to-be-safe-to-perform-memcpy0-0-0 * http://lists.cs.uiuc.edu/pipermail/llvmdev/2007-October/011065.html * * Not sure what's the required behavior when a pointer points just past the * end of a buffer, which often happens in practice (e.g. zero size memmoves). * For example, if allocation size is 3, the following pointer would not * technically point to a valid memory byte: * * <-- alloc --> * | 0 | 1 | 2 | ..... * ^-- p=3, points after last valid byte (2) */ #if !defined(DUK_MEMCPY) #if defined(DUK_F_UCLIBC) /* Old uclibcs have a broken memcpy so use memmove instead (this is overly wide * now on purpose): http://lists.uclibc.org/pipermail/uclibc-cvs/2008-October/025511.html */ #define DUK_MEMCPY memmove #else #define DUK_MEMCPY memcpy #endif #endif #if !defined(DUK_MEMMOVE) #define DUK_MEMMOVE memmove #endif #if !defined(DUK_MEMCMP) #define DUK_MEMCMP memcmp #endif #if !defined(DUK_MEMSET) #define DUK_MEMSET memset #endif #if !defined(DUK_STRLEN) #define DUK_STRLEN strlen #endif #if !defined(DUK_STRCMP) #define DUK_STRCMP strcmp #endif #if !defined(DUK_STRNCMP) #define DUK_STRNCMP strncmp #endif #if !defined(DUK_SPRINTF) #define DUK_SPRINTF sprintf #endif #if !defined(DUK_SNPRINTF) /* snprintf() is technically not part of C89 but usually available. */ #define DUK_SNPRINTF snprintf #endif #if !defined(DUK_VSPRINTF) #define DUK_VSPRINTF vsprintf #endif #if !defined(DUK_VSNPRINTF) /* vsnprintf() is technically not part of C89 but usually available. */ #define DUK_VSNPRINTF vsnprintf #endif #if !defined(DUK_SSCANF) #define DUK_SSCANF sscanf #endif #if !defined(DUK_VSSCANF) #define DUK_VSSCANF vsscanf #endif #if !defined(DUK_MEMZERO) #define DUK_MEMZERO(p,n) DUK_MEMSET((p), 0, (n)) #endif #if !defined(DUK_DOUBLE_INFINITY) #undef DUK_USE_COMPUTED_INFINITY #if defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION < 40600) /* GCC older than 4.6: avoid overflow warnings related to using INFINITY */ #define DUK_DOUBLE_INFINITY (__builtin_inf()) #elif defined(INFINITY) #define DUK_DOUBLE_INFINITY ((double) INFINITY) #elif !defined(DUK_F_VBCC) && !defined(DUK_F_MSVC) && !defined(DUK_F_BCC) && \ !defined(DUK_F_OLD_SOLARIS) && !defined(DUK_F_AIX) #define DUK_DOUBLE_INFINITY (1.0 / 0.0) #else /* In VBCC (1.0 / 0.0) results in a warning and 0.0 instead of infinity. * Use a computed infinity (initialized when a heap is created at the * latest). */ #define DUK_USE_COMPUTED_INFINITY #define DUK_DOUBLE_INFINITY duk_computed_infinity #endif #endif #if !defined(DUK_DOUBLE_NAN) #undef DUK_USE_COMPUTED_NAN #if defined(NAN) #define DUK_DOUBLE_NAN NAN #elif !defined(DUK_F_VBCC) && !defined(DUK_F_MSVC) && !defined(DUK_F_BCC) && \ !defined(DUK_F_OLD_SOLARIS) && !defined(DUK_F_AIX) #define DUK_DOUBLE_NAN (0.0 / 0.0) #else /* In VBCC (0.0 / 0.0) results in a warning and 0.0 instead of NaN. * In MSVC (VS2010 Express) (0.0 / 0.0) results in a compile error. * Use a computed NaN (initialized when a heap is created at the * latest). */ #define DUK_USE_COMPUTED_NAN #define DUK_DOUBLE_NAN duk_computed_nan #endif #endif /* Many platforms are missing fpclassify() and friends, so use replacements * if necessary. The replacement constants (FP_NAN etc) can be anything but * match Linux constants now. */ #undef DUK_USE_REPL_FPCLASSIFY #undef DUK_USE_REPL_SIGNBIT #undef DUK_USE_REPL_ISFINITE #undef DUK_USE_REPL_ISNAN #undef DUK_USE_REPL_ISINF /* Complex condition broken into separate parts. */ #undef DUK_F_USE_REPL_ALL #if !(defined(FP_NAN) && defined(FP_INFINITE) && defined(FP_ZERO) && \ defined(FP_SUBNORMAL) && defined(FP_NORMAL)) /* Missing some obvious constants. */ #define DUK_F_USE_REPL_ALL #elif defined(DUK_F_AMIGAOS) && defined(DUK_F_VBCC) /* VBCC is missing the built-ins even in C99 mode (perhaps a header issue). */ #define DUK_F_USE_REPL_ALL #elif defined(DUK_F_AMIGAOS) && defined(DUK_F_M68K) /* AmigaOS + M68K seems to have math issues even when using GCC cross * compilation. Use replacements for all AmigaOS versions on M68K * regardless of compiler. */ #define DUK_F_USE_REPL_ALL #elif defined(DUK_F_FREEBSD) && defined(DUK_F_CLANG) /* Placeholder fix for (detection is wider than necessary): * http://llvm.org/bugs/show_bug.cgi?id=17788 */ #define DUK_F_USE_REPL_ALL #elif defined(DUK_F_UCLIBC) /* At least some uclibc versions have broken floating point math. For * example, fpclassify() can incorrectly classify certain NaN formats. * To be safe, use replacements. */ #define DUK_F_USE_REPL_ALL #elif defined(DUK_F_AIX) /* Older versions may be missing isnan(), etc. */ #define DUK_F_USE_REPL_ALL #endif #if defined(DUK_F_USE_REPL_ALL) #define DUK_USE_REPL_FPCLASSIFY #define DUK_USE_REPL_SIGNBIT #define DUK_USE_REPL_ISFINITE #define DUK_USE_REPL_ISNAN #define DUK_USE_REPL_ISINF #define DUK_FPCLASSIFY duk_repl_fpclassify #define DUK_SIGNBIT duk_repl_signbit #define DUK_ISFINITE duk_repl_isfinite #define DUK_ISNAN duk_repl_isnan #define DUK_ISINF duk_repl_isinf #define DUK_FP_NAN 0 #define DUK_FP_INFINITE 1 #define DUK_FP_ZERO 2 #define DUK_FP_SUBNORMAL 3 #define DUK_FP_NORMAL 4 #else #define DUK_FPCLASSIFY fpclassify #define DUK_SIGNBIT signbit #define DUK_ISFINITE isfinite #define DUK_ISNAN isnan #define DUK_ISINF isinf #define DUK_FP_NAN FP_NAN #define DUK_FP_INFINITE FP_INFINITE #define DUK_FP_ZERO FP_ZERO #define DUK_FP_SUBNORMAL FP_SUBNORMAL #define DUK_FP_NORMAL FP_NORMAL #endif #if defined(DUK_F_USE_REPL_ALL) #undef DUK_F_USE_REPL_ALL #endif /* These functions don't currently need replacement but are wrapped for * completeness. Because these are used as function pointers, they need * to be defined as concrete C functions (not macros). */ #if !defined(DUK_FABS) #define DUK_FABS fabs #endif #if !defined(DUK_FLOOR) #define DUK_FLOOR floor #endif #if !defined(DUK_CEIL) #define DUK_CEIL ceil #endif #if !defined(DUK_FMOD) #define DUK_FMOD fmod #endif #if !defined(DUK_POW) #define DUK_POW pow #endif #if !defined(DUK_ACOS) #define DUK_ACOS acos #endif #if !defined(DUK_ASIN) #define DUK_ASIN asin #endif #if !defined(DUK_ATAN) #define DUK_ATAN atan #endif #if !defined(DUK_ATAN2) #define DUK_ATAN2 atan2 #endif #if !defined(DUK_SIN) #define DUK_SIN sin #endif #if !defined(DUK_COS) #define DUK_COS cos #endif #if !defined(DUK_TAN) #define DUK_TAN tan #endif #if !defined(DUK_EXP) #define DUK_EXP exp #endif #if !defined(DUK_LOG) #define DUK_LOG log #endif #if !defined(DUK_SQRT) #define DUK_SQRT sqrt #endif /* The functions below exist only in C99/C++11 or later and need a workaround * for platforms that don't include them. MSVC isn't detected as C99, but * these functions also exist in MSVC 2013 and later so include a clause for * that too. Android doesn't have log2; disable all of these for Android. */ #if (defined(DUK_F_C99) || defined(DUK_F_CPP11) || (defined(_MSC_VER) && (_MSC_VER >= 1800))) && \ !defined(DUK_F_ANDROID) && !defined(DUK_F_MINT) #if !defined(DUK_CBRT) #define DUK_CBRT cbrt #endif #if !defined(DUK_LOG2) #define DUK_LOG2 log2 #endif #if !defined(DUK_LOG10) #define DUK_LOG10 log10 #endif #if !defined(DUK_TRUNC) #define DUK_TRUNC trunc #endif #endif /* DUK_F_C99 etc */ /* NetBSD 6.0 x86 (at least) has a few problems with pow() semantics, * see test-bug-netbsd-math-pow.js. MinGW has similar (but different) * issues, see test-bug-mingw-math-issues.js. Enable pow() workarounds * for these targets. */ #undef DUK_USE_POW_WORKAROUNDS #if defined(DUK_F_NETBSD) || defined(DUK_F_MINGW) #define DUK_USE_POW_WORKAROUNDS #endif /* Similar workarounds for atan2() semantics issues. MinGW issues are * documented in test-bug-mingw-math-issues.js. */ #undef DUK_USE_ATAN2_WORKAROUNDS #if defined(DUK_F_MINGW) #define DUK_USE_ATAN2_WORKAROUNDS #endif /* Rely as little as possible on compiler behavior for NaN comparison, * signed zero handling, etc. Currently never activated but may be needed * for broken compilers. */ #undef DUK_USE_PARANOID_MATH /* There was a curious bug where test-bi-date-canceling.js would fail e.g. * on 64-bit Ubuntu, gcc-4.8.1, -m32, and no -std=c99. Some date computations * using doubles would be optimized which then broke some corner case tests. * The problem goes away by adding 'volatile' to the datetime computations. * Not sure what the actual triggering conditions are, but using this on * non-C99 systems solves the known issues and has relatively little cost * on other platforms. */ #undef DUK_USE_PARANOID_DATE_COMPUTATION #if !defined(DUK_F_C99) #define DUK_USE_PARANOID_DATE_COMPUTATION #endif /* * Byte order and double memory layout detection * * Endianness detection is a major portability hassle because the macros * and headers are not standardized. There's even variance across UNIX * platforms. Even with "standard" headers, details like underscore count * varies between platforms, e.g. both __BYTE_ORDER and _BYTE_ORDER are used * (Crossbridge has a single underscore, for instance). * * The checks below are structured with this in mind: several approaches are * used, and at the end we check if any of them worked. This allows generic * approaches to be tried first, and platform/compiler specific hacks tried * last. As a last resort, the user can force a specific endianness, as it's * not likely that automatic detection will work on the most exotic platforms. * * Duktape supports little and big endian machines. There's also support * for a hybrid used by some ARM machines where integers are little endian * but IEEE double values use a mixed order (12345678 -> 43218765). This * byte order for doubles is referred to as "mixed endian". */ /* GCC and Clang provide endianness defines as built-in predefines, with * leading and trailing double underscores (e.g. __BYTE_ORDER__). See * output of "make gccpredefs" and "make clangpredefs". Clang doesn't * seem to provide __FLOAT_WORD_ORDER__; assume not mixed endian for clang. * http://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html */ #if !defined(DUK_USE_BYTEORDER) && defined(__BYTE_ORDER__) #if defined(__ORDER_LITTLE_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) #if defined(__FLOAT_WORD_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && (__FLOAT_WORD_ORDER__ == __ORDER_LITTLE_ENDIAN__) #define DUK_USE_BYTEORDER 1 #elif defined(__FLOAT_WORD_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__FLOAT_WORD_ORDER__ == __ORDER_BIG_ENDIAN__) #define DUK_USE_BYTEORDER 2 #elif !defined(__FLOAT_WORD_ORDER__) /* Float word order not known, assume not a hybrid. */ #define DUK_USE_BYTEORDER 1 #else /* Byte order is little endian but cannot determine IEEE double word order. */ #endif /* float word order */ #elif defined(__ORDER_BIG_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) #if defined(__FLOAT_WORD_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__FLOAT_WORD_ORDER__ == __ORDER_BIG_ENDIAN__) #define DUK_USE_BYTEORDER 3 #elif !defined(__FLOAT_WORD_ORDER__) /* Float word order not known, assume not a hybrid. */ #define DUK_USE_BYTEORDER 3 #else /* Byte order is big endian but cannot determine IEEE double word order. */ #endif /* float word order */ #else /* Cannot determine byte order; __ORDER_PDP_ENDIAN__ is related to 32-bit * integer ordering and is not relevant. */ #endif /* integer byte order */ #endif /* !defined(DUK_USE_BYTEORDER) && defined(__BYTE_ORDER__) */ /* More or less standard endianness predefines provided by header files. * The ARM hybrid case is detected by assuming that __FLOAT_WORD_ORDER * will be big endian, see: http://lists.mysql.com/internals/443. * On some platforms some defines may be present with an empty value which * causes comparisons to fail: https://github.com/svaarala/duktape/issues/453. */ #if !defined(DUK_USE_BYTEORDER) #if defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && (__BYTE_ORDER == __LITTLE_ENDIAN) || \ defined(_BYTE_ORDER) && defined(_LITTLE_ENDIAN) && (_BYTE_ORDER == _LITTLE_ENDIAN) || \ defined(__LITTLE_ENDIAN__) #if defined(__FLOAT_WORD_ORDER) && defined(__LITTLE_ENDIAN) && (__FLOAT_WORD_ORDER == __LITTLE_ENDIAN) || \ defined(_FLOAT_WORD_ORDER) && defined(_LITTLE_ENDIAN) && (_FLOAT_WORD_ORDER == _LITTLE_ENDIAN) #define DUK_USE_BYTEORDER 1 #elif defined(__FLOAT_WORD_ORDER) && defined(__BIG_ENDIAN) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN) || \ defined(_FLOAT_WORD_ORDER) && defined(_BIG_ENDIAN) && (_FLOAT_WORD_ORDER == _BIG_ENDIAN) #define DUK_USE_BYTEORDER 2 #elif !defined(__FLOAT_WORD_ORDER) && !defined(_FLOAT_WORD_ORDER) /* Float word order not known, assume not a hybrid. */ #define DUK_USE_BYTEORDER 1 #else /* Byte order is little endian but cannot determine IEEE double word order. */ #endif /* float word order */ #elif defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && (__BYTE_ORDER == __BIG_ENDIAN) || \ defined(_BYTE_ORDER) && defined(_BIG_ENDIAN) && (_BYTE_ORDER == _BIG_ENDIAN) || \ defined(__BIG_ENDIAN__) #if defined(__FLOAT_WORD_ORDER) && defined(__BIG_ENDIAN) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN) || \ defined(_FLOAT_WORD_ORDER) && defined(_BIG_ENDIAN) && (_FLOAT_WORD_ORDER == _BIG_ENDIAN) #define DUK_USE_BYTEORDER 3 #elif !defined(__FLOAT_WORD_ORDER) && !defined(_FLOAT_WORD_ORDER) /* Float word order not known, assume not a hybrid. */ #define DUK_USE_BYTEORDER 3 #else /* Byte order is big endian but cannot determine IEEE double word order. */ #endif /* float word order */ #else /* Cannot determine byte order. */ #endif /* integer byte order */ #endif /* !defined(DUK_USE_BYTEORDER) */ /* QNX gcc cross compiler seems to define e.g. __LITTLEENDIAN__ or __BIGENDIAN__: * $ /opt/qnx650/host/linux/x86/usr/bin/i486-pc-nto-qnx6.5.0-gcc -dM -E - </dev/null | grep -ni endian * 67:#define __LITTLEENDIAN__ 1 * $ /opt/qnx650/host/linux/x86/usr/bin/mips-unknown-nto-qnx6.5.0-gcc -dM -E - </dev/null | grep -ni endian * 81:#define __BIGENDIAN__ 1 * $ /opt/qnx650/host/linux/x86/usr/bin/arm-unknown-nto-qnx6.5.0-gcc -dM -E - </dev/null | grep -ni endian * 70:#define __LITTLEENDIAN__ 1 */ #if !defined(DUK_USE_BYTEORDER) #if defined(__LITTLEENDIAN__) #define DUK_USE_BYTEORDER 1 #elif defined(__BIGENDIAN__) #define DUK_USE_BYTEORDER 3 #endif #endif /* * Alignment requirement and support for unaligned accesses * * Assume unaligned accesses are not supported unless specifically allowed * in the target platform. Some platforms may support unaligned accesses * but alignment to 4 or 8 may still be desirable. Note that unaligned * accesses (and even pointers) relative to natural alignment (regardless * of target alignment) are technically undefined behavior and thus * compiler/architecture specific. */ /* If not forced, use safe default for alignment. */ #if !defined(DUK_USE_ALIGN_BY) #define DUK_USE_ALIGN_BY 8 #endif /* Compiler specific hackery needed to force struct size to match alignment, * see e.g. duk_hbuffer.h. * * http://stackoverflow.com/questions/11130109/c-struct-size-alignment * http://stackoverflow.com/questions/10951039/specifying-64-bit-alignment */ #if !(defined(DUK_USE_PACK_MSVC_PRAGMA) || defined(DUK_USE_PACK_GCC_ATTR) || \ defined(DUK_USE_PACK_CLANG_ATTR) || defined(DUK_USE_PACK_DUMMY_MEMBER)) #define DUK_USE_PACK_DUMMY_MEMBER #endif #if !defined(DUK_U64_CONSTANT) #define DUK_U64_CONSTANT(x) x##ULL #endif #if !defined(DUK_I64_CONSTANT) #define DUK_I64_CONSTANT(x) x##LL #endif #if !defined(DUK_VA_COPY) /* We need va_copy() which is defined in C99 / C++11, so an awkward * replacement is needed for pre-C99 / pre-C++11 environments. This * will quite likely need portability hacks for some non-C99 * environments. */ #if defined(DUK_F_C99) || defined(DUK_F_CPP11) /* C99 / C++11 and above: rely on va_copy() which is required. * Omit parenthesis on macro right side on purpose to minimize differences * to direct use. */ #define DUK_VA_COPY(dest,src) va_copy(dest,src) #else /* Pre-C99: va_list type is implementation dependent. This replacement * assumes it is a plain value so that a simple assignment will work. * This is not the case on all platforms (it may be a single-array element, * for instance). */ #define DUK_VA_COPY(dest,src) do { (dest) = (src); } while (0) #endif #endif #if !defined(DUK_MACRO_STRINGIFY) /* Macro hackery to convert e.g. __LINE__ to a string without formatting, * see: http://stackoverflow.com/questions/240353/convert-a-preprocessor-token-to-a-string */ #define DUK_MACRO_STRINGIFY_HELPER(x) #x #define DUK_MACRO_STRINGIFY(x) DUK_MACRO_STRINGIFY_HELPER(x) #endif #if !defined(DUK_CAUSE_SEGFAULT) /* This can be used for testing; valgrind will then indicate the C call stack * leading to the call site. */ #define DUK_CAUSE_SEGFAULT() do { *((volatile duk_uint32_t *) NULL) = (duk_uint32_t) 0xdeadbeefUL; } while (0) #endif #if !defined(DUK_UNREF) /* Macro for suppressing warnings for potentially unreferenced variables. * The variables can be actually unreferenced or unreferenced in some * specific cases only; for instance, if a variable is only debug printed, * it is unreferenced when debug printing is disabled. May cause warnings * for volatile arguments. */ #define DUK_UNREF(x) do { (void) (x); } while (0) #endif /* Fillin for DUK_NORETURN; DUK_WO_NORETURN() is used to insert dummy * dummy statements after noreturn calls to silence harmless compiler * warnings, e.g.: * * DUK_ERROR_TYPE(thr, "aiee"); * DUK_WO_NORETURN(return 0;); * * Statements inside DUK_WO_NORETURN() must NEVER be actually reachable, * and they're only included to satisfy the compiler. */ #if defined(DUK_NORETURN) #define DUK_WO_NORETURN(stmt) do { } while (0) #else #define DUK_NORETURN(decl) decl #define DUK_WO_NORETURN(stmt) do { stmt } while (0) #endif #if defined(DUK_UNREACHABLE) #define DUK_WO_UNREACHABLE(stmt) do { } while (0) #else /* Don't know how to declare unreachable point, so don't do it; this * may cause some spurious compilation warnings (e.g. "variable used * uninitialized"). */ #define DUK_UNREACHABLE() do { } while (0) #define DUK_WO_UNREACHABLE(stmt) do { stmt } while (0) #endif #if !defined(DUK_LOSE_CONST) /* Convert any input pointer into a "void *", losing a const qualifier. * This is not fully portable because casting through duk_uintptr_t may * not work on all architectures (e.g. those with long, segmented pointers). */ #define DUK_LOSE_CONST(src) ((void *) (duk_uintptr_t) (src)) #endif #if !defined(DUK_LIKELY) #define DUK_LIKELY(x) (x) #endif #if !defined(DUK_UNLIKELY) #define DUK_UNLIKELY(x) (x) #endif #if !defined(DUK_UNPREDICTABLE) #define DUK_UNPREDICTABLE(x) (x) #endif #if !defined(DUK_NOINLINE) #define DUK_NOINLINE /*nop*/ #endif #if !defined(DUK_INLINE) #define DUK_INLINE /*nop*/ #endif #if !defined(DUK_ALWAYS_INLINE) #define DUK_ALWAYS_INLINE /*nop*/ #endif #if !defined(DUK_HOT) #define DUK_HOT /*nop*/ #endif #if !defined(DUK_COLD) #define DUK_COLD /*nop*/ #endif #if !defined(DUK_EXTERNAL_DECL) #define DUK_EXTERNAL_DECL extern #endif #if !defined(DUK_EXTERNAL) #define DUK_EXTERNAL /*empty*/ #endif #if !defined(DUK_INTERNAL_DECL) #if defined(DUK_SINGLE_FILE) #define DUK_INTERNAL_DECL static #else #define DUK_INTERNAL_DECL extern #endif #endif #if !defined(DUK_INTERNAL) #if defined(DUK_SINGLE_FILE) #define DUK_INTERNAL static #else #define DUK_INTERNAL /*empty*/ #endif #endif #if !defined(DUK_LOCAL_DECL) #define DUK_LOCAL_DECL static #endif #if !defined(DUK_LOCAL) #define DUK_LOCAL static #endif #if !defined(DUK_FILE_MACRO) #define DUK_FILE_MACRO __FILE__ #endif #if !defined(DUK_LINE_MACRO) #define DUK_LINE_MACRO __LINE__ #endif #if !defined(DUK_FUNC_MACRO) #if defined(DUK_F_C99) || defined(DUK_F_CPP11) #define DUK_FUNC_MACRO __func__ #elif defined(__FUNCTION__) #define DUK_FUNC_MACRO __FUNCTION__ #else #define DUK_FUNC_MACRO "unknown" #endif #endif #if defined(DUK_F_HAVE_64BIT) #if !defined(DUK_BSWAP64) #define DUK_BSWAP64(x) \ ((((duk_uint64_t) (x)) >> 56U) | \ ((((duk_uint64_t) (x)) >> 40U) & DUK_U64_CONSTANT(0xff00)) | \ ((((duk_uint64_t) (x)) >> 24U) & DUK_U64_CONSTANT(0xff0000)) | \ ((((duk_uint64_t) (x)) >> 8U) & DUK_U64_CONSTANT(0xff000000)) | \ ((((duk_uint64_t) (x)) << 8U) & DUK_U64_CONSTANT(0xff00000000)) | \ ((((duk_uint64_t) (x)) << 24U) & DUK_U64_CONSTANT(0xff0000000000)) | \ ((((duk_uint64_t) (x)) << 40U) & DUK_U64_CONSTANT(0xff000000000000)) | \ (((duk_uint64_t) (x)) << 56U)) #endif #endif #if !defined(DUK_BSWAP32) #define DUK_BSWAP32(x) \ ((((duk_uint32_t) (x)) >> 24U) | \ ((((duk_uint32_t) (x)) >> 8U) & 0xff00UL) | \ ((((duk_uint32_t) (x)) << 8U) & 0xff0000UL) | \ (((duk_uint32_t) (x)) << 24U)) #endif #if !defined(DUK_BSWAP16) #define DUK_BSWAP16(x) \ ((duk_uint16_t) (x) >> 8U) | \ ((duk_uint16_t) (x) << 8U) #endif /* DUK_USE_VARIADIC_MACROS: required from compilers, so no fill-in. */ /* DUK_USE_UNION_INITIALIZERS: required from compilers, so no fill-in. */ #if !(defined(DUK_USE_FLEX_C99) || defined(DUK_USE_FLEX_ZEROSIZE) || defined(DUK_USE_FLEX_ONESIZE)) #if defined(DUK_F_C99) #define DUK_USE_FLEX_C99 #else #define DUK_USE_FLEX_ZEROSIZE /* Not standard but common enough */ #endif #endif #if !(defined(DUK_USE_PACK_GCC_ATTR) || defined(DUK_USE_PACK_CLANG_ATTR) || \ defined(DUK_USE_PACK_MSVC_PRAGMA) || defined(DUK_USE_PACK_DUMMY_MEMBER)) #define DUK_USE_PACK_DUMMY_MEMBER #endif #if 0 /* not defined by default */ #undef DUK_USE_GCC_PRAGMAS #endif /* Workaround for GH-323: avoid inlining control when compiling from * multiple sources, as it causes compiler portability trouble. */ #if !defined(DUK_SINGLE_FILE) #undef DUK_NOINLINE #undef DUK_INLINE #undef DUK_ALWAYS_INLINE #define DUK_NOINLINE /*nop*/ #define DUK_INLINE /*nop*/ #define DUK_ALWAYS_INLINE /*nop*/ #endif /* * Check whether or not a packed duk_tval representation is possible. * What's basically required is that pointers are 32-bit values * (sizeof(void *) == 4). Best effort check, not always accurate. * If guess goes wrong, crashes may result; self tests also verify * the guess. */ /* Explicit marker needed; may be 'defined', 'undefined, 'or 'not provided'. */ #if !defined(DUK_F_PACKED_TVAL_PROVIDED) #undef DUK_F_PACKED_TVAL_POSSIBLE /* Strict C99 case: DUK_UINTPTR_MAX (= UINTPTR_MAX) should be very reliable */ #if !defined(DUK_F_PACKED_TVAL_POSSIBLE) && defined(DUK_UINTPTR_MAX) #if (DUK_UINTPTR_MAX <= 0xffffffffUL) #define DUK_F_PACKED_TVAL_POSSIBLE #endif #endif /* Non-C99 case, still relying on DUK_UINTPTR_MAX, as long as it is not a computed value */ #if !defined(DUK_F_PACKED_TVAL_POSSIBLE) && defined(DUK_UINTPTR_MAX) && !defined(DUK_UINTPTR_MAX_COMPUTED) #if (DUK_UINTPTR_MAX <= 0xffffffffUL) #define DUK_F_PACKED_TVAL_POSSIBLE #endif #endif /* DUK_SIZE_MAX (= SIZE_MAX) is often reliable */ #if !defined(DUK_F_PACKED_TVAL_POSSIBLE) && defined(DUK_SIZE_MAX) && !defined(DUK_SIZE_MAX_COMPUTED) #if (DUK_SIZE_MAX <= 0xffffffffUL) #define DUK_F_PACKED_TVAL_POSSIBLE #endif #endif #undef DUK_USE_PACKED_TVAL #if defined(DUK_F_PACKED_TVAL_POSSIBLE) #define DUK_USE_PACKED_TVAL #endif #undef DUK_F_PACKED_TVAL_POSSIBLE #endif /* DUK_F_PACKED_TVAL_PROVIDED */ /* Object property allocation layout has implications for memory and code * footprint and generated code size/speed. The best layout also depends * on whether the platform has alignment requirements or benefits from * having mostly aligned accesses. */ #undef DUK_USE_HOBJECT_LAYOUT_1 #undef DUK_USE_HOBJECT_LAYOUT_2 #undef DUK_USE_HOBJECT_LAYOUT_3 #if (DUK_USE_ALIGN_BY == 1) /* On platforms without any alignment issues, layout 1 is preferable * because it compiles to slightly less code and provides direct access * to property keys. */ #define DUK_USE_HOBJECT_LAYOUT_1 #else /* On other platforms use layout 2, which requires some padding but * is a bit more natural than layout 3 in ordering the entries. Layout * 3 is currently not used. */ #define DUK_USE_HOBJECT_LAYOUT_2 #endif /* GCC/clang inaccurate math would break compliance and probably duk_tval, * so refuse to compile. Relax this if -ffast-math is tested to work. */ #if defined(__FAST_MATH__) #error __FAST_MATH__ defined, refusing to compile #endif /* * Autogenerated defaults */ #undef DUK_USE_ALLOW_UNDEFINED_BEHAVIOR #define DUK_USE_ARRAY_BUILTIN #define DUK_USE_ARRAY_FASTPATH #define DUK_USE_ARRAY_PROP_FASTPATH #undef DUK_USE_ASSERTIONS #define DUK_USE_AUGMENT_ERROR_CREATE #define DUK_USE_AUGMENT_ERROR_THROW #define DUK_USE_AVOID_PLATFORM_FUNCPTRS #define DUK_USE_BASE64_FASTPATH #define DUK_USE_BASE64_SUPPORT #define DUK_USE_BOOLEAN_BUILTIN #define DUK_USE_BUFFEROBJECT_SUPPORT #undef DUK_USE_BUFLEN16 #define DUK_USE_BYTECODE_DUMP_SUPPORT #define DUK_USE_CACHE_ACTIVATION #define DUK_USE_CACHE_CATCHER #define DUK_USE_CALLSTACK_LIMIT 10000 #define DUK_USE_CBOR_BUILTIN #define DUK_USE_CBOR_DEC_RECLIMIT 1000 #define DUK_USE_CBOR_ENC_RECLIMIT 1000 #define DUK_USE_CBOR_SUPPORT #define DUK_USE_COMPILER_RECLIMIT 2500 #define DUK_USE_COROUTINE_SUPPORT #undef DUK_USE_CPP_EXCEPTIONS #undef DUK_USE_DATAPTR16 #undef DUK_USE_DATAPTR_DEC16 #undef DUK_USE_DATAPTR_ENC16 #define DUK_USE_DATE_BUILTIN #undef DUK_USE_DATE_FORMAT_STRING #undef DUK_USE_DATE_GET_LOCAL_TZOFFSET #undef DUK_USE_DATE_GET_NOW #undef DUK_USE_DATE_PARSE_STRING #undef DUK_USE_DATE_PRS_GETDATE #undef DUK_USE_DEBUG #undef DUK_USE_DEBUGGER_DUMPHEAP #undef DUK_USE_DEBUGGER_INSPECT #undef DUK_USE_DEBUGGER_PAUSE_UNCAUGHT #undef DUK_USE_DEBUGGER_SUPPORT #define DUK_USE_DEBUGGER_THROW_NOTIFY #undef DUK_USE_DEBUGGER_TRANSPORT_TORTURE #define DUK_USE_DEBUG_BUFSIZE 65536L #define DUK_USE_DEBUG_LEVEL 0 #undef DUK_USE_DEBUG_WRITE #define DUK_USE_DOUBLE_LINKED_HEAP #define DUK_USE_DUKTAPE_BUILTIN #define DUK_USE_ENCODING_BUILTINS #define DUK_USE_ERRCREATE #define DUK_USE_ERRTHROW #define DUK_USE_ES6 #define DUK_USE_ES6_OBJECT_PROTO_PROPERTY #define DUK_USE_ES6_OBJECT_SETPROTOTYPEOF #define DUK_USE_ES6_PROXY #define DUK_USE_ES6_REGEXP_SYNTAX #define DUK_USE_ES6_UNICODE_ESCAPE #define DUK_USE_ES7 #define DUK_USE_ES7_EXP_OPERATOR #define DUK_USE_ES8 #define DUK_USE_ES9 #define DUK_USE_ESBC_LIMITS #define DUK_USE_ESBC_MAX_BYTES 2147418112L #define DUK_USE_ESBC_MAX_LINENUMBER 2147418112L #undef DUK_USE_EXEC_FUN_LOCAL #undef DUK_USE_EXEC_INDIRECT_BOUND_CHECK #undef DUK_USE_EXEC_PREFER_SIZE #define DUK_USE_EXEC_REGCONST_OPTIMIZE #undef DUK_USE_EXEC_TIMEOUT_CHECK #undef DUK_USE_EXPLICIT_NULL_INIT #undef DUK_USE_EXTSTR_FREE #undef DUK_USE_EXTSTR_INTERN_CHECK #undef DUK_USE_FASTINT #define DUK_USE_FAST_REFCOUNT_DEFAULT #undef DUK_USE_FATAL_HANDLER #define DUK_USE_FATAL_MAXLEN 128 #define DUK_USE_FINALIZER_SUPPORT #undef DUK_USE_FINALIZER_TORTURE #undef DUK_USE_FUNCPTR16 #undef DUK_USE_FUNCPTR_DEC16 #undef DUK_USE_FUNCPTR_ENC16 #define DUK_USE_FUNCTION_BUILTIN #define DUK_USE_FUNC_FILENAME_PROPERTY #define DUK_USE_FUNC_NAME_PROPERTY #undef DUK_USE_GC_TORTURE #undef DUK_USE_GET_MONOTONIC_TIME #undef DUK_USE_GET_RANDOM_DOUBLE #define DUK_USE_GLOBAL_BINDING #define DUK_USE_GLOBAL_BUILTIN #undef DUK_USE_HEAPPTR16 #undef DUK_USE_HEAPPTR_DEC16 #undef DUK_USE_HEAPPTR_ENC16 #define DUK_USE_HEX_FASTPATH #define DUK_USE_HEX_SUPPORT #define DUK_USE_HOBJECT_ARRAY_ABANDON_LIMIT 2 #define DUK_USE_HOBJECT_ARRAY_ABANDON_MINSIZE 257 #define DUK_USE_HOBJECT_ARRAY_FAST_RESIZE_LIMIT 9 #define DUK_USE_HOBJECT_ARRAY_MINGROW_ADD 16 #define DUK_USE_HOBJECT_ARRAY_MINGROW_DIVISOR 8 #define DUK_USE_HOBJECT_ENTRY_MINGROW_ADD 16 #define DUK_USE_HOBJECT_ENTRY_MINGROW_DIVISOR 8 #define DUK_USE_HOBJECT_HASH_PART #define DUK_USE_HOBJECT_HASH_PROP_LIMIT 8 #define DUK_USE_HSTRING_ARRIDX #define DUK_USE_HSTRING_CLEN #undef DUK_USE_HSTRING_EXTDATA #define DUK_USE_HSTRING_LAZY_CLEN #define DUK_USE_HTML_COMMENTS #define DUK_USE_IDCHAR_FASTPATH #undef DUK_USE_INJECT_HEAP_ALLOC_ERROR #undef DUK_USE_INTERRUPT_COUNTER #undef DUK_USE_INTERRUPT_DEBUG_FIXUP #define DUK_USE_JC #define DUK_USE_JSON_BUILTIN #define DUK_USE_JSON_DECNUMBER_FASTPATH #define DUK_USE_JSON_DECSTRING_FASTPATH #define DUK_USE_JSON_DEC_RECLIMIT 1000 #define DUK_USE_JSON_EATWHITE_FASTPATH #define DUK_USE_JSON_ENC_RECLIMIT 1000 #define DUK_USE_JSON_QUOTESTRING_FASTPATH #undef DUK_USE_JSON_STRINGIFY_FASTPATH #define DUK_USE_JSON_SUPPORT #define DUK_USE_JX #define DUK_USE_LEXER_SLIDING_WINDOW #undef DUK_USE_LIGHTFUNC_BUILTINS #define DUK_USE_LITCACHE_SIZE 256 #define DUK_USE_MARK_AND_SWEEP_RECLIMIT 256 #define DUK_USE_MATH_BUILTIN #define DUK_USE_NATIVE_CALL_RECLIMIT 1000 #undef DUK_USE_NATIVE_STACK_CHECK #define DUK_USE_NONSTD_ARRAY_SPLICE_DELCOUNT #undef DUK_USE_NONSTD_FUNC_CALLER_PROPERTY #undef DUK_USE_NONSTD_FUNC_SOURCE_PROPERTY #define DUK_USE_NONSTD_FUNC_STMT #define DUK_USE_NONSTD_GETTER_KEY_ARGUMENT #define DUK_USE_NONSTD_JSON_ESC_U2028_U2029 #define DUK_USE_NONSTD_SETTER_KEY_ARGUMENT #define DUK_USE_NONSTD_STRING_FROMCHARCODE_32BIT #define DUK_USE_NUMBER_BUILTIN #define DUK_USE_OBJECT_BUILTIN #undef DUK_USE_OBJSIZES16 #undef DUK_USE_PARANOID_ERRORS #define DUK_USE_PC2LINE #define DUK_USE_PERFORMANCE_BUILTIN #undef DUK_USE_PREFER_SIZE #undef DUK_USE_PROMISE_BUILTIN #define DUK_USE_PROVIDE_DEFAULT_ALLOC_FUNCTIONS #undef DUK_USE_REFCOUNT16 #define DUK_USE_REFCOUNT32 #define DUK_USE_REFERENCE_COUNTING #define DUK_USE_REFLECT_BUILTIN #define DUK_USE_REGEXP_CANON_BITMAP #undef DUK_USE_REGEXP_CANON_WORKAROUND #define DUK_USE_REGEXP_COMPILER_RECLIMIT 10000 #define DUK_USE_REGEXP_EXECUTOR_RECLIMIT 10000 #define DUK_USE_REGEXP_SUPPORT #undef DUK_USE_ROM_GLOBAL_CLONE #undef DUK_USE_ROM_GLOBAL_INHERIT #undef DUK_USE_ROM_OBJECTS #define DUK_USE_ROM_PTRCOMP_FIRST 63488L #undef DUK_USE_ROM_STRINGS #define DUK_USE_SECTION_B #undef DUK_USE_SELF_TESTS #define DUK_USE_SHEBANG_COMMENTS #undef DUK_USE_SHUFFLE_TORTURE #define DUK_USE_SOURCE_NONBMP #undef DUK_USE_STRHASH16 #undef DUK_USE_STRHASH_DENSE #define DUK_USE_STRHASH_SKIP_SHIFT 5 #define DUK_USE_STRICT_DECL #undef DUK_USE_STRICT_UTF8_SOURCE #define DUK_USE_STRING_BUILTIN #undef DUK_USE_STRLEN16 #define DUK_USE_STRTAB_GROW_LIMIT 17 #define DUK_USE_STRTAB_MAXSIZE 268435456L #define DUK_USE_STRTAB_MINSIZE 1024 #undef DUK_USE_STRTAB_PTRCOMP #define DUK_USE_STRTAB_RESIZE_CHECK_MASK 255 #define DUK_USE_STRTAB_SHRINK_LIMIT 6 #undef DUK_USE_STRTAB_TORTURE #define DUK_USE_SYMBOL_BUILTIN #define DUK_USE_TAILCALL #define DUK_USE_TARGET_INFO "unknown" #define DUK_USE_TRACEBACKS #define DUK_USE_TRACEBACK_DEPTH 10 #define DUK_USE_VALSTACK_GROW_SHIFT 2 #define DUK_USE_VALSTACK_LIMIT 1000000L #define DUK_USE_VALSTACK_SHRINK_CHECK_SHIFT 2 #define DUK_USE_VALSTACK_SHRINK_SLACK_SHIFT 4 #undef DUK_USE_VALSTACK_UNSAFE #define DUK_USE_VERBOSE_ERRORS #define DUK_USE_VERBOSE_EXECUTOR_ERRORS #define DUK_USE_VOLUNTARY_GC #define DUK_USE_ZERO_BUFFER_DATA /* * You may add overriding #define/#undef directives below for * customization. You of course cannot un-#include or un-typedef * anything; these require direct changes above. */ /* __OVERRIDE_DEFINES__ */ /* * Conditional includes */ #if defined(DUK_F_CPP) && defined(DUK_USE_CPP_EXCEPTIONS) #include <exception> /* std::exception */ #include <stdexcept> /* std::runtime_error */ #endif /* * Date provider selection * * User may define DUK_USE_DATE_GET_NOW() etc directly, in which case we'll * rely on an external provider. If this is not done, revert to previous * behavior and use Unix/Windows built-in provider. */ #if defined(DUK_COMPILING_DUKTAPE) #if defined(DUK_USE_DATE_GET_NOW) /* External provider already defined. */ #elif defined(DUK_USE_DATE_NOW_GETTIMEOFDAY) #define DUK_USE_DATE_GET_NOW(ctx) duk_bi_date_get_now_gettimeofday() #elif defined(DUK_USE_DATE_NOW_TIME) #define DUK_USE_DATE_GET_NOW(ctx) duk_bi_date_get_now_time() #elif defined(DUK_USE_DATE_NOW_WINDOWS) #define DUK_USE_DATE_GET_NOW(ctx) duk_bi_date_get_now_windows() #elif defined(DUK_USE_DATE_NOW_WINDOWS_SUBMS) #define DUK_USE_DATE_GET_NOW(ctx) duk_bi_date_get_now_windows_subms() #else #error no provider for DUK_USE_DATE_GET_NOW() #endif #if defined(DUK_USE_DATE_GET_LOCAL_TZOFFSET) /* External provider already defined. */ #elif defined(DUK_USE_DATE_TZO_GMTIME_R) || defined(DUK_USE_DATE_TZO_GMTIME_S) || defined(DUK_USE_DATE_TZO_GMTIME) #define DUK_USE_DATE_GET_LOCAL_TZOFFSET(d) duk_bi_date_get_local_tzoffset_gmtime((d)) #elif defined(DUK_USE_DATE_TZO_WINDOWS) #define DUK_USE_DATE_GET_LOCAL_TZOFFSET(d) duk_bi_date_get_local_tzoffset_windows((d)) #elif defined(DUK_USE_DATE_TZO_WINDOWS_NO_DST) #define DUK_USE_DATE_GET_LOCAL_TZOFFSET(d) duk_bi_date_get_local_tzoffset_windows_no_dst((d)) #else #error no provider for DUK_USE_DATE_GET_LOCAL_TZOFFSET() #endif #if defined(DUK_USE_DATE_PARSE_STRING) /* External provider already defined. */ #elif defined(DUK_USE_DATE_PRS_STRPTIME) #define DUK_USE_DATE_PARSE_STRING(ctx,str) duk_bi_date_parse_string_strptime((ctx), (str)) #elif defined(DUK_USE_DATE_PRS_GETDATE) #define DUK_USE_DATE_PARSE_STRING(ctx,str) duk_bi_date_parse_string_getdate((ctx), (str)) #else /* No provider for DUK_USE_DATE_PARSE_STRING(), fall back to ISO 8601 only. */ #endif #if defined(DUK_USE_DATE_FORMAT_STRING) /* External provider already defined. */ #elif defined(DUK_USE_DATE_FMT_STRFTIME) #define DUK_USE_DATE_FORMAT_STRING(ctx,parts,tzoffset,flags) \ duk_bi_date_format_parts_strftime((ctx), (parts), (tzoffset), (flags)) #else /* No provider for DUK_USE_DATE_FORMAT_STRING(), fall back to ISO 8601 only. */ #endif #if defined(DUK_USE_GET_MONOTONIC_TIME) /* External provider already defined. */ #elif defined(DUK_USE_GET_MONOTONIC_TIME_CLOCK_GETTIME) #define DUK_USE_GET_MONOTONIC_TIME(ctx) duk_bi_date_get_monotonic_time_clock_gettime() #elif defined(DUK_USE_GET_MONOTONIC_TIME_WINDOWS_QPC) #define DUK_USE_GET_MONOTONIC_TIME(ctx) duk_bi_date_get_monotonic_time_windows_qpc() #else /* No provider for DUK_USE_GET_MONOTONIC_TIME(), fall back to DUK_USE_DATE_GET_NOW(). */ #endif #endif /* DUK_COMPILING_DUKTAPE */ /* * Checks for legacy feature options (DUK_OPT_xxx) */ #if defined(DUK_OPT_ASSERTIONS) #error unsupported legacy feature option DUK_OPT_ASSERTIONS used #endif #if defined(DUK_OPT_BUFFEROBJECT_SUPPORT) #error unsupported legacy feature option DUK_OPT_BUFFEROBJECT_SUPPORT used #endif #if defined(DUK_OPT_BUFLEN16) #error unsupported legacy feature option DUK_OPT_BUFLEN16 used #endif #if defined(DUK_OPT_DATAPTR16) #error unsupported legacy feature option DUK_OPT_DATAPTR16 used #endif #if defined(DUK_OPT_DATAPTR_DEC16) #error unsupported legacy feature option DUK_OPT_DATAPTR_DEC16 used #endif #if defined(DUK_OPT_DATAPTR_ENC16) #error unsupported legacy feature option DUK_OPT_DATAPTR_ENC16 used #endif #if defined(DUK_OPT_DDDPRINT) #error unsupported legacy feature option DUK_OPT_DDDPRINT used #endif #if defined(DUK_OPT_DDPRINT) #error unsupported legacy feature option DUK_OPT_DDPRINT used #endif #if defined(DUK_OPT_DEBUG) #error unsupported legacy feature option DUK_OPT_DEBUG used #endif #if defined(DUK_OPT_DEBUGGER_DUMPHEAP) #error unsupported legacy feature option DUK_OPT_DEBUGGER_DUMPHEAP used #endif #if defined(DUK_OPT_DEBUGGER_FWD_LOGGING) #error unsupported legacy feature option DUK_OPT_DEBUGGER_FWD_LOGGING used #endif #if defined(DUK_OPT_DEBUGGER_FWD_PRINTALERT) #error unsupported legacy feature option DUK_OPT_DEBUGGER_FWD_PRINTALERT used #endif #if defined(DUK_OPT_DEBUGGER_SUPPORT) #error unsupported legacy feature option DUK_OPT_DEBUGGER_SUPPORT used #endif #if defined(DUK_OPT_DEBUGGER_TRANSPORT_TORTURE) #error unsupported legacy feature option DUK_OPT_DEBUGGER_TRANSPORT_TORTURE used #endif #if defined(DUK_OPT_DEBUG_BUFSIZE) #error unsupported legacy feature option DUK_OPT_DEBUG_BUFSIZE used #endif #if defined(DUK_OPT_DECLARE) #error unsupported legacy feature option DUK_OPT_DECLARE used #endif #if defined(DUK_OPT_DEEP_C_STACK) #error unsupported legacy feature option DUK_OPT_DEEP_C_STACK used #endif #if defined(DUK_OPT_DLL_BUILD) #error unsupported legacy feature option DUK_OPT_DLL_BUILD used #endif #if defined(DUK_OPT_DPRINT) #error unsupported legacy feature option DUK_OPT_DPRINT used #endif #if defined(DUK_OPT_DPRINT_COLORS) #error unsupported legacy feature option DUK_OPT_DPRINT_COLORS used #endif #if defined(DUK_OPT_DPRINT_RDTSC) #error unsupported legacy feature option DUK_OPT_DPRINT_RDTSC used #endif #if defined(DUK_OPT_EXEC_TIMEOUT_CHECK) #error unsupported legacy feature option DUK_OPT_EXEC_TIMEOUT_CHECK used #endif #if defined(DUK_OPT_EXTERNAL_STRINGS) #error unsupported legacy feature option DUK_OPT_EXTERNAL_STRINGS used #endif #if defined(DUK_OPT_EXTSTR_FREE) #error unsupported legacy feature option DUK_OPT_EXTSTR_FREE used #endif #if defined(DUK_OPT_EXTSTR_INTERN_CHECK) #error unsupported legacy feature option DUK_OPT_EXTSTR_INTERN_CHECK used #endif #if defined(DUK_OPT_FASTINT) #error unsupported legacy feature option DUK_OPT_FASTINT used #endif #if defined(DUK_OPT_FORCE_ALIGN) #error unsupported legacy feature option DUK_OPT_FORCE_ALIGN used #endif #if defined(DUK_OPT_FORCE_BYTEORDER) #error unsupported legacy feature option DUK_OPT_FORCE_BYTEORDER used #endif #if defined(DUK_OPT_FUNCPTR16) #error unsupported legacy feature option DUK_OPT_FUNCPTR16 used #endif #if defined(DUK_OPT_FUNCPTR_DEC16) #error unsupported legacy feature option DUK_OPT_FUNCPTR_DEC16 used #endif #if defined(DUK_OPT_FUNCPTR_ENC16) #error unsupported legacy feature option DUK_OPT_FUNCPTR_ENC16 used #endif #if defined(DUK_OPT_FUNC_NONSTD_CALLER_PROPERTY) #error unsupported legacy feature option DUK_OPT_FUNC_NONSTD_CALLER_PROPERTY used #endif #if defined(DUK_OPT_FUNC_NONSTD_SOURCE_PROPERTY) #error unsupported legacy feature option DUK_OPT_FUNC_NONSTD_SOURCE_PROPERTY used #endif #if defined(DUK_OPT_GC_TORTURE) #error unsupported legacy feature option DUK_OPT_GC_TORTURE used #endif #if defined(DUK_OPT_HAVE_CUSTOM_H) #error unsupported legacy feature option DUK_OPT_HAVE_CUSTOM_H used #endif #if defined(DUK_OPT_HEAPPTR16) #error unsupported legacy feature option DUK_OPT_HEAPPTR16 used #endif #if defined(DUK_OPT_HEAPPTR_DEC16) #error unsupported legacy feature option DUK_OPT_HEAPPTR_DEC16 used #endif #if defined(DUK_OPT_HEAPPTR_ENC16) #error unsupported legacy feature option DUK_OPT_HEAPPTR_ENC16 used #endif #if defined(DUK_OPT_INTERRUPT_COUNTER) #error unsupported legacy feature option DUK_OPT_INTERRUPT_COUNTER used #endif #if defined(DUK_OPT_JSON_STRINGIFY_FASTPATH) #error unsupported legacy feature option DUK_OPT_JSON_STRINGIFY_FASTPATH used #endif #if defined(DUK_OPT_LIGHTFUNC_BUILTINS) #error unsupported legacy feature option DUK_OPT_LIGHTFUNC_BUILTINS used #endif #if defined(DUK_OPT_NONSTD_FUNC_CALLER_PROPERTY) #error unsupported legacy feature option DUK_OPT_NONSTD_FUNC_CALLER_PROPERTY used #endif #if defined(DUK_OPT_NONSTD_FUNC_SOURCE_PROPERTY) #error unsupported legacy feature option DUK_OPT_NONSTD_FUNC_SOURCE_PROPERTY used #endif #if defined(DUK_OPT_NO_ARRAY_SPLICE_NONSTD_DELCOUNT) #error unsupported legacy feature option DUK_OPT_NO_ARRAY_SPLICE_NONSTD_DELCOUNT used #endif #if defined(DUK_OPT_NO_AUGMENT_ERRORS) #error unsupported legacy feature option DUK_OPT_NO_AUGMENT_ERRORS used #endif #if defined(DUK_OPT_NO_BROWSER_LIKE) #error unsupported legacy feature option DUK_OPT_NO_BROWSER_LIKE used #endif #if defined(DUK_OPT_NO_BUFFEROBJECT_SUPPORT) #error unsupported legacy feature option DUK_OPT_NO_BUFFEROBJECT_SUPPORT used #endif #if defined(DUK_OPT_NO_BYTECODE_DUMP_SUPPORT) #error unsupported legacy feature option DUK_OPT_NO_BYTECODE_DUMP_SUPPORT used #endif #if defined(DUK_OPT_NO_COMMONJS_MODULES) #error unsupported legacy feature option DUK_OPT_NO_COMMONJS_MODULES used #endif #if defined(DUK_OPT_NO_ES6_OBJECT_PROTO_PROPERTY) #error unsupported legacy feature option DUK_OPT_NO_ES6_OBJECT_PROTO_PROPERTY used #endif #if defined(DUK_OPT_NO_ES6_OBJECT_SETPROTOTYPEOF) #error unsupported legacy feature option DUK_OPT_NO_ES6_OBJECT_SETPROTOTYPEOF used #endif #if defined(DUK_OPT_NO_ES6_PROXY) #error unsupported legacy feature option DUK_OPT_NO_ES6_PROXY used #endif #if defined(DUK_OPT_NO_FILE_IO) #error unsupported legacy feature option DUK_OPT_NO_FILE_IO used #endif #if defined(DUK_OPT_NO_FUNC_STMT) #error unsupported legacy feature option DUK_OPT_NO_FUNC_STMT used #endif #if defined(DUK_OPT_NO_JC) #error unsupported legacy feature option DUK_OPT_NO_JC used #endif #if defined(DUK_OPT_NO_JSONC) #error unsupported legacy feature option DUK_OPT_NO_JSONC used #endif #if defined(DUK_OPT_NO_JSONX) #error unsupported legacy feature option DUK_OPT_NO_JSONX used #endif #if defined(DUK_OPT_NO_JX) #error unsupported legacy feature option DUK_OPT_NO_JX used #endif #if defined(DUK_OPT_NO_MARK_AND_SWEEP) #error unsupported legacy feature option DUK_OPT_NO_MARK_AND_SWEEP used #endif #if defined(DUK_OPT_NO_MS_STRINGTABLE_RESIZE) #error unsupported legacy feature option DUK_OPT_NO_MS_STRINGTABLE_RESIZE used #endif #if defined(DUK_OPT_NO_NONSTD_ACCESSOR_KEY_ARGUMENT) #error unsupported legacy feature option DUK_OPT_NO_NONSTD_ACCESSOR_KEY_ARGUMENT used #endif #if defined(DUK_OPT_NO_NONSTD_ARRAY_CONCAT_TRAILER) #error unsupported legacy feature option DUK_OPT_NO_NONSTD_ARRAY_CONCAT_TRAILER used #endif #if defined(DUK_OPT_NO_NONSTD_ARRAY_MAP_TRAILER) #error unsupported legacy feature option DUK_OPT_NO_NONSTD_ARRAY_MAP_TRAILER used #endif #if defined(DUK_OPT_NO_NONSTD_ARRAY_SPLICE_DELCOUNT) #error unsupported legacy feature option DUK_OPT_NO_NONSTD_ARRAY_SPLICE_DELCOUNT used #endif #if defined(DUK_OPT_NO_NONSTD_FUNC_STMT) #error unsupported legacy feature option DUK_OPT_NO_NONSTD_FUNC_STMT used #endif #if defined(DUK_OPT_NO_NONSTD_JSON_ESC_U2028_U2029) #error unsupported legacy feature option DUK_OPT_NO_NONSTD_JSON_ESC_U2028_U2029 used #endif #if defined(DUK_OPT_NO_NONSTD_STRING_FROMCHARCODE_32BIT) #error unsupported legacy feature option DUK_OPT_NO_NONSTD_STRING_FROMCHARCODE_32BIT used #endif #if defined(DUK_OPT_NO_OBJECT_ES6_PROTO_PROPERTY) #error unsupported legacy feature option DUK_OPT_NO_OBJECT_ES6_PROTO_PROPERTY used #endif #if defined(DUK_OPT_NO_OBJECT_ES6_SETPROTOTYPEOF) #error unsupported legacy feature option DUK_OPT_NO_OBJECT_ES6_SETPROTOTYPEOF used #endif #if defined(DUK_OPT_NO_OCTAL_SUPPORT) #error unsupported legacy feature option DUK_OPT_NO_OCTAL_SUPPORT used #endif #if defined(DUK_OPT_NO_PACKED_TVAL) #error unsupported legacy feature option DUK_OPT_NO_PACKED_TVAL used #endif #if defined(DUK_OPT_NO_PC2LINE) #error unsupported legacy feature option DUK_OPT_NO_PC2LINE used #endif #if defined(DUK_OPT_NO_REFERENCE_COUNTING) #error unsupported legacy feature option DUK_OPT_NO_REFERENCE_COUNTING used #endif #if defined(DUK_OPT_NO_REGEXP_SUPPORT) #error unsupported legacy feature option DUK_OPT_NO_REGEXP_SUPPORT used #endif #if defined(DUK_OPT_NO_SECTION_B) #error unsupported legacy feature option DUK_OPT_NO_SECTION_B used #endif #if defined(DUK_OPT_NO_SOURCE_NONBMP) #error unsupported legacy feature option DUK_OPT_NO_SOURCE_NONBMP used #endif #if defined(DUK_OPT_NO_STRICT_DECL) #error unsupported legacy feature option DUK_OPT_NO_STRICT_DECL used #endif #if defined(DUK_OPT_NO_TRACEBACKS) #error unsupported legacy feature option DUK_OPT_NO_TRACEBACKS used #endif #if defined(DUK_OPT_NO_VERBOSE_ERRORS) #error unsupported legacy feature option DUK_OPT_NO_VERBOSE_ERRORS used #endif #if defined(DUK_OPT_NO_VOLUNTARY_GC) #error unsupported legacy feature option DUK_OPT_NO_VOLUNTARY_GC used #endif #if defined(DUK_OPT_NO_ZERO_BUFFER_DATA) #error unsupported legacy feature option DUK_OPT_NO_ZERO_BUFFER_DATA used #endif #if defined(DUK_OPT_OBJSIZES16) #error unsupported legacy feature option DUK_OPT_OBJSIZES16 used #endif #if defined(DUK_OPT_PANIC_HANDLER) #error unsupported legacy feature option DUK_OPT_PANIC_HANDLER used #endif #if defined(DUK_OPT_REFCOUNT16) #error unsupported legacy feature option DUK_OPT_REFCOUNT16 used #endif #if defined(DUK_OPT_SEGFAULT_ON_PANIC) #error unsupported legacy feature option DUK_OPT_SEGFAULT_ON_PANIC used #endif #if defined(DUK_OPT_SELF_TESTS) #error unsupported legacy feature option DUK_OPT_SELF_TESTS used #endif #if defined(DUK_OPT_SETJMP) #error unsupported legacy feature option DUK_OPT_SETJMP used #endif #if defined(DUK_OPT_SHUFFLE_TORTURE) #error unsupported legacy feature option DUK_OPT_SHUFFLE_TORTURE used #endif #if defined(DUK_OPT_SIGSETJMP) #error unsupported legacy feature option DUK_OPT_SIGSETJMP used #endif #if defined(DUK_OPT_STRHASH16) #error unsupported legacy feature option DUK_OPT_STRHASH16 used #endif #if defined(DUK_OPT_STRICT_UTF8_SOURCE) #error unsupported legacy feature option DUK_OPT_STRICT_UTF8_SOURCE used #endif #if defined(DUK_OPT_STRLEN16) #error unsupported legacy feature option DUK_OPT_STRLEN16 used #endif #if defined(DUK_OPT_STRTAB_CHAIN) #error unsupported legacy feature option DUK_OPT_STRTAB_CHAIN used #endif #if defined(DUK_OPT_STRTAB_CHAIN_SIZE) #error unsupported legacy feature option DUK_OPT_STRTAB_CHAIN_SIZE used #endif #if defined(DUK_OPT_TARGET_INFO) #error unsupported legacy feature option DUK_OPT_TARGET_INFO used #endif #if defined(DUK_OPT_TRACEBACK_DEPTH) #error unsupported legacy feature option DUK_OPT_TRACEBACK_DEPTH used #endif #if defined(DUK_OPT_UNDERSCORE_SETJMP) #error unsupported legacy feature option DUK_OPT_UNDERSCORE_SETJMP used #endif #if defined(DUK_OPT_USER_INITJS) #error unsupported legacy feature option DUK_OPT_USER_INITJS used #endif /* * Checks for config option consistency (DUK_USE_xxx) */ #if defined(DUK_USE_32BIT_PTRS) #error unsupported config option used (option has been removed): DUK_USE_32BIT_PTRS #endif #if defined(DUK_USE_ALIGN_4) #error unsupported config option used (option has been removed): DUK_USE_ALIGN_4 #endif #if defined(DUK_USE_ALIGN_8) #error unsupported config option used (option has been removed): DUK_USE_ALIGN_8 #endif #if defined(DUK_USE_BROWSER_LIKE) #error unsupported config option used (option has been removed): DUK_USE_BROWSER_LIKE #endif #if defined(DUK_USE_BUILTIN_INITJS) #error unsupported config option used (option has been removed): DUK_USE_BUILTIN_INITJS #endif #if defined(DUK_USE_BYTEORDER_FORCED) #error unsupported config option used (option has been removed): DUK_USE_BYTEORDER_FORCED #endif #if defined(DUK_USE_COMMONJS_MODULES) #error unsupported config option used (option has been removed): DUK_USE_COMMONJS_MODULES #endif #if defined(DUK_USE_DATAPTR_DEC16) && !defined(DUK_USE_DATAPTR16) #error config option DUK_USE_DATAPTR_DEC16 requires option DUK_USE_DATAPTR16 (which is missing) #endif #if defined(DUK_USE_DATAPTR_ENC16) && !defined(DUK_USE_DATAPTR16) #error config option DUK_USE_DATAPTR_ENC16 requires option DUK_USE_DATAPTR16 (which is missing) #endif #if defined(DUK_USE_DDDPRINT) #error unsupported config option used (option has been removed): DUK_USE_DDDPRINT #endif #if defined(DUK_USE_DDPRINT) #error unsupported config option used (option has been removed): DUK_USE_DDPRINT #endif #if defined(DUK_USE_DEBUGGER_FWD_LOGGING) #error unsupported config option used (option has been removed): DUK_USE_DEBUGGER_FWD_LOGGING #endif #if defined(DUK_USE_DEBUGGER_FWD_PRINTALERT) #error unsupported config option used (option has been removed): DUK_USE_DEBUGGER_FWD_PRINTALERT #endif #if defined(DUK_USE_DEBUGGER_SUPPORT) && !defined(DUK_USE_INTERRUPT_COUNTER) #error config option DUK_USE_DEBUGGER_SUPPORT requires option DUK_USE_INTERRUPT_COUNTER (which is missing) #endif #if defined(DUK_USE_DEEP_C_STACK) #error unsupported config option used (option has been removed): DUK_USE_DEEP_C_STACK #endif #if defined(DUK_USE_DOUBLE_BE) #error unsupported config option used (option has been removed): DUK_USE_DOUBLE_BE #endif #if defined(DUK_USE_DOUBLE_BE) && defined(DUK_USE_DOUBLE_LE) #error config option DUK_USE_DOUBLE_BE conflicts with option DUK_USE_DOUBLE_LE (which is also defined) #endif #if defined(DUK_USE_DOUBLE_BE) && defined(DUK_USE_DOUBLE_ME) #error config option DUK_USE_DOUBLE_BE conflicts with option DUK_USE_DOUBLE_ME (which is also defined) #endif #if defined(DUK_USE_DOUBLE_LE) #error unsupported config option used (option has been removed): DUK_USE_DOUBLE_LE #endif #if defined(DUK_USE_DOUBLE_LE) && defined(DUK_USE_DOUBLE_BE) #error config option DUK_USE_DOUBLE_LE conflicts with option DUK_USE_DOUBLE_BE (which is also defined) #endif #if defined(DUK_USE_DOUBLE_LE) && defined(DUK_USE_DOUBLE_ME) #error config option DUK_USE_DOUBLE_LE conflicts with option DUK_USE_DOUBLE_ME (which is also defined) #endif #if defined(DUK_USE_DOUBLE_ME) #error unsupported config option used (option has been removed): DUK_USE_DOUBLE_ME #endif #if defined(DUK_USE_DOUBLE_ME) && defined(DUK_USE_DOUBLE_LE) #error config option DUK_USE_DOUBLE_ME conflicts with option DUK_USE_DOUBLE_LE (which is also defined) #endif #if defined(DUK_USE_DOUBLE_ME) && defined(DUK_USE_DOUBLE_BE) #error config option DUK_USE_DOUBLE_ME conflicts with option DUK_USE_DOUBLE_BE (which is also defined) #endif #if defined(DUK_USE_DPRINT) #error unsupported config option used (option has been removed): DUK_USE_DPRINT #endif #if defined(DUK_USE_DPRINT) && !defined(DUK_USE_DEBUG) #error config option DUK_USE_DPRINT requires option DUK_USE_DEBUG (which is missing) #endif #if defined(DUK_USE_DPRINT_COLORS) #error unsupported config option used (option has been removed): DUK_USE_DPRINT_COLORS #endif #if defined(DUK_USE_DPRINT_RDTSC) #error unsupported config option used (option has been removed): DUK_USE_DPRINT_RDTSC #endif #if defined(DUK_USE_ES6_REGEXP_BRACES) #error unsupported config option used (option has been removed): DUK_USE_ES6_REGEXP_BRACES #endif #if defined(DUK_USE_ESBC_MAX_BYTES) && !defined(DUK_USE_ESBC_LIMITS) #error config option DUK_USE_ESBC_MAX_BYTES requires option DUK_USE_ESBC_LIMITS (which is missing) #endif #if defined(DUK_USE_ESBC_MAX_LINENUMBER) && !defined(DUK_USE_ESBC_LIMITS) #error config option DUK_USE_ESBC_MAX_LINENUMBER requires option DUK_USE_ESBC_LIMITS (which is missing) #endif #if defined(DUK_USE_EXEC_TIMEOUT_CHECK) && !defined(DUK_USE_INTERRUPT_COUNTER) #error config option DUK_USE_EXEC_TIMEOUT_CHECK requires option DUK_USE_INTERRUPT_COUNTER (which is missing) #endif #if defined(DUK_USE_EXTSTR_FREE) && !defined(DUK_USE_HSTRING_EXTDATA) #error config option DUK_USE_EXTSTR_FREE requires option DUK_USE_HSTRING_EXTDATA (which is missing) #endif #if defined(DUK_USE_EXTSTR_INTERN_CHECK) && !defined(DUK_USE_HSTRING_EXTDATA) #error config option DUK_USE_EXTSTR_INTERN_CHECK requires option DUK_USE_HSTRING_EXTDATA (which is missing) #endif #if defined(DUK_USE_FASTINT) && !defined(DUK_USE_64BIT_OPS) #error config option DUK_USE_FASTINT requires option DUK_USE_64BIT_OPS (which is missing) #endif #if defined(DUK_USE_FILE_IO) #error unsupported config option used (option has been removed): DUK_USE_FILE_IO #endif #if defined(DUK_USE_FULL_TVAL) #error unsupported config option used (option has been removed): DUK_USE_FULL_TVAL #endif #if defined(DUK_USE_FUNCPTR_DEC16) && !defined(DUK_USE_FUNCPTR16) #error config option DUK_USE_FUNCPTR_DEC16 requires option DUK_USE_FUNCPTR16 (which is missing) #endif #if defined(DUK_USE_FUNCPTR_ENC16) && !defined(DUK_USE_FUNCPTR16) #error config option DUK_USE_FUNCPTR_ENC16 requires option DUK_USE_FUNCPTR16 (which is missing) #endif #if defined(DUK_USE_HASHBYTES_UNALIGNED_U32_ACCESS) #error unsupported config option used (option has been removed): DUK_USE_HASHBYTES_UNALIGNED_U32_ACCESS #endif #if defined(DUK_USE_HEAPPTR16) && defined(DUK_USE_DEBUG) #error config option DUK_USE_HEAPPTR16 conflicts with option DUK_USE_DEBUG (which is also defined) #endif #if defined(DUK_USE_HEAPPTR_DEC16) && !defined(DUK_USE_HEAPPTR16) #error config option DUK_USE_HEAPPTR_DEC16 requires option DUK_USE_HEAPPTR16 (which is missing) #endif #if defined(DUK_USE_HEAPPTR_ENC16) && !defined(DUK_USE_HEAPPTR16) #error config option DUK_USE_HEAPPTR_ENC16 requires option DUK_USE_HEAPPTR16 (which is missing) #endif #if defined(DUK_USE_INTEGER_BE) #error unsupported config option used (option has been removed): DUK_USE_INTEGER_BE #endif #if defined(DUK_USE_INTEGER_BE) && defined(DUK_USE_INTEGER_LE) #error config option DUK_USE_INTEGER_BE conflicts with option DUK_USE_INTEGER_LE (which is also defined) #endif #if defined(DUK_USE_INTEGER_BE) && defined(DUK_USE_INTEGER_ME) #error config option DUK_USE_INTEGER_BE conflicts with option DUK_USE_INTEGER_ME (which is also defined) #endif #if defined(DUK_USE_INTEGER_LE) #error unsupported config option used (option has been removed): DUK_USE_INTEGER_LE #endif #if defined(DUK_USE_INTEGER_LE) && defined(DUK_USE_INTEGER_BE) #error config option DUK_USE_INTEGER_LE conflicts with option DUK_USE_INTEGER_BE (which is also defined) #endif #if defined(DUK_USE_INTEGER_LE) && defined(DUK_USE_INTEGER_ME) #error config option DUK_USE_INTEGER_LE conflicts with option DUK_USE_INTEGER_ME (which is also defined) #endif #if defined(DUK_USE_INTEGER_ME) #error unsupported config option used (option has been removed): DUK_USE_INTEGER_ME #endif #if defined(DUK_USE_INTEGER_ME) && defined(DUK_USE_INTEGER_LE) #error config option DUK_USE_INTEGER_ME conflicts with option DUK_USE_INTEGER_LE (which is also defined) #endif #if defined(DUK_USE_INTEGER_ME) && defined(DUK_USE_INTEGER_BE) #error config option DUK_USE_INTEGER_ME conflicts with option DUK_USE_INTEGER_BE (which is also defined) #endif #if defined(DUK_USE_MARKANDSWEEP_FINALIZER_TORTURE) #error unsupported config option used (option has been removed): DUK_USE_MARKANDSWEEP_FINALIZER_TORTURE #endif #if defined(DUK_USE_MARK_AND_SWEEP) #error unsupported config option used (option has been removed): DUK_USE_MARK_AND_SWEEP #endif #if defined(DUK_USE_MATH_FMAX) #error unsupported config option used (option has been removed): DUK_USE_MATH_FMAX #endif #if defined(DUK_USE_MATH_FMIN) #error unsupported config option used (option has been removed): DUK_USE_MATH_FMIN #endif #if defined(DUK_USE_MATH_ROUND) #error unsupported config option used (option has been removed): DUK_USE_MATH_ROUND #endif #if defined(DUK_USE_MS_STRINGTABLE_RESIZE) #error unsupported config option used (option has been removed): DUK_USE_MS_STRINGTABLE_RESIZE #endif #if defined(DUK_USE_NONSTD_ARRAY_CONCAT_TRAILER) #error unsupported config option used (option has been removed): DUK_USE_NONSTD_ARRAY_CONCAT_TRAILER #endif #if defined(DUK_USE_NONSTD_ARRAY_MAP_TRAILER) #error unsupported config option used (option has been removed): DUK_USE_NONSTD_ARRAY_MAP_TRAILER #endif #if defined(DUK_USE_NONSTD_REGEXP_DOLLAR_ESCAPE) #error unsupported config option used (option has been removed): DUK_USE_NONSTD_REGEXP_DOLLAR_ESCAPE #endif #if defined(DUK_USE_NO_DOUBLE_ALIASING_SELFTEST) #error unsupported config option used (option has been removed): DUK_USE_NO_DOUBLE_ALIASING_SELFTEST #endif #if defined(DUK_USE_OCTAL_SUPPORT) #error unsupported config option used (option has been removed): DUK_USE_OCTAL_SUPPORT #endif #if defined(DUK_USE_PACKED_TVAL_POSSIBLE) #error unsupported config option used (option has been removed): DUK_USE_PACKED_TVAL_POSSIBLE #endif #if defined(DUK_USE_PANIC_ABORT) #error unsupported config option used (option has been removed): DUK_USE_PANIC_ABORT #endif #if defined(DUK_USE_PANIC_EXIT) #error unsupported config option used (option has been removed): DUK_USE_PANIC_EXIT #endif #if defined(DUK_USE_PANIC_HANDLER) #error unsupported config option used (option has been removed): DUK_USE_PANIC_HANDLER #endif #if defined(DUK_USE_PANIC_SEGFAULT) #error unsupported config option used (option has been removed): DUK_USE_PANIC_SEGFAULT #endif #if defined(DUK_USE_POW_NETBSD_WORKAROUND) #error unsupported config option used (option has been removed): DUK_USE_POW_NETBSD_WORKAROUND #endif #if defined(DUK_USE_RDTSC) #error unsupported config option used (option has been removed): DUK_USE_RDTSC #endif #if defined(DUK_USE_REFZERO_FINALIZER_TORTURE) #error unsupported config option used (option has been removed): DUK_USE_REFZERO_FINALIZER_TORTURE #endif #if defined(DUK_USE_ROM_GLOBAL_CLONE) && !defined(DUK_USE_ROM_STRINGS) #error config option DUK_USE_ROM_GLOBAL_CLONE requires option DUK_USE_ROM_STRINGS (which is missing) #endif #if defined(DUK_USE_ROM_GLOBAL_CLONE) && !defined(DUK_USE_ROM_OBJECTS) #error config option DUK_USE_ROM_GLOBAL_CLONE requires option DUK_USE_ROM_OBJECTS (which is missing) #endif #if defined(DUK_USE_ROM_GLOBAL_CLONE) && defined(DUK_USE_ROM_GLOBAL_INHERIT) #error config option DUK_USE_ROM_GLOBAL_CLONE conflicts with option DUK_USE_ROM_GLOBAL_INHERIT (which is also defined) #endif #if defined(DUK_USE_ROM_GLOBAL_INHERIT) && !defined(DUK_USE_ROM_STRINGS) #error config option DUK_USE_ROM_GLOBAL_INHERIT requires option DUK_USE_ROM_STRINGS (which is missing) #endif #if defined(DUK_USE_ROM_GLOBAL_INHERIT) && !defined(DUK_USE_ROM_OBJECTS) #error config option DUK_USE_ROM_GLOBAL_INHERIT requires option DUK_USE_ROM_OBJECTS (which is missing) #endif #if defined(DUK_USE_ROM_GLOBAL_INHERIT) && defined(DUK_USE_ROM_GLOBAL_CLONE) #error config option DUK_USE_ROM_GLOBAL_INHERIT conflicts with option DUK_USE_ROM_GLOBAL_CLONE (which is also defined) #endif #if defined(DUK_USE_ROM_OBJECTS) && !defined(DUK_USE_ROM_STRINGS) #error config option DUK_USE_ROM_OBJECTS requires option DUK_USE_ROM_STRINGS (which is missing) #endif #if defined(DUK_USE_ROM_STRINGS) && !defined(DUK_USE_ROM_OBJECTS) #error config option DUK_USE_ROM_STRINGS requires option DUK_USE_ROM_OBJECTS (which is missing) #endif #if defined(DUK_USE_SETJMP) #error unsupported config option used (option has been removed): DUK_USE_SETJMP #endif #if defined(DUK_USE_SIGSETJMP) #error unsupported config option used (option has been removed): DUK_USE_SIGSETJMP #endif #if defined(DUK_USE_STRTAB_CHAIN) #error unsupported config option used (option has been removed): DUK_USE_STRTAB_CHAIN #endif #if defined(DUK_USE_STRTAB_CHAIN_SIZE) #error unsupported config option used (option has been removed): DUK_USE_STRTAB_CHAIN_SIZE #endif #if defined(DUK_USE_STRTAB_CHAIN_SIZE) && !defined(DUK_USE_STRTAB_CHAIN) #error config option DUK_USE_STRTAB_CHAIN_SIZE requires option DUK_USE_STRTAB_CHAIN (which is missing) #endif #if defined(DUK_USE_STRTAB_PROBE) #error unsupported config option used (option has been removed): DUK_USE_STRTAB_PROBE #endif #if defined(DUK_USE_STRTAB_PTRCOMP) && !defined(DUK_USE_HEAPPTR16) #error config option DUK_USE_STRTAB_PTRCOMP requires option DUK_USE_HEAPPTR16 (which is missing) #endif #if defined(DUK_USE_TAILCALL) && defined(DUK_USE_NONSTD_FUNC_CALLER_PROPERTY) #error config option DUK_USE_TAILCALL conflicts with option DUK_USE_NONSTD_FUNC_CALLER_PROPERTY (which is also defined) #endif #if defined(DUK_USE_UNALIGNED_ACCESSES_POSSIBLE) #error unsupported config option used (option has been removed): DUK_USE_UNALIGNED_ACCESSES_POSSIBLE #endif #if defined(DUK_USE_UNDERSCORE_SETJMP) #error unsupported config option used (option has been removed): DUK_USE_UNDERSCORE_SETJMP #endif #if defined(DUK_USE_USER_DECLARE) #error unsupported config option used (option has been removed): DUK_USE_USER_DECLARE #endif #if defined(DUK_USE_USER_INITJS) #error unsupported config option used (option has been removed): DUK_USE_USER_INITJS #endif #if defined(DUK_USE_CPP_EXCEPTIONS) && !defined(__cplusplus) #error DUK_USE_CPP_EXCEPTIONS enabled but not compiling with a C++ compiler #endif /* * Convert DUK_USE_BYTEORDER, from whatever source, into currently used * internal defines. If detection failed, #error out. */ #if defined(DUK_USE_BYTEORDER) #if (DUK_USE_BYTEORDER == 1) #define DUK_USE_INTEGER_LE #define DUK_USE_DOUBLE_LE #elif (DUK_USE_BYTEORDER == 2) #define DUK_USE_INTEGER_LE /* integer endianness is little on purpose */ #define DUK_USE_DOUBLE_ME #elif (DUK_USE_BYTEORDER == 3) #define DUK_USE_INTEGER_BE #define DUK_USE_DOUBLE_BE #else #error unsupported: byte order invalid #endif /* byte order */ #else #error unsupported: byte order detection failed #endif /* defined(DUK_USE_BYTEORDER) */ #endif /* DUK_CONFIG_H_INCLUDED */
codelabs/ffigen_codelab/step_05/src/duk_config.h/0
{ "file_path": "codelabs/ffigen_codelab/step_05/src/duk_config.h", "repo_id": "codelabs", "token_count": 53486 }
24
org.gradle.jvmargs=-Xmx4G android.useAndroidX=true android.enableJetifier=true
codelabs/ffigen_codelab/step_07/example/android/gradle.properties/0
{ "file_path": "codelabs/ffigen_codelab/step_07/example/android/gradle.properties", "repo_id": "codelabs", "token_count": 30 }
25
import 'package:flutter/material.dart'; class HomeScreen extends StatelessWidget { const HomeScreen({super.key}); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( automaticallyImplyLeading: false, ), body: Center( child: Column( children: [ Image.asset('dash.png'), Text( 'Welcome!', style: Theme.of(context).textTheme.displaySmall, ), ], ), ), ); } }
codelabs/firebase-auth-flutterfire-ui/start/lib/home.dart/0
{ "file_path": "codelabs/firebase-auth-flutterfire-ui/start/lib/home.dart", "repo_id": "codelabs", "token_count": 259 }
26
name: complete description: "A new Flutter project." publish_to: 'none' version: 0.1.0 environment: sdk: '>=3.3.0-279.2.beta <4.0.0' dependencies: firebase_auth: ^4.17.2 firebase_core: ^2.25.2 firebase_ui_auth: ^1.12.1 firebase_ui_oauth_google: ^1.2.17 flutter: sdk: flutter google_sign_in: ^6.2.1 dev_dependencies: flutter_test: sdk: flutter flutter_lints: ^3.0.0 flutter: uses-material-design: true assets: - assets/
codelabs/firebase-auth-flutterfire-ui/start/pubspec.yaml/0
{ "file_path": "codelabs/firebase-auth-flutterfire-ui/start/pubspec.yaml", "repo_id": "codelabs", "token_count": 213 }
27
{ "version": "10.6.0", "firestore": { "version": "1.14.1", "path": "firestore_export", "metadata_file": "firestore_export/firestore_export.overall_export_metadata" }, "auth": { "version": "10.6.0", "path": "auth_export" } }
codelabs/firebase-emulator-suite/firebase_seed/firebase-export-metadata.json/0
{ "file_path": "codelabs/firebase-emulator-suite/firebase_seed/firebase-export-metadata.json", "repo_id": "codelabs", "token_count": 114 }
28
#import "GeneratedPluginRegistrant.h"
codelabs/firebase-emulator-suite/start/ios/Runner/Runner-Bridging-Header.h/0
{ "file_path": "codelabs/firebase-emulator-suite/start/ios/Runner/Runner-Bridging-Header.h", "repo_id": "codelabs", "token_count": 13 }
29
org.gradle.jvmargs=-Xmx4G android.useAndroidX=true android.enableJetifier=true
codelabs/firebase-get-to-know-flutter/step_06/android/gradle.properties/0
{ "file_path": "codelabs/firebase-get-to-know-flutter/step_06/android/gradle.properties", "repo_id": "codelabs", "token_count": 30 }
30
#ifndef FLUTTER_PLUGIN_WINDOW_TO_FRONT_PLUGIN_C_API_H_ #define FLUTTER_PLUGIN_WINDOW_TO_FRONT_PLUGIN_C_API_H_ #include <flutter_plugin_registrar.h> #ifdef FLUTTER_PLUGIN_IMPL #define FLUTTER_PLUGIN_EXPORT __declspec(dllexport) #else #define FLUTTER_PLUGIN_EXPORT __declspec(dllimport) #endif #if defined(__cplusplus) extern "C" { #endif FLUTTER_PLUGIN_EXPORT void WindowToFrontPluginCApiRegisterWithRegistrar( FlutterDesktopPluginRegistrarRef registrar); #if defined(__cplusplus) } // extern "C" #endif #endif // FLUTTER_PLUGIN_WINDOW_TO_FRONT_PLUGIN_C_API_H_
codelabs/github-client/window_to_front/windows/include/window_to_front/window_to_front_plugin_c_api.h/0
{ "file_path": "codelabs/github-client/window_to_front/windows/include/window_to_front/window_to_front_plugin_c_api.h", "repo_id": "codelabs", "token_count": 254 }
31
#include "../../Flutter/Flutter-Release.xcconfig" #include "Warnings.xcconfig"
codelabs/haiku_generator/step0/macos/Runner/Configs/Release.xcconfig/0
{ "file_path": "codelabs/haiku_generator/step0/macos/Runner/Configs/Release.xcconfig", "repo_id": "codelabs", "token_count": 32 }
32
#include "../../Flutter/Flutter-Release.xcconfig" #include "Warnings.xcconfig"
codelabs/haiku_generator/step2/macos/Runner/Configs/Release.xcconfig/0
{ "file_path": "codelabs/haiku_generator/step2/macos/Runner/Configs/Release.xcconfig", "repo_id": "codelabs", "token_count": 32 }
33
#import "GeneratedPluginRegistrant.h"
codelabs/homescreen_codelab/step_04/ios/Runner/Runner-Bridging-Header.h/0
{ "file_path": "codelabs/homescreen_codelab/step_04/ios/Runner/Runner-Bridging-Header.h", "repo_id": "codelabs", "token_count": 13 }
34
include: ../../../analysis_options.yaml
codelabs/in_app_purchases/complete/app/analysis_options.yaml/0
{ "file_path": "codelabs/in_app_purchases/complete/app/analysis_options.yaml", "repo_id": "codelabs", "token_count": 13 }
35
#import "GeneratedPluginRegistrant.h"
codelabs/in_app_purchases/complete/app/ios/Runner/Runner-Bridging-Header.h/0
{ "file_path": "codelabs/in_app_purchases/complete/app/ios/Runner/Runner-Bridging-Header.h", "repo_id": "codelabs", "token_count": 13 }
36
org.gradle.jvmargs=-Xmx4G android.useAndroidX=true android.enableJetifier=true
codelabs/namer/step_05_b_extract/android/gradle.properties/0
{ "file_path": "codelabs/namer/step_05_b_extract/android/gradle.properties", "repo_id": "codelabs", "token_count": 30 }
37
#include "Generated.xcconfig"
codelabs/namer/step_05_d_theme/ios/Flutter/Release.xcconfig/0
{ "file_path": "codelabs/namer/step_05_d_theme/ios/Flutter/Release.xcconfig", "repo_id": "codelabs", "token_count": 12 }
38
#include "ephemeral/Flutter-Generated.xcconfig"
codelabs/namer/step_05_d_theme/macos/Flutter/Flutter-Release.xcconfig/0
{ "file_path": "codelabs/namer/step_05_d_theme/macos/Flutter/Flutter-Release.xcconfig", "repo_id": "codelabs", "token_count": 19 }
39
#include "../../Flutter/Flutter-Release.xcconfig" #include "Warnings.xcconfig"
codelabs/namer/step_05_e_text_style/macos/Runner/Configs/Release.xcconfig/0
{ "file_path": "codelabs/namer/step_05_e_text_style/macos/Runner/Configs/Release.xcconfig", "repo_id": "codelabs", "token_count": 32 }
40
#include "Generated.xcconfig"
codelabs/namer/step_05_i_optional_changes/ios/Flutter/Debug.xcconfig/0
{ "file_path": "codelabs/namer/step_05_i_optional_changes/ios/Flutter/Debug.xcconfig", "repo_id": "codelabs", "token_count": 12 }
41
#include "ephemeral/Flutter-Generated.xcconfig"
codelabs/namer/step_05_i_optional_changes/macos/Flutter/Flutter-Debug.xcconfig/0
{ "file_path": "codelabs/namer/step_05_i_optional_changes/macos/Flutter/Flutter-Debug.xcconfig", "repo_id": "codelabs", "token_count": 19 }
42
#import "GeneratedPluginRegistrant.h"
codelabs/namer/step_06_a_business_logic/ios/Runner/Runner-Bridging-Header.h/0
{ "file_path": "codelabs/namer/step_06_a_business_logic/ios/Runner/Runner-Bridging-Header.h", "repo_id": "codelabs", "token_count": 13 }
43
#include "../../Flutter/Flutter-Debug.xcconfig" #include "Warnings.xcconfig"
codelabs/namer/step_06_a_business_logic/macos/Runner/Configs/Debug.xcconfig/0
{ "file_path": "codelabs/namer/step_06_a_business_logic/macos/Runner/Configs/Debug.xcconfig", "repo_id": "codelabs", "token_count": 32 }
44
org.gradle.jvmargs=-Xmx4G android.useAndroidX=true android.enableJetifier=true
codelabs/namer/step_08/android/gradle.properties/0
{ "file_path": "codelabs/namer/step_08/android/gradle.properties", "repo_id": "codelabs", "token_count": 30 }
45
org.gradle.jvmargs=-Xmx4G android.useAndroidX=true android.enableJetifier=true
codelabs/next-gen-ui/step_01/android/gradle.properties/0
{ "file_path": "codelabs/next-gen-ui/step_01/android/gradle.properties", "repo_id": "codelabs", "token_count": 30 }
46
#include "../../Flutter/Flutter-Debug.xcconfig" #include "Warnings.xcconfig"
codelabs/next-gen-ui/step_04_d/macos/Runner/Configs/Debug.xcconfig/0
{ "file_path": "codelabs/next-gen-ui/step_04_d/macos/Runner/Configs/Debug.xcconfig", "repo_id": "codelabs", "token_count": 32 }
47
org.gradle.jvmargs=-Xmx4G android.useAndroidX=true android.enableJetifier=true
codelabs/testing_codelab/step_03/android/gradle.properties/0
{ "file_path": "codelabs/testing_codelab/step_03/android/gradle.properties", "repo_id": "codelabs", "token_count": 30 }
48
#include "../../Flutter/Flutter-Release.xcconfig" #include "Warnings.xcconfig"
codelabs/testing_codelab/step_05/macos/Runner/Configs/Release.xcconfig/0
{ "file_path": "codelabs/testing_codelab/step_05/macos/Runner/Configs/Release.xcconfig", "repo_id": "codelabs", "token_count": 32 }
49
#import "GeneratedPluginRegistrant.h"
codelabs/tfagents-flutter/step4/frontend/ios/Runner/Runner-Bridging-Header.h/0
{ "file_path": "codelabs/tfagents-flutter/step4/frontend/ios/Runner/Runner-Bridging-Header.h", "repo_id": "codelabs", "token_count": 13 }
50
#include "../../Flutter/Flutter-Debug.xcconfig" #include "Warnings.xcconfig"
codelabs/tfagents-flutter/step4/frontend/macos/Runner/Configs/Debug.xcconfig/0
{ "file_path": "codelabs/tfagents-flutter/step4/frontend/macos/Runner/Configs/Debug.xcconfig", "repo_id": "codelabs", "token_count": 32 }
51
#include "Generated.xcconfig"
codelabs/tfagents-flutter/step5/frontend/ios/Flutter/Debug.xcconfig/0
{ "file_path": "codelabs/tfagents-flutter/step5/frontend/ios/Flutter/Debug.xcconfig", "repo_id": "codelabs", "token_count": 12 }
52
#include "ephemeral/Flutter-Generated.xcconfig"
codelabs/tfagents-flutter/step5/frontend/macos/Flutter/Flutter-Debug.xcconfig/0
{ "file_path": "codelabs/tfagents-flutter/step5/frontend/macos/Flutter/Flutter-Debug.xcconfig", "repo_id": "codelabs", "token_count": 19 }
53