├── ios ├── Flutter │ ├── Debug.xcconfig │ ├── Release.xcconfig │ └── AppFrameworkInfo.plist ├── Runner │ ├── Runner-Bridging-Header.h │ ├── Assets.xcassets │ │ ├── LaunchImage.imageset │ │ │ ├── LaunchImage.png │ │ │ ├── LaunchImage@2x.png │ │ │ ├── LaunchImage@3x.png │ │ │ ├── README.md │ │ │ └── Contents.json │ │ └── AppIcon.appiconset │ │ │ ├── Icon-App-20x20@1x.png │ │ │ ├── Icon-App-20x20@2x.png │ │ │ ├── Icon-App-20x20@3x.png │ │ │ ├── Icon-App-29x29@1x.png │ │ │ ├── Icon-App-29x29@2x.png │ │ │ ├── Icon-App-29x29@3x.png │ │ │ ├── Icon-App-40x40@1x.png │ │ │ ├── Icon-App-40x40@2x.png │ │ │ ├── Icon-App-40x40@3x.png │ │ │ ├── Icon-App-60x60@2x.png │ │ │ ├── Icon-App-60x60@3x.png │ │ │ ├── Icon-App-76x76@1x.png │ │ │ ├── Icon-App-76x76@2x.png │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ ├── Icon-App-83.5x83.5@2x.png │ │ │ └── Contents.json │ ├── AppDelegate.swift │ ├── Base.lproj │ │ ├── Main.storyboard │ │ └── LaunchScreen.storyboard │ └── Info.plist ├── Runner.xcodeproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── WorkspaceSettings.xcsettings │ │ │ └── IDEWorkspaceChecks.plist │ ├── xcshareddata │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ └── project.pbxproj ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ ├── WorkspaceSettings.xcsettings │ │ └── IDEWorkspaceChecks.plist └── .gitignore ├── part1-example.gif ├── part2-example.gif ├── part3-example.gif ├── android ├── gradle.properties ├── app │ ├── src │ │ ├── main │ │ │ ├── res │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── drawable │ │ │ │ │ └── launch_background.xml │ │ │ │ ├── drawable-v21 │ │ │ │ │ └── launch_background.xml │ │ │ │ ├── values │ │ │ │ │ └── styles.xml │ │ │ │ └── values-night │ │ │ │ │ └── styles.xml │ │ │ ├── kotlin │ │ │ │ └── dev │ │ │ │ │ └── matrix │ │ │ │ │ └── custom_widgets │ │ │ │ │ └── MainActivity.kt │ │ │ └── AndroidManifest.xml │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ └── profile │ │ │ └── AndroidManifest.xml │ └── build.gradle ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── .gitignore ├── settings.gradle └── build.gradle ├── .metadata ├── lib ├── demo_widget.dart ├── part4_overflow_toolbar │ ├── overflow_toolbar_demo.dart │ └── overflow_toolbar.dart ├── part2a_child_size │ ├── child_size.dart │ └── child_size_demo.dart ├── part2b_child_size │ ├── child_size_demo.dart │ └── child_size.dart ├── part3b_simple_overlay │ ├── simple_overlay_demo.dart │ └── simple_overlay.dart ├── part3a_simple_overlay │ ├── simple_overlay_demo.dart │ └── simple_overlay.dart ├── main.dart └── part1_ellipsized_text │ ├── ellipsized_text_demo.dart │ └── ellipsized_text.dart ├── .gitignore ├── test └── widget_test.dart ├── README.md ├── pubspec.yaml └── pubspec.lock /ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /part1-example.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MatrixDev/Flutter-CustomWidgets/HEAD/part1-example.gif -------------------------------------------------------------------------------- /part2-example.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MatrixDev/Flutter-CustomWidgets/HEAD/part2-example.gif -------------------------------------------------------------------------------- /part3-example.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MatrixDev/Flutter-CustomWidgets/HEAD/part3-example.gif -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MatrixDev/Flutter-CustomWidgets/HEAD/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MatrixDev/Flutter-CustomWidgets/HEAD/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MatrixDev/Flutter-CustomWidgets/HEAD/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MatrixDev/Flutter-CustomWidgets/HEAD/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MatrixDev/Flutter-CustomWidgets/HEAD/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MatrixDev/Flutter-CustomWidgets/HEAD/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MatrixDev/Flutter-CustomWidgets/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MatrixDev/Flutter-CustomWidgets/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MatrixDev/Flutter-CustomWidgets/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MatrixDev/Flutter-CustomWidgets/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MatrixDev/Flutter-CustomWidgets/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MatrixDev/Flutter-CustomWidgets/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MatrixDev/Flutter-CustomWidgets/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MatrixDev/Flutter-CustomWidgets/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MatrixDev/Flutter-CustomWidgets/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MatrixDev/Flutter-CustomWidgets/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MatrixDev/Flutter-CustomWidgets/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MatrixDev/Flutter-CustomWidgets/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MatrixDev/Flutter-CustomWidgets/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MatrixDev/Flutter-CustomWidgets/HEAD/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MatrixDev/Flutter-CustomWidgets/HEAD/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MatrixDev/Flutter-CustomWidgets/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MatrixDev/Flutter-CustomWidgets/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /android/app/src/main/kotlin/dev/matrix/custom_widgets/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package dev.matrix.custom_widgets 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip 7 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: b22742018b3edf16c6cadd7b76d9db5e7f9064b5 8 | channel: stable 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 4 | def properties = new Properties() 5 | 6 | assert localPropertiesFile.exists() 7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 8 | 9 | def flutterSdkPath = properties.getProperty("flutter.sdk") 10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 12 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/demo_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter/widgets.dart'; 3 | 4 | abstract class DemoWidget extends StatefulWidget { 5 | String get title; 6 | 7 | const DemoWidget(); 8 | 9 | @override 10 | DemoWidgetState createState(); 11 | } 12 | 13 | abstract class DemoWidgetState extends State { 14 | Widget buildContent(); 15 | 16 | @override 17 | Widget build(BuildContext context) { 18 | return Scaffold( 19 | appBar: AppBar(title: Text(widget.title)), 20 | body: Padding( 21 | padding: const EdgeInsets.all(32), 22 | child: buildContent(), 23 | ), 24 | ); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.3.50' 3 | repositories { 4 | google() 5 | jcenter() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:4.1.0' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | jcenter() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | project.evaluationDependsOn(':app') 25 | } 26 | 27 | task clean(type: Delete) { 28 | delete rootProject.buildDir 29 | } 30 | -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | *.mode1v3 2 | *.mode2v3 3 | *.moved-aside 4 | *.pbxuser 5 | *.perspectivev3 6 | **/*sync/ 7 | .sconsign.dblite 8 | .tags* 9 | **/.vagrant/ 10 | **/DerivedData/ 11 | Icon? 12 | **/Pods/ 13 | **/.symlinks/ 14 | profile 15 | xcuserdata 16 | **/.generated/ 17 | Flutter/App.framework 18 | Flutter/Flutter.framework 19 | Flutter/Flutter.podspec 20 | Flutter/Generated.xcconfig 21 | Flutter/ephemeral/ 22 | Flutter/app.flx 23 | Flutter/app.zip 24 | Flutter/flutter_assets/ 25 | Flutter/flutter_export_environment.sh 26 | ServiceDefinitions.json 27 | Runner/GeneratedPluginRegistrant.* 28 | 29 | # Exceptions to above rules. 30 | !default.mode1v3 31 | !default.mode2v3 32 | !default.pbxuser 33 | !default.perspectivev3 34 | -------------------------------------------------------------------------------- /ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 8.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | **/ios/Flutter/.last_build_id 26 | .dart_tool/ 27 | .flutter-plugins 28 | .flutter-plugins-dependencies 29 | .packages 30 | .pub-cache/ 31 | .pub/ 32 | /build/ 33 | 34 | # Web related 35 | lib/generated_plugin_registrant.dart 36 | 37 | # Symbolication related 38 | app.*.symbols 39 | 40 | # Obfuscation related 41 | app.*.map.json 42 | 43 | # Android Studio will place build artifacts here 44 | /android/app/debug 45 | /android/app/profile 46 | /android/app/release 47 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility that Flutter provides. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | import 'package:flutter/material.dart'; 9 | import 'package:flutter_test/flutter_test.dart'; 10 | 11 | import 'package:custom_widgets/main.dart'; 12 | 13 | void main() { 14 | testWidgets('Counter increments smoke test', (WidgetTester tester) async { 15 | // Build our app and trigger a frame. 16 | await tester.pumpWidget(MyApp()); 17 | 18 | // Verify that our counter starts at 0. 19 | expect(find.text('0'), findsOneWidget); 20 | expect(find.text('1'), findsNothing); 21 | 22 | // Tap the '+' icon and trigger a frame. 23 | await tester.tap(find.byIcon(Icons.add)); 24 | await tester.pump(); 25 | 26 | // Verify that our counter has incremented. 27 | expect(find.text('0'), findsNothing); 28 | expect(find.text('1'), findsOneWidget); 29 | }); 30 | } 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Flutter - Custom Widgets 2 | 3 | ## Part 1 - EllipsizedText / LeafRenderObjectWidget 4 | 5 | [Writing custom Widgets in Flutter (Part 1) — EllipsizedText](https://rlesovyi.medium.com/writing-custom-widgets-in-flutter-part-1-ellipsizedtext-a0efdc1368a8) 6 | 7 | ![part1_example](part1-example.gif) 8 | 9 | ## Part 2 - ChildSize / SingleChildRenderObjectWidget 10 | 11 | [Writing custom Widgets in Flutter (Part 2.a) — ChildSize (with helpers)](https://rlesovyi.medium.com/writing-custom-widgets-in-flutter-part-2-singlechildrenderobjectwidget-5637fecdf9bb) 12 | 13 | [Writing custom Widgets in Flutter (Part 2.b) — ChildSize (no helpers)](https://rlesovyi.medium.com/writing-custom-widgets-in-flutter-part-2-b-childsize-no-helpers-61c578c9bbd2) 14 | 15 | ![part2_example](part2-example.gif) 16 | 17 | ## Part 3 - SimpleOverlay / MultiChildRenderObjectWidget 18 | 19 | [Writing custom Widgets in Flutter (Part 3.a) — SimpleOverlay (with helpers)](https://rlesovyi.medium.com/writing-custom-widgets-in-flutter-part-3a-simpleoverlay-with-helpers-6b3990db48b6) 20 | 21 | [Writing custom Widgets in Flutter (Part 3.b) — SimpleOverlay (no helpers)](https://rlesovyi.medium.com/writing-custom-widgets-in-flutter-part-3-b-simpleoverlay-no-helpers-9ddf45cea983) 22 | 23 | ![part3_example](part3-example.gif) 24 | -------------------------------------------------------------------------------- /lib/part4_overflow_toolbar/overflow_toolbar_demo.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | import 'package:custom_widgets/demo_widget.dart'; 4 | import 'package:custom_widgets/part2a_child_size/child_size.dart'; 5 | import 'package:flutter/material.dart'; 6 | import 'package:flutter/widgets.dart'; 7 | 8 | class OverflowToolbarDemo extends DemoWidget { 9 | final title = 'Part 4 - OverflowToolbar (TODO)'; 10 | 11 | const OverflowToolbarDemo(); 12 | 13 | @override 14 | DemoWidgetState createState() => _OverflowToolbarDemoState(); 15 | } 16 | 17 | class _OverflowToolbarDemoState extends DemoWidgetState { 18 | var _fraction = 1.0; 19 | var _size = Size.zero; 20 | 21 | @override 22 | Widget buildContent() { 23 | return Column( 24 | mainAxisSize: MainAxisSize.min, 25 | children: [ 26 | const SizedBox(height: 100), 27 | Slider(value: _fraction, onChanged: (value) => setState(() => _fraction = value)), 28 | Text(_size.toString()), 29 | Center(child: _buildContent()), 30 | ], 31 | ); 32 | } 33 | 34 | Widget _buildContent() { 35 | return ChildSize( 36 | child: _buildImage(), 37 | onChildSizeChanged: (size) => setState(() => _size = size), 38 | ); 39 | } 40 | 41 | Widget _buildImage() { 42 | return LayoutBuilder(builder: (_, constraints) { 43 | return ColoredBox( 44 | color: Colors.amber, 45 | child: Icon( 46 | Icons.image, 47 | color: Colors.yellow, 48 | size: min(constraints.maxWidth, constraints.maxHeight) * _fraction, 49 | ), 50 | ); 51 | }); 52 | }} 53 | -------------------------------------------------------------------------------- /lib/part2a_child_size/child_size.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/rendering.dart'; 2 | import 'package:flutter/widgets.dart'; 3 | 4 | class ChildSize extends SingleChildRenderObjectWidget { 5 | final void Function(Size)? onChildSizeChanged; 6 | 7 | const ChildSize({ 8 | Key? key, 9 | Widget? child, 10 | this.onChildSizeChanged, 11 | }) : super(key: key, child: child); 12 | 13 | @override 14 | RenderObject createRenderObject(BuildContext context) { 15 | return RenderChildSize().._widget = this; 16 | } 17 | 18 | @override 19 | void updateRenderObject(BuildContext context, RenderChildSize renderObject) { 20 | renderObject.._widget = this; 21 | } 22 | } 23 | 24 | class RenderChildSize extends RenderBox with RenderObjectWithChildMixin { 25 | var _lastSize = Size.zero; 26 | var _widget = const ChildSize(); 27 | 28 | @override 29 | void performLayout() { 30 | final child = this.child; 31 | if (child != null) { 32 | child.layout(constraints, parentUsesSize: true); 33 | size = child.size; 34 | } else { 35 | size = constraints.smallest; 36 | } 37 | 38 | if (_lastSize != size) { 39 | _lastSize = size; 40 | _widget.onChildSizeChanged?.call(_lastSize); 41 | } 42 | } 43 | 44 | @override 45 | void paint(PaintingContext context, Offset offset) { 46 | final child = this.child; 47 | if (child != null) { 48 | context.paintChild(child, offset); 49 | } 50 | } 51 | 52 | @override 53 | bool hitTestChildren(BoxHitTestResult result, {required Offset position}) { 54 | return child?.hitTest(result, position: position) == true; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /lib/part2a_child_size/child_size_demo.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'dart:math'; 3 | 4 | import 'package:custom_widgets/demo_widget.dart'; 5 | import 'package:custom_widgets/part2a_child_size/child_size.dart'; 6 | import 'package:flutter/material.dart'; 7 | import 'package:flutter/widgets.dart'; 8 | 9 | class ChildSizeDemoA extends StatefulWidget implements DemoWidget { 10 | final title = 'Part 2.a - ChildSize'; 11 | 12 | const ChildSizeDemoA(); 13 | 14 | @override 15 | DemoWidgetState createState() => _ChildSizeDemoAState(); 16 | } 17 | 18 | class _ChildSizeDemoAState extends DemoWidgetState { 19 | var _fraction = 1.0; 20 | var _size = Size.zero; 21 | 22 | @override 23 | Widget buildContent() { 24 | return Column( 25 | mainAxisSize: MainAxisSize.min, 26 | children: [ 27 | const SizedBox(height: 100), 28 | Slider(value: _fraction, onChanged: (value) => setState(() => _fraction = value)), 29 | Text(_size.toString()), 30 | Center(child: _buildContent()), 31 | ], 32 | ); 33 | } 34 | 35 | Widget _buildContent() { 36 | return ChildSize( 37 | child: _buildImage(), 38 | onChildSizeChanged: (size) => scheduleMicrotask(() { 39 | setState(() => _size = size); 40 | }), 41 | ); 42 | } 43 | 44 | Widget _buildImage() { 45 | return LayoutBuilder(builder: (_, constraints) { 46 | return ColoredBox( 47 | color: Colors.amber, 48 | child: Icon( 49 | Icons.image, 50 | color: Colors.yellow, 51 | size: min(constraints.maxWidth, constraints.maxHeight) * _fraction, 52 | ), 53 | ); 54 | }); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /lib/part2b_child_size/child_size_demo.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'dart:math'; 3 | 4 | import 'package:custom_widgets/demo_widget.dart'; 5 | import 'package:custom_widgets/part2b_child_size/child_size.dart'; 6 | import 'package:flutter/material.dart'; 7 | import 'package:flutter/widgets.dart'; 8 | 9 | class ChildSizeDemoB extends StatefulWidget implements DemoWidget { 10 | final title = 'Part 2.b - ChildSize (no helpers)'; 11 | 12 | const ChildSizeDemoB(); 13 | 14 | @override 15 | DemoWidgetState createState() => _ChildSizeDemoBState(); 16 | } 17 | 18 | class _ChildSizeDemoBState extends DemoWidgetState { 19 | var _fraction = 1.0; 20 | var _size = Size.zero; 21 | 22 | @override 23 | Widget buildContent() { 24 | return Column( 25 | mainAxisSize: MainAxisSize.min, 26 | children: [ 27 | const SizedBox(height: 100), 28 | Slider(value: _fraction, onChanged: (value) => setState(() => _fraction = value)), 29 | Text(_size.toString()), 30 | Center(child: _buildContent()), 31 | ], 32 | ); 33 | } 34 | 35 | Widget _buildContent() { 36 | return ChildSize( 37 | child: _buildImage(), 38 | onChildSizeChanged: (size) => scheduleMicrotask(() { 39 | setState(() => _size = size); 40 | }), 41 | ); 42 | } 43 | 44 | Widget _buildImage() { 45 | return LayoutBuilder(builder: (_, constraints) { 46 | return ColoredBox( 47 | color: Colors.amber, 48 | child: Icon( 49 | Icons.image, 50 | color: Colors.yellow, 51 | size: min(constraints.maxWidth, constraints.maxHeight) * _fraction, 52 | ), 53 | ); 54 | }); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /lib/part3b_simple_overlay/simple_overlay_demo.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | import 'package:custom_widgets/demo_widget.dart'; 4 | import 'package:custom_widgets/part3b_simple_overlay/simple_overlay.dart'; 5 | import 'package:flutter/material.dart'; 6 | 7 | class SimpleOverlayDemoB extends DemoWidget { 8 | final title = 'Part 3b - FollowLeader (no helpers)'; 9 | 10 | const SimpleOverlayDemoB(); 11 | 12 | @override 13 | DemoWidgetState createState() => _SimpleOverlayDemoBState(); 14 | } 15 | 16 | class _SimpleOverlayDemoBState extends DemoWidgetState { 17 | var _size = 1.0; 18 | 19 | @override 20 | Widget buildContent() { 21 | return Column( 22 | mainAxisSize: MainAxisSize.min, 23 | children: [ 24 | const SizedBox(height: 100), 25 | Slider(value: _size, onChanged: (value) => setState(() => _size = value)), 26 | Center(child: _buildContent()), 27 | ], 28 | ); 29 | } 30 | 31 | Widget _buildContent() { 32 | return SimpleOverlay( 33 | child: _buildImage(), 34 | overlay: _buildOverlay(), 35 | ); 36 | } 37 | 38 | Widget _buildImage() { 39 | return LayoutBuilder(builder: (_, constraints) { 40 | return ColoredBox( 41 | color: Colors.amber, 42 | child: Icon( 43 | Icons.image, 44 | color: Colors.yellow, 45 | size: min(constraints.maxWidth, constraints.maxHeight) * _size, 46 | ), 47 | ); 48 | }); 49 | } 50 | 51 | Widget _buildOverlay() { 52 | return const Align( 53 | alignment: Alignment.bottomRight, 54 | child: Text( 55 | 'Published on 27.06.2021', 56 | style: TextStyle(color: Colors.black), 57 | ), 58 | ); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | custom_widgets 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | $(FLUTTER_BUILD_NAME) 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UIViewControllerBasedStatusBarAppearance 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /lib/part3a_simple_overlay/simple_overlay_demo.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | import 'package:custom_widgets/demo_widget.dart'; 4 | import 'package:custom_widgets/part3a_simple_overlay/simple_overlay.dart'; 5 | import 'package:flutter/material.dart'; 6 | 7 | class SimpleOverlayDemoA extends DemoWidget { 8 | final title = 'Part 3a - FollowLeader'; 9 | 10 | const SimpleOverlayDemoA(); 11 | 12 | @override 13 | DemoWidgetState createState() => _SimpleOverlayDemoAState(); 14 | } 15 | 16 | class _SimpleOverlayDemoAState extends DemoWidgetState { 17 | var _size = 1.0; 18 | 19 | @override 20 | Widget buildContent() { 21 | return Column( 22 | mainAxisSize: MainAxisSize.min, 23 | children: [ 24 | const SizedBox(height: 100), 25 | Slider(value: _size, onChanged: (value) => setState(() => _size = value)), 26 | Center(child: _buildContent()), 27 | ], 28 | ); 29 | } 30 | 31 | Widget _buildContent() { 32 | return SimpleOverlay( 33 | child: _buildImage(), 34 | overlay: _buildOverlay(), 35 | ); 36 | } 37 | 38 | Widget _buildImage() { 39 | return LayoutBuilder(builder: (_, constraints) { 40 | return ColoredBox( 41 | color: Colors.amber, 42 | child: Icon( 43 | Icons.image, 44 | color: Colors.yellow, 45 | size: min(constraints.maxWidth, constraints.maxHeight) * _size, 46 | ), 47 | ); 48 | }); 49 | } 50 | 51 | Widget _buildOverlay() { 52 | return const Align( 53 | alignment: Alignment.bottomRight, 54 | child: Padding( 55 | padding: const EdgeInsets.all(8), 56 | child: Text( 57 | 'Published on 07.06.2021', 58 | style: const TextStyle(color: Colors.black), 59 | ), 60 | ), 61 | ); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | compileSdkVersion 30 30 | 31 | sourceSets { 32 | main.java.srcDirs += 'src/main/kotlin' 33 | } 34 | 35 | defaultConfig { 36 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 37 | applicationId "dev.matrix.custom_widgets" 38 | minSdkVersion 16 39 | targetSdkVersion 30 40 | versionCode flutterVersionCode.toInteger() 41 | versionName flutterVersionName 42 | } 43 | 44 | buildTypes { 45 | release { 46 | // TODO: Add your own signing config for the release build. 47 | // Signing with the debug keys for now, so `flutter run --release` works. 48 | signingConfig signingConfigs.debug 49 | } 50 | } 51 | } 52 | 53 | flutter { 54 | source '../..' 55 | } 56 | 57 | dependencies { 58 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 59 | } 60 | -------------------------------------------------------------------------------- /lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:custom_widgets/demo_widget.dart'; 2 | import 'package:custom_widgets/part1_ellipsized_text/ellipsized_text_demo.dart'; 3 | import 'package:custom_widgets/part2a_child_size/child_size_demo.dart'; 4 | import 'package:custom_widgets/part2b_child_size/child_size_demo.dart'; 5 | import 'package:custom_widgets/part3a_simple_overlay/simple_overlay_demo.dart'; 6 | import 'package:custom_widgets/part3b_simple_overlay/simple_overlay_demo.dart'; 7 | import 'package:custom_widgets/part4_overflow_toolbar/overflow_toolbar_demo.dart'; 8 | import 'package:flutter/material.dart'; 9 | 10 | void main() { 11 | runApp(MyApp()); 12 | } 13 | 14 | class MyApp extends StatelessWidget { 15 | @override 16 | Widget build(BuildContext context) { 17 | return MaterialApp( 18 | title: 'Flutter Custom Widget Examples', 19 | theme: ThemeData(primarySwatch: Colors.blue), 20 | home: const HomePage(), 21 | ); 22 | } 23 | } 24 | 25 | class HomePage extends StatelessWidget { 26 | const HomePage(); 27 | 28 | @override 29 | Widget build(BuildContext context) { 30 | return Scaffold( 31 | appBar: AppBar(title: Text('Flutter Custom Widget Examples')), 32 | body: Center( 33 | child: Column( 34 | mainAxisAlignment: MainAxisAlignment.center, 35 | crossAxisAlignment: CrossAxisAlignment.start, 36 | children: [ 37 | _buildItem(context, const EllipsizedTextDemo()), 38 | _buildItem(context, const ChildSizeDemoA()), 39 | _buildItem(context, const ChildSizeDemoB()), 40 | _buildItem(context, const SimpleOverlayDemoA()), 41 | _buildItem(context, const SimpleOverlayDemoB()), 42 | _buildItem(context, const OverflowToolbarDemo()), 43 | ], 44 | ), 45 | ), 46 | ); 47 | } 48 | 49 | Widget _buildItem(BuildContext context, DemoWidget screen) { 50 | return InkWell( 51 | child: Padding( 52 | padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 16), 53 | child: Text(screen.title, style: const TextStyle(fontSize: 20)), 54 | ), 55 | onTap: () { 56 | Navigator.push(context, MaterialPageRoute(builder: (_) => screen)); 57 | }, 58 | ); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /lib/part3a_simple_overlay/simple_overlay.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/gestures.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter/rendering.dart'; 4 | import 'package:flutter/widgets.dart'; 5 | 6 | // region SimpleOverlay 7 | 8 | class SimpleOverlay extends MultiChildRenderObjectWidget { 9 | SimpleOverlay({ 10 | required Widget child, 11 | required Widget overlay, 12 | }) : super(children: [child, overlay]); 13 | 14 | @override 15 | RenderObject createRenderObject(BuildContext context) { 16 | return RenderSimpleOverlay(); 17 | } 18 | } 19 | 20 | // endregion 21 | 22 | // region SimpleOverlayChild 23 | 24 | class _SimpleOverlayChild extends ContainerBoxParentData 25 | with ContainerParentDataMixin {} 26 | 27 | // endregion 28 | 29 | // region SimpleOverlayRenderObject 30 | 31 | class RenderSimpleOverlay extends RenderBox 32 | with 33 | ContainerRenderObjectMixin, 34 | RenderBoxContainerDefaultsMixin { 35 | // region Children Management 36 | 37 | @override 38 | void setupParentData(covariant RenderObject child) { 39 | child.parentData = _SimpleOverlayChild(); 40 | } 41 | 42 | // endregion 43 | 44 | // region Layout 45 | 46 | @override 47 | void performLayout() { 48 | var childConstraints = constraints; 49 | 50 | final child = firstChild; 51 | if (child != null) { 52 | child.layout(constraints, parentUsesSize: true); 53 | childConstraints = BoxConstraints.tight(child.size); 54 | } 55 | 56 | final overlay = (child == null) ? null : childAfter(child); 57 | if (overlay != null) { 58 | overlay.layout(childConstraints, parentUsesSize: true); 59 | } 60 | 61 | size = child?.size ?? overlay?.size ?? constraints.smallest; 62 | } 63 | 64 | // endregion 65 | 66 | // region Paint 67 | 68 | @override 69 | void paint(PaintingContext context, Offset offset) { 70 | defaultPaint(context, offset); 71 | } 72 | 73 | // endregion 74 | 75 | // region Touch 76 | 77 | @override 78 | bool hitTestChildren(BoxHitTestResult result, {required Offset position}) { 79 | return defaultHitTestChildren(result, position: position); 80 | } 81 | 82 | // endregion 83 | } 84 | 85 | // endregion 86 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 13 | 17 | 21 | 26 | 30 | 31 | 32 | 33 | 34 | 35 | 37 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /lib/part1_ellipsized_text/ellipsized_text_demo.dart: -------------------------------------------------------------------------------- 1 | import 'package:custom_widgets/demo_widget.dart'; 2 | import 'package:custom_widgets/part1_ellipsized_text/ellipsized_text.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | class EllipsizedTextDemo extends DemoWidget { 6 | final title = 'Part 1 - EllipsizedText'; 7 | 8 | const EllipsizedTextDemo(); 9 | 10 | @override 11 | DemoWidgetState createState() => _EllipsizedTextDemoState(); 12 | } 13 | 14 | class _EllipsizedTextDemoState extends DemoWidgetState { 15 | var _fraction = 1.0; 16 | 17 | @override 18 | Widget buildContent() { 19 | return Column( 20 | mainAxisSize: MainAxisSize.min, 21 | children: [ 22 | const SizedBox(height: 100), 23 | Slider(value: _fraction, onChanged: (value) => setState(() => _fraction = value)), 24 | Expanded(child: _buildTextExamples()), 25 | ], 26 | ); 27 | } 28 | 29 | Widget _buildTextExamples() { 30 | return Column( 31 | crossAxisAlignment: CrossAxisAlignment.start, 32 | children: [ 33 | Text('Text'), 34 | CustomSingleChildLayout( 35 | delegate: _SingleChildLayoutDelegate(_fraction), 36 | child: Text( 37 | 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 38 | overflow: TextOverflow.ellipsis, 39 | style: const TextStyle(color: Colors.black), 40 | ), 41 | ), 42 | Text('EllipsizedText'), 43 | CustomSingleChildLayout( 44 | delegate: _SingleChildLayoutDelegate(_fraction), 45 | child: EllipsizedText( 46 | 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 47 | style: const TextStyle(color: Colors.black), 48 | ), 49 | ), 50 | ], 51 | ); 52 | } 53 | } 54 | 55 | class _SingleChildLayoutDelegate extends SingleChildLayoutDelegate { 56 | final double _width; 57 | 58 | _SingleChildLayoutDelegate(this._width); 59 | 60 | @override 61 | Size getSize(BoxConstraints constraints) { 62 | return constraints.constrainDimensions(double.infinity, 30); 63 | } 64 | 65 | @override 66 | bool shouldRelayout(_SingleChildLayoutDelegate oldDelegate) { 67 | return oldDelegate._width != _width; 68 | } 69 | 70 | @override 71 | BoxConstraints getConstraintsForChild(BoxConstraints constraints) { 72 | return constraints.copyWith(maxWidth: constraints.maxWidth * _width, minHeight: 0); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: custom_widgets 2 | description: A new Flutter project. 3 | 4 | # The following line prevents the package from being accidentally published to 5 | # pub.dev using `pub publish`. This is preferred for private packages. 6 | publish_to: 'none' # Remove this line if you wish to publish to pub.dev 7 | 8 | # The following defines the version and build number for your application. 9 | # A version number is three numbers separated by dots, like 1.2.43 10 | # followed by an optional build number separated by a +. 11 | # Both the version and the builder number may be overridden in flutter 12 | # build by specifying --build-name and --build-number, respectively. 13 | # In Android, build-name is used as versionName while build-number used as versionCode. 14 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning 15 | # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. 16 | # Read more about iOS versioning at 17 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html 18 | version: 1.0.0+1 19 | 20 | environment: 21 | sdk: ">=2.12.0 <3.0.0" 22 | 23 | dependencies: 24 | flutter: 25 | sdk: flutter 26 | 27 | 28 | # The following adds the Cupertino Icons font to your application. 29 | # Use with the CupertinoIcons class for iOS style icons. 30 | cupertino_icons: ^1.0.2 31 | 32 | dev_dependencies: 33 | flutter_test: 34 | sdk: flutter 35 | 36 | # For information on the generic Dart part of this file, see the 37 | # following page: https://dart.dev/tools/pub/pubspec 38 | 39 | # The following section is specific to Flutter. 40 | flutter: 41 | 42 | # The following line ensures that the Material Icons font is 43 | # included with your application, so that you can use the icons in 44 | # the material Icons class. 45 | uses-material-design: true 46 | 47 | # To add assets to your application, add an assets section, like this: 48 | # assets: 49 | # - images/a_dot_burr.jpeg 50 | # - images/a_dot_ham.jpeg 51 | 52 | # An image asset can refer to one or more resolution-specific "variants", see 53 | # https://flutter.dev/assets-and-images/#resolution-aware. 54 | 55 | # For details regarding adding assets from package dependencies, see 56 | # https://flutter.dev/assets-and-images/#from-packages 57 | 58 | # To add custom fonts to your application, add a fonts section here, 59 | # in this "flutter" section. Each entry in this list should have a 60 | # "family" key with the font family name, and a "fonts" key with a 61 | # list giving the asset and other descriptors for the font. For 62 | # example: 63 | # fonts: 64 | # - family: Schyler 65 | # fonts: 66 | # - asset: fonts/Schyler-Regular.ttf 67 | # - asset: fonts/Schyler-Italic.ttf 68 | # style: italic 69 | # - family: Trajan Pro 70 | # fonts: 71 | # - asset: fonts/TrajanPro.ttf 72 | # - asset: fonts/TrajanPro_Bold.ttf 73 | # weight: 700 74 | # 75 | # For details regarding fonts from package dependencies, 76 | # see https://flutter.dev/custom-fonts/#from-packages 77 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /lib/part1_ellipsized_text/ellipsized_text.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/widgets.dart'; 2 | 3 | enum Ellipsis { start, middle, end } 4 | 5 | class EllipsizedText extends LeafRenderObjectWidget { 6 | final String text; 7 | final TextStyle? style; 8 | final Ellipsis ellipsis; 9 | 10 | const EllipsizedText( 11 | this.text, { 12 | Key? key, 13 | this.style, 14 | this.ellipsis = Ellipsis.end, 15 | }) : super(key: key); 16 | 17 | @override 18 | RenderObject createRenderObject(BuildContext context) { 19 | return RenderEllipsizedText()..widget = this; 20 | } 21 | 22 | @override 23 | void updateRenderObject(BuildContext context, RenderEllipsizedText renderObject) { 24 | renderObject.widget = this; 25 | } 26 | } 27 | 28 | class RenderEllipsizedText extends RenderBox { 29 | final _textPainter = TextPainter(textDirection: TextDirection.ltr); 30 | 31 | var _widgetChanged = false; 32 | var _widget = const EllipsizedText(''); 33 | var _constraints = const BoxConstraints(); 34 | 35 | set widget(EllipsizedText widget) { 36 | if (_widget.text == widget.text && 37 | _widget.style == widget.style && 38 | _widget.ellipsis == widget.ellipsis) { 39 | return; 40 | } 41 | _widgetChanged = true; 42 | _widget = widget; 43 | markNeedsLayout(); 44 | } 45 | 46 | @override 47 | void performLayout() { 48 | if (!_widgetChanged && _constraints == constraints && hasSize) { 49 | return; 50 | } 51 | 52 | _widgetChanged = false; 53 | _constraints = constraints; 54 | 55 | size = _ellipsize( 56 | minWidth: constraints.minWidth, 57 | maxWidth: constraints.maxWidth, 58 | ); 59 | } 60 | 61 | @override 62 | void paint(PaintingContext context, Offset offset) { 63 | _textPainter.paint(context.canvas, offset); 64 | } 65 | 66 | Size _ellipsize({required double minWidth, required double maxWidth}) { 67 | final text = _widget.text; 68 | 69 | if (_layoutText(length: text.length, minWidth: minWidth) > maxWidth) { 70 | var left = 0; 71 | var right = text.length - 1; 72 | 73 | while (left < right) { 74 | final index = (left + right) ~/ 2; 75 | if (_layoutText(length: index, minWidth: minWidth) > maxWidth) { 76 | right = index; 77 | } else { 78 | left = index + 1; 79 | } 80 | } 81 | _layoutText(length: right - 1, minWidth: minWidth); 82 | } 83 | 84 | return constraints.constrain(Size(_textPainter.width, _textPainter.height)); 85 | } 86 | 87 | double _layoutText({required int length, required double minWidth}) { 88 | final text = _widget.text; 89 | final style = _widget.style; 90 | final ellipsis = _widget.ellipsis; 91 | 92 | String ellipsizedText = ''; 93 | 94 | switch (ellipsis) { 95 | case Ellipsis.start: 96 | if (length > 0) { 97 | ellipsizedText = text.substring(text.length - length, text.length); 98 | if (length != text.length) { 99 | ellipsizedText = '...' + ellipsizedText; 100 | } 101 | } 102 | break; 103 | case Ellipsis.middle: 104 | if (length > 0) { 105 | ellipsizedText = text; 106 | if (length != text.length) { 107 | var start = text.substring(0, (length / 2).round()); 108 | var end = text.substring(text.length - start.length, text.length); 109 | ellipsizedText = start + '...' + end; 110 | } 111 | } 112 | break; 113 | case Ellipsis.end: 114 | if (length > 0) { 115 | ellipsizedText = text.substring(0, length); 116 | if (length != text.length) { 117 | ellipsizedText = ellipsizedText + '...'; 118 | } 119 | } 120 | break; 121 | } 122 | 123 | _textPainter.text = TextSpan(text: ellipsizedText, style: style); 124 | _textPainter.layout(minWidth: minWidth, maxWidth: double.infinity); 125 | return _textPainter.width; 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | async: 5 | dependency: transitive 6 | description: 7 | name: async 8 | url: "https://pub.dartlang.org" 9 | source: hosted 10 | version: "2.6.1" 11 | boolean_selector: 12 | dependency: transitive 13 | description: 14 | name: boolean_selector 15 | url: "https://pub.dartlang.org" 16 | source: hosted 17 | version: "2.1.0" 18 | characters: 19 | dependency: transitive 20 | description: 21 | name: characters 22 | url: "https://pub.dartlang.org" 23 | source: hosted 24 | version: "1.1.0" 25 | charcode: 26 | dependency: transitive 27 | description: 28 | name: charcode 29 | url: "https://pub.dartlang.org" 30 | source: hosted 31 | version: "1.2.0" 32 | clock: 33 | dependency: transitive 34 | description: 35 | name: clock 36 | url: "https://pub.dartlang.org" 37 | source: hosted 38 | version: "1.1.0" 39 | collection: 40 | dependency: transitive 41 | description: 42 | name: collection 43 | url: "https://pub.dartlang.org" 44 | source: hosted 45 | version: "1.15.0" 46 | cupertino_icons: 47 | dependency: "direct main" 48 | description: 49 | name: cupertino_icons 50 | url: "https://pub.dartlang.org" 51 | source: hosted 52 | version: "1.0.3" 53 | fake_async: 54 | dependency: transitive 55 | description: 56 | name: fake_async 57 | url: "https://pub.dartlang.org" 58 | source: hosted 59 | version: "1.2.0" 60 | flutter: 61 | dependency: "direct main" 62 | description: flutter 63 | source: sdk 64 | version: "0.0.0" 65 | flutter_test: 66 | dependency: "direct dev" 67 | description: flutter 68 | source: sdk 69 | version: "0.0.0" 70 | matcher: 71 | dependency: transitive 72 | description: 73 | name: matcher 74 | url: "https://pub.dartlang.org" 75 | source: hosted 76 | version: "0.12.10" 77 | meta: 78 | dependency: transitive 79 | description: 80 | name: meta 81 | url: "https://pub.dartlang.org" 82 | source: hosted 83 | version: "1.3.0" 84 | path: 85 | dependency: transitive 86 | description: 87 | name: path 88 | url: "https://pub.dartlang.org" 89 | source: hosted 90 | version: "1.8.0" 91 | sky_engine: 92 | dependency: transitive 93 | description: flutter 94 | source: sdk 95 | version: "0.0.99" 96 | source_span: 97 | dependency: transitive 98 | description: 99 | name: source_span 100 | url: "https://pub.dartlang.org" 101 | source: hosted 102 | version: "1.8.1" 103 | stack_trace: 104 | dependency: transitive 105 | description: 106 | name: stack_trace 107 | url: "https://pub.dartlang.org" 108 | source: hosted 109 | version: "1.10.0" 110 | stream_channel: 111 | dependency: transitive 112 | description: 113 | name: stream_channel 114 | url: "https://pub.dartlang.org" 115 | source: hosted 116 | version: "2.1.0" 117 | string_scanner: 118 | dependency: transitive 119 | description: 120 | name: string_scanner 121 | url: "https://pub.dartlang.org" 122 | source: hosted 123 | version: "1.1.0" 124 | term_glyph: 125 | dependency: transitive 126 | description: 127 | name: term_glyph 128 | url: "https://pub.dartlang.org" 129 | source: hosted 130 | version: "1.2.0" 131 | test_api: 132 | dependency: transitive 133 | description: 134 | name: test_api 135 | url: "https://pub.dartlang.org" 136 | source: hosted 137 | version: "0.3.0" 138 | typed_data: 139 | dependency: transitive 140 | description: 141 | name: typed_data 142 | url: "https://pub.dartlang.org" 143 | source: hosted 144 | version: "1.3.0" 145 | vector_math: 146 | dependency: transitive 147 | description: 148 | name: vector_math 149 | url: "https://pub.dartlang.org" 150 | source: hosted 151 | version: "2.1.0" 152 | sdks: 153 | dart: ">=2.12.0 <3.0.0" 154 | -------------------------------------------------------------------------------- /lib/part2b_child_size/child_size.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/rendering.dart'; 2 | import 'package:flutter/widgets.dart'; 3 | 4 | // region ChildSize 5 | 6 | class ChildSize extends RenderObjectWidget { 7 | // ... 8 | final Widget? child; 9 | final void Function(Size)? onChildSizeChanged; 10 | 11 | const ChildSize({ 12 | Key? key, 13 | this.child, 14 | this.onChildSizeChanged, 15 | }) : super(key: key); 16 | 17 | @override 18 | RenderObjectElement createElement() { 19 | return ChildSizeElement(this); 20 | } 21 | 22 | @override 23 | RenderObject createRenderObject(BuildContext context) { 24 | return RenderChildSize().._widget = this; 25 | } 26 | 27 | @override 28 | void updateRenderObject(BuildContext context, RenderChildSize renderObject) { 29 | renderObject.._widget = this; 30 | } 31 | } 32 | 33 | // endregion 34 | 35 | // region ChildSizeElement 36 | 37 | class ChildSizeElement extends RenderObjectElement { 38 | // ... 39 | Element? _child; 40 | 41 | ChildSizeElement(ChildSize widget) : super(widget); 42 | 43 | @override 44 | ChildSize get widget { 45 | return super.widget as ChildSize; 46 | } 47 | 48 | @override 49 | RenderChildSize get renderObject { 50 | return super.renderObject as RenderChildSize; 51 | } 52 | 53 | @override 54 | void mount(Element? parent, Object? newSlot) { 55 | super.mount(parent, newSlot); 56 | _child = updateChild(_child, widget.child, null); 57 | } 58 | 59 | @override 60 | void update(ChildSize newWidget) { 61 | super.update(newWidget); 62 | _child = updateChild(_child, newWidget.child, null); 63 | } 64 | 65 | @override 66 | void unmount() { 67 | super.unmount(); 68 | _child = null; 69 | } 70 | 71 | @override 72 | void visitChildren(ElementVisitor visitor) { 73 | final child = _child; 74 | if (child != null) { 75 | visitor(child); 76 | } 77 | super.visitChildren(visitor); 78 | } 79 | 80 | @override 81 | void forgetChild(Element child) { 82 | assert(child == _child); 83 | _child = null; 84 | super.forgetChild(child); 85 | } 86 | 87 | @override 88 | void insertRenderObjectChild(RenderBox child, covariant Object? slot) { 89 | renderObject.insertRenderObjectChild(child, slot); 90 | } 91 | 92 | @override 93 | void removeRenderObjectChild(RenderBox child, covariant Object? slot) { 94 | renderObject.removeRenderObjectChild(child, slot); 95 | } 96 | } 97 | 98 | // endregion 99 | 100 | // region RenderChildSize 101 | 102 | class RenderChildSize extends RenderBox { 103 | // ... 104 | RenderBox? _child; 105 | var _lastSize = Size.zero; 106 | var _widget = const ChildSize(); 107 | 108 | // region Children Management 109 | 110 | @override 111 | void attach(covariant PipelineOwner owner) { 112 | super.attach(owner); 113 | _child?.attach(owner); 114 | } 115 | 116 | @override 117 | void detach() { 118 | super.detach(); 119 | _child?.detach(); 120 | } 121 | 122 | @override 123 | void visitChildren(RenderObjectVisitor visitor) { 124 | final child = _child; 125 | if (child != null) { 126 | visitor(child); 127 | } 128 | super.visitChildren(visitor); 129 | } 130 | 131 | @override 132 | void redepthChildren() { 133 | final child = _child; 134 | if (child != null) { 135 | redepthChild(child); 136 | } 137 | super.redepthChildren(); 138 | } 139 | 140 | void insertRenderObjectChild(RenderBox child, covariant Object? slot) { 141 | assert(_child == null); 142 | _child = child; 143 | adoptChild(child); 144 | } 145 | 146 | void removeRenderObjectChild(RenderBox child, covariant Object? slot) { 147 | assert(_child == child); 148 | _child = null; 149 | dropChild(child); 150 | } 151 | 152 | // endregion 153 | 154 | // region Layout 155 | 156 | @override 157 | void performLayout() { 158 | final child = _child; 159 | if (child != null) { 160 | child.layout(constraints, parentUsesSize: true); 161 | size = child.size; 162 | } else { 163 | size = constraints.smallest; 164 | } 165 | 166 | if (_lastSize != size) { 167 | _lastSize = size; 168 | _widget.onChildSizeChanged?.call(_lastSize); 169 | } 170 | } 171 | 172 | // endregion 173 | 174 | // region Paint 175 | 176 | @override 177 | void paint(PaintingContext context, Offset offset) { 178 | final child = _child; 179 | if (child != null) { 180 | context.paintChild(child, offset); 181 | } 182 | } 183 | 184 | // endregion 185 | 186 | // region HitTest 187 | 188 | @override 189 | bool hitTestChildren(BoxHitTestResult result, {required Offset position}) { 190 | return _child?.hitTest(result, position: position) == true; 191 | } 192 | 193 | // endregion 194 | 195 | } 196 | 197 | // endregion 198 | -------------------------------------------------------------------------------- /lib/part4_overflow_toolbar/overflow_toolbar.dart: -------------------------------------------------------------------------------- 1 | import 'package:collection/collection.dart'; 2 | import 'package:flutter/rendering.dart'; 3 | import 'package:flutter/widgets.dart'; 4 | 5 | // region OverflowToolbar 6 | 7 | class OverflowToolbar extends RenderObjectWidget { 8 | final List icons; 9 | 10 | const OverflowToolbar({required this.icons}); 11 | 12 | @override 13 | RenderObjectElement createElement() { 14 | return OverflowToolbarElement(this); 15 | } 16 | 17 | @override 18 | RenderObject createRenderObject(BuildContext context) { 19 | return OverflowToolbarRender(context as OverflowToolbarElement); 20 | } 21 | } 22 | 23 | // endregion 24 | 25 | // region OverflowToolbarElement 26 | 27 | class OverflowToolbarElement extends RenderObjectElement { 28 | final _children = []; 29 | 30 | OverflowToolbarElement(OverflowToolbar widget) : super(widget); 31 | 32 | @override 33 | OverflowToolbar get widget { 34 | return super.widget as OverflowToolbar; 35 | } 36 | 37 | @override 38 | OverflowToolbarRender get renderObject { 39 | return super.renderObject as OverflowToolbarRender; 40 | } 41 | 42 | @override 43 | void update(OverflowToolbar newWidget) { 44 | super.update(newWidget); 45 | 46 | // for (final index in _children.keys.toList()) { 47 | // _children[index] = updateChild(_children[index], newWidget.icons[index], index); 48 | // } 49 | } 50 | 51 | @override 52 | void unmount() { 53 | super.unmount(); 54 | _children.clear(); 55 | } 56 | 57 | @override 58 | void visitChildren(ElementVisitor visitor) { 59 | // for (final child in _children.values) { 60 | // if (child != null) visitor(child); 61 | // } 62 | } 63 | 64 | @override 65 | void forgetChild(Element child) { 66 | super.forgetChild(child); 67 | // _children.removeWhere((key, value) => value == child); 68 | } 69 | 70 | @override 71 | void insertRenderObjectChild(RenderBox child, int slot) { 72 | renderObject.insertRenderObjectChild(child, slot); 73 | } 74 | 75 | @override 76 | void removeRenderObjectChild(RenderBox child, int slot) { 77 | renderObject.removeRenderObjectChild(child, slot); 78 | } 79 | 80 | void requestItem(int index) { 81 | _children[index] = updateChild(_children[index], widget.icons[index], index); 82 | } 83 | 84 | void removeItemsAfter(int index) { 85 | final child = _children[index]; 86 | if (child != null) { 87 | forgetChild(child); 88 | } 89 | } 90 | } 91 | 92 | // endregion 93 | 94 | // region OverflowToolbarChild 95 | 96 | class OverflowToolbarChild extends BoxParentData { 97 | final RenderBox renderBox; 98 | 99 | var index = -1; 100 | 101 | OverflowToolbarChild(this.renderBox); 102 | } 103 | 104 | // endregion 105 | 106 | // region OverflowToolbarRender 107 | 108 | class OverflowToolbarRender extends RenderBox { 109 | final OverflowToolbarElement _element; 110 | final _children = []; 111 | 112 | OverflowToolbarRender(this._element); 113 | 114 | // region Children Management 115 | 116 | @override 117 | void attach(PipelineOwner owner) { 118 | super.attach(owner); 119 | 120 | for (final child in _children) { 121 | child.renderBox.attach(owner); 122 | } 123 | } 124 | 125 | @override 126 | void detach() { 127 | super.detach(); 128 | 129 | for (final child in _children) { 130 | child.renderBox.detach(); 131 | } 132 | } 133 | 134 | @override 135 | void visitChildren(RenderObjectVisitor visitor) { 136 | for (final child in _children) { 137 | visitor(child.renderBox); 138 | } 139 | } 140 | 141 | @override 142 | void setupParentData(RenderBox child) { 143 | child.parentData = OverflowToolbarChild(child); 144 | } 145 | 146 | void allowMutationsLock(void block()) { 147 | invokeLayoutCallback((_) { 148 | _element.owner?.buildScope(_element, block); 149 | }); 150 | } 151 | 152 | void insertRenderObjectChild(RenderBox child, int slot) { 153 | adoptChild(child); 154 | insertChild(child); 155 | } 156 | 157 | void removeRenderObjectChild(RenderBox child, int slot) { 158 | dropChild(child); 159 | _children.removeWhere((element) => element.index == slot); 160 | } 161 | 162 | void insertChild(RenderBox renderBox) { 163 | final child = renderBox.parentData as OverflowToolbarChild; 164 | final index = _children.lowerBoundBy(child, (value) => value.index); 165 | _children.insert(index, child); 166 | } 167 | 168 | // endregion 169 | 170 | // region Layout 171 | 172 | @override 173 | void performLayout() {} 174 | 175 | // endregion 176 | 177 | // region Paint 178 | 179 | @override 180 | void paint(PaintingContext context, Offset offset) {} 181 | 182 | // endregion 183 | 184 | // region HitTest 185 | 186 | @override 187 | bool hitTestChildren(BoxHitTestResult result, {required Offset position}) { 188 | return super.hitTestChildren(result, position: position); 189 | } 190 | 191 | // endregion 192 | 193 | } 194 | 195 | // endregion 196 | -------------------------------------------------------------------------------- /lib/part3b_simple_overlay/simple_overlay.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/gestures.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter/rendering.dart'; 4 | import 'package:flutter/widgets.dart'; 5 | 6 | // region SimpleOverlay 7 | 8 | class SimpleOverlay extends RenderObjectWidget { 9 | final Widget child; 10 | final Widget overlay; 11 | 12 | const SimpleOverlay({ 13 | required this.child, 14 | required this.overlay, 15 | }); 16 | 17 | @override 18 | RenderObjectElement createElement() { 19 | return SimpleOverlayElement(this); 20 | } 21 | 22 | @override 23 | RenderObject createRenderObject(BuildContext context) { 24 | return SimpleOverlayRenderObject(); 25 | } 26 | } 27 | 28 | // endregion 29 | 30 | // region SimpleOverlayElement 31 | 32 | class SimpleOverlayElement extends RenderObjectElement { 33 | // ... 34 | Element? _child; 35 | Element? _overlay; 36 | 37 | SimpleOverlayElement(SimpleOverlay widget) : super(widget); 38 | 39 | @override 40 | SimpleOverlay get widget { 41 | return super.widget as SimpleOverlay; 42 | } 43 | 44 | @override 45 | SimpleOverlayRenderObject get renderObject { 46 | return super.renderObject as SimpleOverlayRenderObject; 47 | } 48 | 49 | @override 50 | void mount(Element? parent, newSlot) { 51 | super.mount(parent, newSlot); 52 | 53 | _child = inflateWidget(widget.child, true); 54 | _overlay = inflateWidget(widget.overlay, false); 55 | } 56 | 57 | @override 58 | void update(SimpleOverlay newWidget) { 59 | super.update(newWidget); 60 | 61 | _child = updateChild(_child, newWidget.child, true); 62 | _overlay = updateChild(_overlay, newWidget.overlay, false); 63 | } 64 | 65 | @override 66 | void unmount() { 67 | super.unmount(); 68 | 69 | _child = null; 70 | _overlay = null; 71 | } 72 | 73 | @override 74 | void visitChildren(ElementVisitor visitor) { 75 | if (_child != null) visitor(_child!); 76 | if (_overlay != null) visitor(_overlay!); 77 | } 78 | 79 | @override 80 | void forgetChild(Element child) { 81 | super.forgetChild(child); 82 | if (_child == child) _child = null; 83 | if (_overlay == child) _overlay = null; 84 | } 85 | 86 | @override 87 | void insertRenderObjectChild(RenderBox child, bool slot) { 88 | renderObject.insertRenderObjectChild(child, slot); 89 | } 90 | 91 | @override 92 | void moveRenderObjectChild(RenderBox child, bool oldSlot, bool newSlot) { 93 | renderObject.moveRenderObjectChild(child, oldSlot, newSlot); 94 | } 95 | 96 | @override 97 | void removeRenderObjectChild(RenderBox child, bool slot) { 98 | renderObject.removeRenderObjectChild(child, slot); 99 | } 100 | } 101 | 102 | // endregion 103 | 104 | // region SimpleOverlayRenderObject 105 | 106 | class SimpleOverlayRenderObject extends RenderBox { 107 | //... 108 | RenderBox? _child; 109 | RenderBox? _overlay; 110 | 111 | // region Children Management 112 | 113 | @override 114 | void attach(covariant PipelineOwner owner) { 115 | super.attach(owner); 116 | _child?.attach(owner); 117 | _overlay?.attach(owner); 118 | } 119 | 120 | @override 121 | void detach() { 122 | super.detach(); 123 | _child?.detach(); 124 | _overlay?.detach(); 125 | } 126 | 127 | @override 128 | void visitChildren(RenderObjectVisitor visitor) { 129 | if (_child != null) visitor(_child!); 130 | if (_overlay != null) visitor(_overlay!); 131 | } 132 | 133 | @override 134 | void redepthChildren() { 135 | super.redepthChildren(); 136 | _child?.redepthChildren(); 137 | _overlay?.redepthChildren(); 138 | } 139 | 140 | void insertRenderObjectChild(RenderBox child, bool slot) { 141 | if (slot) { 142 | _child = child; 143 | } else { 144 | _overlay = child; 145 | } 146 | adoptChild(child); 147 | } 148 | 149 | void moveRenderObjectChild(RenderBox child, bool oldSlot, bool newSlot) { 150 | if (oldSlot) { 151 | _child = null; 152 | } else { 153 | _overlay = null; 154 | } 155 | if (newSlot) { 156 | _child = child; 157 | } else { 158 | _overlay = child; 159 | } 160 | } 161 | 162 | void removeRenderObjectChild(RenderBox child, bool slot) { 163 | if (slot) { 164 | _child = null; 165 | } else { 166 | _overlay = null; 167 | } 168 | dropChild(child); 169 | } 170 | 171 | // endregion 172 | 173 | // region Layout 174 | 175 | @override 176 | void performLayout() { 177 | var followerConstraints = constraints; 178 | 179 | final child = _child; 180 | if (child != null) { 181 | child.layout(constraints, parentUsesSize: true); 182 | followerConstraints = BoxConstraints.tight(child.size); 183 | } 184 | 185 | final overlay = _overlay; 186 | if (overlay != null) { 187 | overlay.layout(followerConstraints, parentUsesSize: true); 188 | } 189 | 190 | size = _child?.size ?? _overlay?.size ?? constraints.smallest; 191 | } 192 | 193 | // endregion 194 | 195 | // region Paint 196 | 197 | @override 198 | void paint(PaintingContext context, Offset offset) { 199 | if (_child != null) { 200 | context.paintChild(_child!, offset); 201 | } 202 | if (_overlay != null) { 203 | context.paintChild(_overlay!, offset); 204 | } 205 | } 206 | 207 | // endregion 208 | 209 | // region Touch 210 | 211 | @override 212 | bool hitTestChildren(BoxHitTestResult result, {required Offset position}) { 213 | if (_overlay?.hitTest(result, position: position) == true) { 214 | return true; 215 | } 216 | if (_child?.hitTest(result, position: position) == true) { 217 | return true; 218 | } 219 | return false; 220 | } 221 | 222 | // endregion 223 | } 224 | 225 | // endregion 226 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 11 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 12 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; 13 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 14 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 15 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXCopyFilesBuildPhase section */ 19 | 9705A1C41CF9048500538489 /* Embed Frameworks */ = { 20 | isa = PBXCopyFilesBuildPhase; 21 | buildActionMask = 2147483647; 22 | dstPath = ""; 23 | dstSubfolderSpec = 10; 24 | files = ( 25 | ); 26 | name = "Embed Frameworks"; 27 | runOnlyForDeploymentPostprocessing = 0; 28 | }; 29 | /* End PBXCopyFilesBuildPhase section */ 30 | 31 | /* Begin PBXFileReference section */ 32 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 33 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 34 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 35 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 36 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 37 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 38 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 39 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 40 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 41 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 42 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 43 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 44 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 45 | /* End PBXFileReference section */ 46 | 47 | /* Begin PBXFrameworksBuildPhase section */ 48 | 97C146EB1CF9000F007C117D /* Frameworks */ = { 49 | isa = PBXFrameworksBuildPhase; 50 | buildActionMask = 2147483647; 51 | files = ( 52 | ); 53 | runOnlyForDeploymentPostprocessing = 0; 54 | }; 55 | /* End PBXFrameworksBuildPhase section */ 56 | 57 | /* Begin PBXGroup section */ 58 | 9740EEB11CF90186004384FC /* Flutter */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 62 | 9740EEB21CF90195004384FC /* Debug.xcconfig */, 63 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 64 | 9740EEB31CF90195004384FC /* Generated.xcconfig */, 65 | ); 66 | name = Flutter; 67 | sourceTree = ""; 68 | }; 69 | 97C146E51CF9000F007C117D = { 70 | isa = PBXGroup; 71 | children = ( 72 | 9740EEB11CF90186004384FC /* Flutter */, 73 | 97C146F01CF9000F007C117D /* Runner */, 74 | 97C146EF1CF9000F007C117D /* Products */, 75 | ); 76 | sourceTree = ""; 77 | }; 78 | 97C146EF1CF9000F007C117D /* Products */ = { 79 | isa = PBXGroup; 80 | children = ( 81 | 97C146EE1CF9000F007C117D /* Runner.app */, 82 | ); 83 | name = Products; 84 | sourceTree = ""; 85 | }; 86 | 97C146F01CF9000F007C117D /* Runner */ = { 87 | isa = PBXGroup; 88 | children = ( 89 | 97C146FA1CF9000F007C117D /* Main.storyboard */, 90 | 97C146FD1CF9000F007C117D /* Assets.xcassets */, 91 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, 92 | 97C147021CF9000F007C117D /* Info.plist */, 93 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, 94 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, 95 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, 96 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, 97 | ); 98 | path = Runner; 99 | sourceTree = ""; 100 | }; 101 | /* End PBXGroup section */ 102 | 103 | /* Begin PBXNativeTarget section */ 104 | 97C146ED1CF9000F007C117D /* Runner */ = { 105 | isa = PBXNativeTarget; 106 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; 107 | buildPhases = ( 108 | 9740EEB61CF901F6004384FC /* Run Script */, 109 | 97C146EA1CF9000F007C117D /* Sources */, 110 | 97C146EB1CF9000F007C117D /* Frameworks */, 111 | 97C146EC1CF9000F007C117D /* Resources */, 112 | 9705A1C41CF9048500538489 /* Embed Frameworks */, 113 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 114 | ); 115 | buildRules = ( 116 | ); 117 | dependencies = ( 118 | ); 119 | name = Runner; 120 | productName = Runner; 121 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */; 122 | productType = "com.apple.product-type.application"; 123 | }; 124 | /* End PBXNativeTarget section */ 125 | 126 | /* Begin PBXProject section */ 127 | 97C146E61CF9000F007C117D /* Project object */ = { 128 | isa = PBXProject; 129 | attributes = { 130 | LastUpgradeCheck = 1020; 131 | ORGANIZATIONNAME = ""; 132 | TargetAttributes = { 133 | 97C146ED1CF9000F007C117D = { 134 | CreatedOnToolsVersion = 7.3.1; 135 | LastSwiftMigration = 1100; 136 | }; 137 | }; 138 | }; 139 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; 140 | compatibilityVersion = "Xcode 9.3"; 141 | developmentRegion = en; 142 | hasScannedForEncodings = 0; 143 | knownRegions = ( 144 | en, 145 | Base, 146 | ); 147 | mainGroup = 97C146E51CF9000F007C117D; 148 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */; 149 | projectDirPath = ""; 150 | projectRoot = ""; 151 | targets = ( 152 | 97C146ED1CF9000F007C117D /* Runner */, 153 | ); 154 | }; 155 | /* End PBXProject section */ 156 | 157 | /* Begin PBXResourcesBuildPhase section */ 158 | 97C146EC1CF9000F007C117D /* Resources */ = { 159 | isa = PBXResourcesBuildPhase; 160 | buildActionMask = 2147483647; 161 | files = ( 162 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 163 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 164 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 165 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, 166 | ); 167 | runOnlyForDeploymentPostprocessing = 0; 168 | }; 169 | /* End PBXResourcesBuildPhase section */ 170 | 171 | /* Begin PBXShellScriptBuildPhase section */ 172 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { 173 | isa = PBXShellScriptBuildPhase; 174 | buildActionMask = 2147483647; 175 | files = ( 176 | ); 177 | inputPaths = ( 178 | ); 179 | name = "Thin Binary"; 180 | outputPaths = ( 181 | ); 182 | runOnlyForDeploymentPostprocessing = 0; 183 | shellPath = /bin/sh; 184 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; 185 | }; 186 | 9740EEB61CF901F6004384FC /* Run Script */ = { 187 | isa = PBXShellScriptBuildPhase; 188 | buildActionMask = 2147483647; 189 | files = ( 190 | ); 191 | inputPaths = ( 192 | ); 193 | name = "Run Script"; 194 | outputPaths = ( 195 | ); 196 | runOnlyForDeploymentPostprocessing = 0; 197 | shellPath = /bin/sh; 198 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; 199 | }; 200 | /* End PBXShellScriptBuildPhase section */ 201 | 202 | /* Begin PBXSourcesBuildPhase section */ 203 | 97C146EA1CF9000F007C117D /* Sources */ = { 204 | isa = PBXSourcesBuildPhase; 205 | buildActionMask = 2147483647; 206 | files = ( 207 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, 208 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, 209 | ); 210 | runOnlyForDeploymentPostprocessing = 0; 211 | }; 212 | /* End PBXSourcesBuildPhase section */ 213 | 214 | /* Begin PBXVariantGroup section */ 215 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = { 216 | isa = PBXVariantGroup; 217 | children = ( 218 | 97C146FB1CF9000F007C117D /* Base */, 219 | ); 220 | name = Main.storyboard; 221 | sourceTree = ""; 222 | }; 223 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { 224 | isa = PBXVariantGroup; 225 | children = ( 226 | 97C147001CF9000F007C117D /* Base */, 227 | ); 228 | name = LaunchScreen.storyboard; 229 | sourceTree = ""; 230 | }; 231 | /* End PBXVariantGroup section */ 232 | 233 | /* Begin XCBuildConfiguration section */ 234 | 249021D3217E4FDB00AE95B9 /* Profile */ = { 235 | isa = XCBuildConfiguration; 236 | buildSettings = { 237 | ALWAYS_SEARCH_USER_PATHS = NO; 238 | CLANG_ANALYZER_NONNULL = YES; 239 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 240 | CLANG_CXX_LIBRARY = "libc++"; 241 | CLANG_ENABLE_MODULES = YES; 242 | CLANG_ENABLE_OBJC_ARC = YES; 243 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 244 | CLANG_WARN_BOOL_CONVERSION = YES; 245 | CLANG_WARN_COMMA = YES; 246 | CLANG_WARN_CONSTANT_CONVERSION = YES; 247 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 248 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 249 | CLANG_WARN_EMPTY_BODY = YES; 250 | CLANG_WARN_ENUM_CONVERSION = YES; 251 | CLANG_WARN_INFINITE_RECURSION = YES; 252 | CLANG_WARN_INT_CONVERSION = YES; 253 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 254 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 255 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 256 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 257 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 258 | CLANG_WARN_STRICT_PROTOTYPES = YES; 259 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 260 | CLANG_WARN_UNREACHABLE_CODE = YES; 261 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 262 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 263 | COPY_PHASE_STRIP = NO; 264 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 265 | ENABLE_NS_ASSERTIONS = NO; 266 | ENABLE_STRICT_OBJC_MSGSEND = YES; 267 | GCC_C_LANGUAGE_STANDARD = gnu99; 268 | GCC_NO_COMMON_BLOCKS = YES; 269 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 270 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 271 | GCC_WARN_UNDECLARED_SELECTOR = YES; 272 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 273 | GCC_WARN_UNUSED_FUNCTION = YES; 274 | GCC_WARN_UNUSED_VARIABLE = YES; 275 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 276 | MTL_ENABLE_DEBUG_INFO = NO; 277 | SDKROOT = iphoneos; 278 | SUPPORTED_PLATFORMS = iphoneos; 279 | TARGETED_DEVICE_FAMILY = "1,2"; 280 | VALIDATE_PRODUCT = YES; 281 | }; 282 | name = Profile; 283 | }; 284 | 249021D4217E4FDB00AE95B9 /* Profile */ = { 285 | isa = XCBuildConfiguration; 286 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 287 | buildSettings = { 288 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 289 | CLANG_ENABLE_MODULES = YES; 290 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 291 | ENABLE_BITCODE = NO; 292 | INFOPLIST_FILE = Runner/Info.plist; 293 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 294 | PRODUCT_BUNDLE_IDENTIFIER = dev.matrix.customWidgets; 295 | PRODUCT_NAME = "$(TARGET_NAME)"; 296 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 297 | SWIFT_VERSION = 5.0; 298 | VERSIONING_SYSTEM = "apple-generic"; 299 | }; 300 | name = Profile; 301 | }; 302 | 97C147031CF9000F007C117D /* Debug */ = { 303 | isa = XCBuildConfiguration; 304 | buildSettings = { 305 | ALWAYS_SEARCH_USER_PATHS = NO; 306 | CLANG_ANALYZER_NONNULL = YES; 307 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 308 | CLANG_CXX_LIBRARY = "libc++"; 309 | CLANG_ENABLE_MODULES = YES; 310 | CLANG_ENABLE_OBJC_ARC = YES; 311 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 312 | CLANG_WARN_BOOL_CONVERSION = YES; 313 | CLANG_WARN_COMMA = YES; 314 | CLANG_WARN_CONSTANT_CONVERSION = YES; 315 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 316 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 317 | CLANG_WARN_EMPTY_BODY = YES; 318 | CLANG_WARN_ENUM_CONVERSION = YES; 319 | CLANG_WARN_INFINITE_RECURSION = YES; 320 | CLANG_WARN_INT_CONVERSION = YES; 321 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 322 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 323 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 324 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 325 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 326 | CLANG_WARN_STRICT_PROTOTYPES = YES; 327 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 328 | CLANG_WARN_UNREACHABLE_CODE = YES; 329 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 330 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 331 | COPY_PHASE_STRIP = NO; 332 | DEBUG_INFORMATION_FORMAT = dwarf; 333 | ENABLE_STRICT_OBJC_MSGSEND = YES; 334 | ENABLE_TESTABILITY = YES; 335 | GCC_C_LANGUAGE_STANDARD = gnu99; 336 | GCC_DYNAMIC_NO_PIC = NO; 337 | GCC_NO_COMMON_BLOCKS = YES; 338 | GCC_OPTIMIZATION_LEVEL = 0; 339 | GCC_PREPROCESSOR_DEFINITIONS = ( 340 | "DEBUG=1", 341 | "$(inherited)", 342 | ); 343 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 344 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 345 | GCC_WARN_UNDECLARED_SELECTOR = YES; 346 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 347 | GCC_WARN_UNUSED_FUNCTION = YES; 348 | GCC_WARN_UNUSED_VARIABLE = YES; 349 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 350 | MTL_ENABLE_DEBUG_INFO = YES; 351 | ONLY_ACTIVE_ARCH = YES; 352 | SDKROOT = iphoneos; 353 | TARGETED_DEVICE_FAMILY = "1,2"; 354 | }; 355 | name = Debug; 356 | }; 357 | 97C147041CF9000F007C117D /* Release */ = { 358 | isa = XCBuildConfiguration; 359 | buildSettings = { 360 | ALWAYS_SEARCH_USER_PATHS = NO; 361 | CLANG_ANALYZER_NONNULL = YES; 362 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 363 | CLANG_CXX_LIBRARY = "libc++"; 364 | CLANG_ENABLE_MODULES = YES; 365 | CLANG_ENABLE_OBJC_ARC = YES; 366 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 367 | CLANG_WARN_BOOL_CONVERSION = YES; 368 | CLANG_WARN_COMMA = YES; 369 | CLANG_WARN_CONSTANT_CONVERSION = YES; 370 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 371 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 372 | CLANG_WARN_EMPTY_BODY = YES; 373 | CLANG_WARN_ENUM_CONVERSION = YES; 374 | CLANG_WARN_INFINITE_RECURSION = YES; 375 | CLANG_WARN_INT_CONVERSION = YES; 376 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 377 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 378 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 379 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 380 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 381 | CLANG_WARN_STRICT_PROTOTYPES = YES; 382 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 383 | CLANG_WARN_UNREACHABLE_CODE = YES; 384 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 385 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 386 | COPY_PHASE_STRIP = NO; 387 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 388 | ENABLE_NS_ASSERTIONS = NO; 389 | ENABLE_STRICT_OBJC_MSGSEND = YES; 390 | GCC_C_LANGUAGE_STANDARD = gnu99; 391 | GCC_NO_COMMON_BLOCKS = YES; 392 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 393 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 394 | GCC_WARN_UNDECLARED_SELECTOR = YES; 395 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 396 | GCC_WARN_UNUSED_FUNCTION = YES; 397 | GCC_WARN_UNUSED_VARIABLE = YES; 398 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 399 | MTL_ENABLE_DEBUG_INFO = NO; 400 | SDKROOT = iphoneos; 401 | SUPPORTED_PLATFORMS = iphoneos; 402 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 403 | TARGETED_DEVICE_FAMILY = "1,2"; 404 | VALIDATE_PRODUCT = YES; 405 | }; 406 | name = Release; 407 | }; 408 | 97C147061CF9000F007C117D /* Debug */ = { 409 | isa = XCBuildConfiguration; 410 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 411 | buildSettings = { 412 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 413 | CLANG_ENABLE_MODULES = YES; 414 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 415 | ENABLE_BITCODE = NO; 416 | INFOPLIST_FILE = Runner/Info.plist; 417 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 418 | PRODUCT_BUNDLE_IDENTIFIER = dev.matrix.customWidgets; 419 | PRODUCT_NAME = "$(TARGET_NAME)"; 420 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 421 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 422 | SWIFT_VERSION = 5.0; 423 | VERSIONING_SYSTEM = "apple-generic"; 424 | }; 425 | name = Debug; 426 | }; 427 | 97C147071CF9000F007C117D /* Release */ = { 428 | isa = XCBuildConfiguration; 429 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 430 | buildSettings = { 431 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 432 | CLANG_ENABLE_MODULES = YES; 433 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 434 | ENABLE_BITCODE = NO; 435 | INFOPLIST_FILE = Runner/Info.plist; 436 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 437 | PRODUCT_BUNDLE_IDENTIFIER = dev.matrix.customWidgets; 438 | PRODUCT_NAME = "$(TARGET_NAME)"; 439 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 440 | SWIFT_VERSION = 5.0; 441 | VERSIONING_SYSTEM = "apple-generic"; 442 | }; 443 | name = Release; 444 | }; 445 | /* End XCBuildConfiguration section */ 446 | 447 | /* Begin XCConfigurationList section */ 448 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { 449 | isa = XCConfigurationList; 450 | buildConfigurations = ( 451 | 97C147031CF9000F007C117D /* Debug */, 452 | 97C147041CF9000F007C117D /* Release */, 453 | 249021D3217E4FDB00AE95B9 /* Profile */, 454 | ); 455 | defaultConfigurationIsVisible = 0; 456 | defaultConfigurationName = Release; 457 | }; 458 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { 459 | isa = XCConfigurationList; 460 | buildConfigurations = ( 461 | 97C147061CF9000F007C117D /* Debug */, 462 | 97C147071CF9000F007C117D /* Release */, 463 | 249021D4217E4FDB00AE95B9 /* Profile */, 464 | ); 465 | defaultConfigurationIsVisible = 0; 466 | defaultConfigurationName = Release; 467 | }; 468 | /* End XCConfigurationList section */ 469 | }; 470 | rootObject = 97C146E61CF9000F007C117D /* Project object */; 471 | } 472 | --------------------------------------------------------------------------------