mirror of
https://github.com/flutter/samples.git
synced 2025-11-10 14:58:34 +00:00
Update for Flutter 3.10 beta (#1746)
## Pre-launch Checklist - [x] I read the [Flutter Style Guide] _recently_, and have followed its advice. - [x] I signed the [CLA]. - [x] I read the [Contributors Guide]. - [x] I updated/added relevant documentation (doc comments with `///`). - [ ] All existing and new tests are passing. --------- Co-authored-by: David Iglesias <ditman@gmail.com> Co-authored-by: Mark Thompson <2554588+MarkTechson@users.noreply.github.com> Co-authored-by: John Ryan <ryjohn@google.com>
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
# This file should be version controlled.
|
||||
|
||||
version:
|
||||
revision: 0df8557c56a182d31fa024eeb08c428ae52edf7f
|
||||
revision: a14a4eac6132065fcbd853a2ff376e6911cdb2ea
|
||||
channel: beta
|
||||
|
||||
project_type: app
|
||||
@@ -13,26 +13,26 @@ project_type: app
|
||||
migration:
|
||||
platforms:
|
||||
- platform: root
|
||||
create_revision: 0df8557c56a182d31fa024eeb08c428ae52edf7f
|
||||
base_revision: 0df8557c56a182d31fa024eeb08c428ae52edf7f
|
||||
create_revision: a14a4eac6132065fcbd853a2ff376e6911cdb2ea
|
||||
base_revision: a14a4eac6132065fcbd853a2ff376e6911cdb2ea
|
||||
- platform: android
|
||||
create_revision: 0df8557c56a182d31fa024eeb08c428ae52edf7f
|
||||
base_revision: 0df8557c56a182d31fa024eeb08c428ae52edf7f
|
||||
create_revision: a14a4eac6132065fcbd853a2ff376e6911cdb2ea
|
||||
base_revision: a14a4eac6132065fcbd853a2ff376e6911cdb2ea
|
||||
- platform: ios
|
||||
create_revision: 0df8557c56a182d31fa024eeb08c428ae52edf7f
|
||||
base_revision: 0df8557c56a182d31fa024eeb08c428ae52edf7f
|
||||
create_revision: a14a4eac6132065fcbd853a2ff376e6911cdb2ea
|
||||
base_revision: a14a4eac6132065fcbd853a2ff376e6911cdb2ea
|
||||
- platform: linux
|
||||
create_revision: 0df8557c56a182d31fa024eeb08c428ae52edf7f
|
||||
base_revision: 0df8557c56a182d31fa024eeb08c428ae52edf7f
|
||||
create_revision: a14a4eac6132065fcbd853a2ff376e6911cdb2ea
|
||||
base_revision: a14a4eac6132065fcbd853a2ff376e6911cdb2ea
|
||||
- platform: macos
|
||||
create_revision: 0df8557c56a182d31fa024eeb08c428ae52edf7f
|
||||
base_revision: 0df8557c56a182d31fa024eeb08c428ae52edf7f
|
||||
create_revision: a14a4eac6132065fcbd853a2ff376e6911cdb2ea
|
||||
base_revision: a14a4eac6132065fcbd853a2ff376e6911cdb2ea
|
||||
- platform: web
|
||||
create_revision: 0df8557c56a182d31fa024eeb08c428ae52edf7f
|
||||
base_revision: 0df8557c56a182d31fa024eeb08c428ae52edf7f
|
||||
create_revision: a14a4eac6132065fcbd853a2ff376e6911cdb2ea
|
||||
base_revision: a14a4eac6132065fcbd853a2ff376e6911cdb2ea
|
||||
- platform: windows
|
||||
create_revision: 0df8557c56a182d31fa024eeb08c428ae52edf7f
|
||||
base_revision: 0df8557c56a182d31fa024eeb08c428ae52edf7f
|
||||
create_revision: a14a4eac6132065fcbd853a2ff376e6911cdb2ea
|
||||
base_revision: a14a4eac6132065fcbd853a2ff376e6911cdb2ea
|
||||
|
||||
# User provided section
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ apply plugin: 'kotlin-android'
|
||||
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
|
||||
|
||||
android {
|
||||
namespace "com.example.simplistic_calculator"
|
||||
compileSdkVersion flutter.compileSdkVersion
|
||||
ndkVersion flutter.ndkVersion
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.example.simplistic_calculator">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- The INTERNET permission is required for development. Specifically,
|
||||
the Flutter tool needs it to communicate with the running application
|
||||
to allow setting breakpoints, to provide hot reload, etc.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.example.simplistic_calculator">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<application
|
||||
android:label="simplistic_calculator"
|
||||
android:name="${applicationName}"
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.example.simplistic_calculator">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- The INTERNET permission is required for development. Specifically,
|
||||
the Flutter tool needs it to communicate with the running application
|
||||
to allow setting breakpoints, to provide hot reload, etc.
|
||||
|
||||
@@ -26,6 +26,6 @@ subprojects {
|
||||
project.evaluationDependsOn(':app')
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
tasks.register("clean", Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
|
||||
#include "Generated.xcconfig"
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
|
||||
#include "Generated.xcconfig"
|
||||
|
||||
44
simplistic_calculator/ios/Podfile
Normal file
44
simplistic_calculator/ios/Podfile
Normal file
@@ -0,0 +1,44 @@
|
||||
# Uncomment this line to define a global platform for your project
|
||||
# platform :ios, '11.0'
|
||||
|
||||
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
|
||||
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
|
||||
|
||||
project 'Runner', {
|
||||
'Debug' => :debug,
|
||||
'Profile' => :release,
|
||||
'Release' => :release,
|
||||
}
|
||||
|
||||
def flutter_root
|
||||
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
|
||||
unless File.exist?(generated_xcode_build_settings_path)
|
||||
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
|
||||
end
|
||||
|
||||
File.foreach(generated_xcode_build_settings_path) do |line|
|
||||
matches = line.match(/FLUTTER_ROOT\=(.*)/)
|
||||
return matches[1].strip if matches
|
||||
end
|
||||
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
|
||||
end
|
||||
|
||||
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
|
||||
|
||||
flutter_ios_podfile_setup
|
||||
|
||||
target 'Runner' do
|
||||
use_frameworks!
|
||||
use_modular_headers!
|
||||
|
||||
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
|
||||
target 'RunnerTests' do
|
||||
inherit! :search_paths
|
||||
end
|
||||
end
|
||||
|
||||
post_install do |installer|
|
||||
installer.pods_project.targets.each do |target|
|
||||
flutter_additional_ios_build_settings(target)
|
||||
end
|
||||
end
|
||||
@@ -101,29 +101,30 @@ class CalculatorEngine extends StateNotifier<CalculatorState> {
|
||||
final exp = parser.parse(state.buffer);
|
||||
final result = exp.evaluate(EvaluationType.REAL, cm) as double;
|
||||
|
||||
if (result.isInfinite) {
|
||||
state = state.copyWith(
|
||||
error: 'Result is Infinite',
|
||||
buffer: '',
|
||||
mode: CalculatorEngineMode.result,
|
||||
);
|
||||
} else if (result.isNaN) {
|
||||
state = state.copyWith(
|
||||
error: 'Result is Not a Number',
|
||||
buffer: '',
|
||||
mode: CalculatorEngineMode.result,
|
||||
);
|
||||
} else {
|
||||
final resultStr = result.ceil() == result
|
||||
? result.toInt().toString()
|
||||
: result.toString();
|
||||
state = state.copyWith(
|
||||
buffer: resultStr,
|
||||
switch (result) {
|
||||
case double(isInfinite: true):
|
||||
state = state.copyWith(
|
||||
error: 'Result is Infinite',
|
||||
buffer: '',
|
||||
mode: CalculatorEngineMode.result,
|
||||
calcHistory: [
|
||||
'${state.buffer} = $resultStr',
|
||||
...state.calcHistory,
|
||||
]);
|
||||
);
|
||||
case double(isNaN: true):
|
||||
state = state.copyWith(
|
||||
error: 'Result is Not a Number',
|
||||
buffer: '',
|
||||
mode: CalculatorEngineMode.result,
|
||||
);
|
||||
default:
|
||||
final resultStr = result.ceil() == result
|
||||
? result.toInt().toString()
|
||||
: result.toString();
|
||||
state = state.copyWith(
|
||||
buffer: resultStr,
|
||||
mode: CalculatorEngineMode.result,
|
||||
calcHistory: [
|
||||
'${state.buffer} = $resultStr',
|
||||
...state.calcHistory,
|
||||
]);
|
||||
}
|
||||
} catch (err) {
|
||||
state = state.copyWith(
|
||||
@@ -465,9 +466,10 @@ class CalcButton extends ConsumerWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final buttonConstructor = type == CalcButtonType.elevated
|
||||
? ElevatedButton.new
|
||||
: OutlinedButton.new;
|
||||
final buttonConstructor = switch (type) {
|
||||
CalcButtonType.elevated => ElevatedButton.new,
|
||||
_ => OutlinedButton.new,
|
||||
};
|
||||
|
||||
return SizedBox.expand(
|
||||
child: Padding(
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// Generated file. Do not edit.
|
||||
//
|
||||
|
||||
// clang-format off
|
||||
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <window_size/window_size_plugin.h>
|
||||
|
||||
void fl_register_plugins(FlPluginRegistry* registry) {
|
||||
g_autoptr(FlPluginRegistrar) window_size_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "WindowSizePlugin");
|
||||
window_size_plugin_register_with_registrar(window_size_registrar);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// Generated file. Do not edit.
|
||||
//
|
||||
|
||||
// clang-format off
|
||||
|
||||
#ifndef GENERATED_PLUGIN_REGISTRANT_
|
||||
#define GENERATED_PLUGIN_REGISTRANT_
|
||||
|
||||
#include <flutter_linux/flutter_linux.h>
|
||||
|
||||
// Registers Flutter plugins.
|
||||
void fl_register_plugins(FlPluginRegistry* registry);
|
||||
|
||||
#endif // GENERATED_PLUGIN_REGISTRANT_
|
||||
24
simplistic_calculator/linux/flutter/generated_plugins.cmake
Normal file
24
simplistic_calculator/linux/flutter/generated_plugins.cmake
Normal file
@@ -0,0 +1,24 @@
|
||||
#
|
||||
# Generated file, do not edit.
|
||||
#
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
window_size
|
||||
)
|
||||
|
||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||
)
|
||||
|
||||
set(PLUGIN_BUNDLED_LIBRARIES)
|
||||
|
||||
foreach(plugin ${FLUTTER_PLUGIN_LIST})
|
||||
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin})
|
||||
target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
|
||||
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
|
||||
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
|
||||
endforeach(plugin)
|
||||
|
||||
foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
|
||||
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
|
||||
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
|
||||
endforeach(ffi_plugin)
|
||||
@@ -1 +1,2 @@
|
||||
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
|
||||
#include "ephemeral/Flutter-Generated.xcconfig"
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
|
||||
#include "ephemeral/Flutter-Generated.xcconfig"
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// Generated file. Do not edit.
|
||||
//
|
||||
|
||||
import FlutterMacOS
|
||||
import Foundation
|
||||
|
||||
import window_size
|
||||
|
||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
WindowSizePlugin.register(with: registry.registrar(forPlugin: "WindowSizePlugin"))
|
||||
}
|
||||
43
simplistic_calculator/macos/Podfile
Normal file
43
simplistic_calculator/macos/Podfile
Normal file
@@ -0,0 +1,43 @@
|
||||
platform :osx, '10.14'
|
||||
|
||||
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
|
||||
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
|
||||
|
||||
project 'Runner', {
|
||||
'Debug' => :debug,
|
||||
'Profile' => :release,
|
||||
'Release' => :release,
|
||||
}
|
||||
|
||||
def flutter_root
|
||||
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__)
|
||||
unless File.exist?(generated_xcode_build_settings_path)
|
||||
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first"
|
||||
end
|
||||
|
||||
File.foreach(generated_xcode_build_settings_path) do |line|
|
||||
matches = line.match(/FLUTTER_ROOT\=(.*)/)
|
||||
return matches[1].strip if matches
|
||||
end
|
||||
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\""
|
||||
end
|
||||
|
||||
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
|
||||
|
||||
flutter_macos_podfile_setup
|
||||
|
||||
target 'Runner' do
|
||||
use_frameworks!
|
||||
use_modular_headers!
|
||||
|
||||
flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__))
|
||||
target 'RunnerTests' do
|
||||
inherit! :search_paths
|
||||
end
|
||||
end
|
||||
|
||||
post_install do |installer|
|
||||
installer.pods_project.targets.each do |target|
|
||||
flutter_additional_macos_build_settings(target)
|
||||
end
|
||||
end
|
||||
@@ -3,7 +3,7 @@ import FlutterMacOS
|
||||
|
||||
class MainFlutterWindow: NSWindow {
|
||||
override func awakeFromNib() {
|
||||
let flutterViewController = FlutterViewController.init()
|
||||
let flutterViewController = FlutterViewController()
|
||||
let windowFrame = self.frame
|
||||
self.contentViewController = flutterViewController
|
||||
self.setFrame(windowFrame, display: true)
|
||||
|
||||
@@ -4,13 +4,13 @@ publish_to: 'none'
|
||||
version: 1.0.0+1
|
||||
|
||||
environment:
|
||||
sdk: '>=2.19.5 <4.0.0'
|
||||
sdk: ^3.0.0-0
|
||||
|
||||
dependencies:
|
||||
auto_size_text: ^3.0.0
|
||||
cupertino_icons: ^1.0.2
|
||||
fluent_ui: ^4.0.0
|
||||
fluentui_system_icons: ^1.1.168
|
||||
fluent_ui: ^3.9.1
|
||||
fluentui_system_icons: ^1.1.190
|
||||
flutter:
|
||||
sdk: flutter
|
||||
flutter_layout_grid: ^2.0.1
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// Generated file. Do not edit.
|
||||
//
|
||||
|
||||
// clang-format off
|
||||
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <window_size/window_size_plugin.h>
|
||||
|
||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||
WindowSizePluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("WindowSizePlugin"));
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// Generated file. Do not edit.
|
||||
//
|
||||
|
||||
// clang-format off
|
||||
|
||||
#ifndef GENERATED_PLUGIN_REGISTRANT_
|
||||
#define GENERATED_PLUGIN_REGISTRANT_
|
||||
|
||||
#include <flutter/plugin_registry.h>
|
||||
|
||||
// Registers Flutter plugins.
|
||||
void RegisterPlugins(flutter::PluginRegistry* registry);
|
||||
|
||||
#endif // GENERATED_PLUGIN_REGISTRANT_
|
||||
@@ -0,0 +1,24 @@
|
||||
#
|
||||
# Generated file, do not edit.
|
||||
#
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
window_size
|
||||
)
|
||||
|
||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||
)
|
||||
|
||||
set(PLUGIN_BUNDLED_LIBRARIES)
|
||||
|
||||
foreach(plugin ${FLUTTER_PLUGIN_LIST})
|
||||
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin})
|
||||
target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
|
||||
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
|
||||
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
|
||||
endforeach(plugin)
|
||||
|
||||
foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
|
||||
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
|
||||
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
|
||||
endforeach(ffi_plugin)
|
||||
Reference in New Issue
Block a user