Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions add_to_app/ios_content_resizing/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# ios_content_resizing

Embeds an instance of Flutter into an existing iOS app that will dynamically resize itself based off of it's content.

## Description

This sample showcases the integration of a self-resizing Flutter view within a native UIKit environment. The Flutter module features an expanding column of widgets. As items are added, the hosting UIView will automatically adjusts its [intrinsicContentSize](https://developer.apple.com/documentation/uikit/uiview/intrinsiccontentsize) to accommodate the new content size.

## tl;dr

If you're just looking to get up and running quickly, these bash commands will
fetch packages and set up dependencies (note that the above commands assume
you're building for both iOS and Android, with both toolchains installed):

```bash
#!/bin/bash
set -e

cd flutter_module/
flutter pub get

# For iOS builds:
cd ../ios_content_resizing
pod install
open ios_content_resizing.xcworkspace
# Then, click "Run" in Xcode to launch the app into your Simulator or device
```

## Requirements

* Flutter
* iOS
* Xcode
* Cocoapods

## Questions/issues

See [add_to_app/README.md](../README.md) for further help.
48 changes: 48 additions & 0 deletions add_to_app/ios_content_resizing/flutter_module/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
.DS_Store
.dart_tool/

.pub/

.idea/
.vagrant/
.sconsign.dblite
.svn/

migrate_working_dir/

*.swp
profile

DerivedData/

.generated/

*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3

!default.pbxuser
!default.mode1v3
!default.mode2v3
!default.perspectivev3

xcuserdata

*.moved-aside

*.pyc
*sync/
Icon?
.tags*

build/
.android/
.ios/
.flutter-plugins-dependencies

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json
10 changes: 10 additions & 0 deletions add_to_app/ios_content_resizing/flutter_module/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: "27ccc2e66f3fd85ad388e3ba038a89251aef41b7"
channel: "master"

project_type: module
11 changes: 11 additions & 0 deletions add_to_app/ios_content_resizing/flutter_module/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# flutter_module

A new Flutter module project.

## Getting Started

For help getting started with Flutter development, view the online
[documentation](https://flutter.dev/).

For instructions integrating Flutter modules to your existing applications,
see the [add-to-app documentation](https://flutter.dev/to/add-to-app).
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include: package:flutter_lints/flutter.yaml

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
52 changes: 52 additions & 0 deletions add_to_app/ios_content_resizing/flutter_module/lib/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright 2014 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';

void main() {
runApp(const ResizeApp());
}

class ResizeApp extends StatefulWidget {
const ResizeApp({super.key});

@override
State<ResizeApp> createState() => _ResizeAppState();
}

class _ResizeAppState extends State<ResizeApp> {
int _listSize = 1;
void _addToList() {
setState(() {
_listSize++;
});
}

@override
Widget build(BuildContext context) {
return Center(
heightFactor: 1,
child: Directionality(
textDirection: TextDirection.ltr,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
for (int i = 0; i < _listSize; i++)
Container(color: HSVColor.fromAHSV(1, (10.0 * i), 1, 1).toColor(), height: 50, width: 200,
child: Center(
child: Text(
'Flutter Widget $i',
style: const TextStyle(fontSize: 16, color: Colors.black),
),
)),
TextButton(
onPressed: _addToList,
child: Text('Listception!'),
)
],
),
),
);
}
}
87 changes: 87 additions & 0 deletions add_to_app/ios_content_resizing/flutter_module/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: flutter_module
description: "A new Flutter module project."

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
#
# This version is used _only_ for the Runner app, which is used if you just do
# a `flutter run`. It has no impact on any other native host app that you embed
# your Flutter project into.
version: 1.0.0+1

environment:
sdk: ^3.11.0-200.1.beta

dependencies:
flutter:
sdk: flutter

# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.8

dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^6.0.0

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true

# To add Flutter specific assets to your application, add an assets section,
# like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg

# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/to/resolution-aware-images

# For details regarding adding assets from package dependencies, see
# https://flutter.dev/to/asset-from-package

# To add Flutter specific custom fonts to your application, add a fonts
# section here, in this "flutter" section. Each entry in this list should
# have a "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/to/font-from-package


# This section identifies your Flutter project as a module meant for
# embedding in a native host app. These identifiers should _not_ ordinarily
# be changed after generation - they are used to ensure that the tooling can
# maintain consistency when adding or modifying assets and plugins.
# They also do not have any bearing on your native host application's
# identifiers, which may be completely independent or the same as these.
module:
androidX: true
androidPackage: com.example.flutter_module
iosBundleIdentifier: com.example.flutterModule
32 changes: 32 additions & 0 deletions add_to_app/ios_content_resizing/ios_content_resizing/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Uncomment the next line to define a global platform for your project
# platform :ios, '15.0'

flutter_application_path = '../flutter_module'
load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')


target 'ios_content_resizing' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!

# Pods for ios_content_resizing

install_all_flutter_pods(flutter_application_path)

target 'ios_content_resizingTests' do
inherit! :search_paths
# Pods for testing
end

target 'ios_content_resizingUITests' do
# Pods for testing
end

end


post_install do |installer|
flutter_post_install(installer) if defined?(flutter_post_install)
end


Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading