🎧 New: AI-Generated Podcasts Turn your study notes into engaging audio conversations. Learn more

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Full Transcript

CMSC 23 2ND SEM | 2023 - 2024 LAYOUTING iOS APPS In Flutter, we need this for some operations We can layout iOS app using the Cupertino...

CMSC 23 2ND SEM | 2023 - 2024 LAYOUTING iOS APPS In Flutter, we need this for some operations We can layout iOS app using the Cupertino that we need in our mobile application such package as fetching data over a network, writing in a database, or reading from a file ASYNCHRONOUS IN DART Asynchronous computations usually provide a Future as a result Use the async and await keywords FUTURE Future is a result of an asynchronous computation Two states: uncompleted and competed UNCOMPLETED 08: ASYNCHRONOUS PROGRAMMING: FUTURES, ○ When you call an asynchronous ASYNC, AWAIT function, it returns an uncompleted ASYNCHRONOUS PROGRAMMING future A multithreaded model that’s most ○ That future is waiting for the applicable to networking and function’s asynchronous operation communications to finish or throw an error It is a non-blocking architecture COMPLETED Multiple related operations can run ○ Asynchronous operation succeeds, concurrently without waiting for other tasks the future completes with a value to complete ○ Otherwise, it completes with an error ○ COMPLETED WITH VALUE sequential yung code, hindi nagdedepend Future , T can be of any sa external libraries data type or void Future, Future DIFFERENCES OF ASYNC AND SYNC ○ COMPLETED WITH ERROR ASYNC SYNC Asynchronous operation performed by the function Multi-threaded Single-threaded fails for any reason, the future completed with an error Non-blocking Blocking WORKING WITH FUTURES: ASYNC AND AWAIT Slower and more Increases throughput To define an async function, add async methodical before the function body Await keyboard works only in async WHEN TO USE ASYNC? functions Used in programming independent tasks Responsive UI Synchronous Programming ASYNC AND SYNC Asynchronous and synchronous methods offer advantages for different stakeholders: async for users, sync for developers WHY ASYNCHRONOUS CODE MATTERS AGUITEZ | ANARETA | ARCEDERA | BALITAAN | EVANGELISTA | MORELOS Page 17 CMSC 23 2ND SEM | 2023 - 2024 Asynchronous Programming HANDLING ERRORS Use try-catch AGUITEZ | ANARETA | ARCEDERA | BALITAAN | EVANGELISTA | MORELOS Page 18 CMSC 23 2ND SEM | 2023 - 2024 09: STATE MANAGEMENT ○ User preferences STATE ○ Login info It is information that can be read when the ○ Notifications in a social networking widget is built and changed over the app lifetime of the app ○ Shopping cart in an e-commerce setState() allows us to set the properties of app the state object that triggers the redraw of ○ Read/unread state of articles in a the UI new app State of an app is everything that exists in memory when the app is running: Some Notes on State Management ○ App’s assets You can use State and setState() to ○ Variables manage all of the state in your app ○ UI There is also no clear-cut, universal rule to ○ Animation state distinguish whether a particular variable is ○ Textures ephemeral or app state ○ Fonts SIMPLE APP STATE MANAGEMENT STATE MANAGEMENT It is the most popular and necessary process in the lifecycle of an application Flutter is declarative Flutter builds its user interface to reflect the current state of your application PROVIDER PACKAGE It is an easy to use package that wraps around InheritedWidgets that makes it easier to use and manage TYPES OF CONCEPTUAL STATE Widget listens to changes in the state and 1. EPHEMERAL STATE update it as soon as they are notified This is called the UI state or local state flutter pub add provider It is the state you can neatly contain in a single widget TYPES OF PROVIDER No need to use state management 1. ListenableProvider techniques on this kind of state just use a Used for listenable objects StatefulWidget and the method setState() It will listen, then ask widgets depending on Examples: it and affected by the state change to ○ Current page in a Page View rebuild ○ Current progress of complex listen to central data stored animation 2. ChangeNotifierProvider ○ Current selected tab in a Similar to ListenableProvider but for objects BottomNavigationBar and calls ChangeNotifier.dispose 2. APP STATE automatically when needed This is when you want to share across many notifyListeners() parts of your app ○ The method specific to It is also shared state ChangeNotifier Examples: AGUITEZ | ANARETA | ARCEDERA | BALITAAN | EVANGELISTA | MORELOS Page 19 CMSC 23 2ND SEM | 2023 - 2024 ○ This method is called anytime the Contains the functions/logic model changes in a way that might ○ Screen change your app’s UI Contains the screens to be 3. ValueListenableProvider shown in the app Listens to a ValueListenable and exposes the Code: value https://github.com/CMSC-23-1st-Sem-2022-2023/lec 4. StreamProvider t09_statemanagement Listens to stream, exposes the late value emitted, and asks widgets dependent on the stream to rebuild continuous 5. FutureProvider Takes a future class and updates the widgets depending on it when the future is completed context.watch() – listens to the changes to the provider model context.read() – returns the provider model without listening to it CONSUMER Calls the provider of in a new widget and delegates its build It specifically rebuilds a specific widget It has a builder that has 3 parameters ○ Context – for build method ○ Name of model – an instance of the changenotifier ○ Child – optimization Different State Management Packages Provider Revierpod setState InheritedWidget and InheritedModel Redux BLoC/Rx GetIt MobX Binder GetX EXAMPLE Section your code into different folders ○ Model Contains the data structure/classes ○ Provider AGUITEZ | ANARETA | ARCEDERA | BALITAAN | EVANGELISTA | MORELOS Page 20 CMSC 23 2ND SEM | 2023 - 2024 10: PACKAGES, PLUGINS, BACKGROUNDS CREATE YOUR OWN PACKAGE PACKAGES Use flutter create -template=package open source use the command flutter pub add ○ LICENSE to place the package ○ Test/packagename_test.dart into your mobile app ○ packagename.iml flutter pub get – get daw ng list ○.gitignore ○.metadata ○ pubspec.yaml ○ README.md ○ lib/packagename.dart ○./idea/modules.xml,./idea/workspace.xaml ○ CHANGELOG.md IMPLEMENT THE PACKAGE Add the functionality inside the main PACKAGE COMPONENTS lib/.dart pubspec.yaml ○ metafile that declares the package FEDERATED PLUGINS name, version, author, and other Way of splitting support for different information platforms into separate packages Lib It uses one package for iOS, another for ○ Public code in the package Android, for the web, and IoT device (Internet of things) PACKAGE TYPES It allows a domain expert to extend an DART PACKAGES existing plugin to work for the platform they General packages written in Dart know best These packages might contain Flutter-specific functionality and have a FEDERATE PLUGINS REQUIREMENTS dependency on the Flutter framework, App-facing package restricting their use to Flutter only ○ Package the users depend on to use the plugin PLUGIN PACKAGES ○ Specifies API usage by the Flutter ap It is a type of package Platform package Specialized Dart package that contains an ○ One or more packages that contain API written in Dart code combined with one platform-specific implementation of or more platform-specific implementations code Can be written for Android, iOS, Web, Platform interface package MacOS, Windows, or Linux ○ Links the app-facing package to the platform package FOREIGN FUNCTION INTERFACE (FFI) PLUGIN PACKAGES ENDORSED AND NON-ENDORSED FEDERATED PLUGIN Specialized Dart package that contains an A federated plugin is endorsed when your API written in Dart code combined with one implementation for a specific platform is or more platform-specific implementations added to the plugin and is automatically This are the foreign function interfaces available to the app Used to call native C APIS, and to read, write, allocate, deallocate native memory AGUITEZ | ANARETA | ARCEDERA | BALITAAN | EVANGELISTA | MORELOS Page 21 CMSC 23 2ND SEM | 2023 - 2024 Otherwise, when you need to manually add the dependencies for a platform then it is non-endorsed BACKGROUND PROCESS Implementing Dart code, even though your app is not currently active app ○ Example: Notifications, Sensors Isolates This is Dart’s model for multithreading, though an isolate doesn’t share memory with the main program The isolate is used by creating callbacks and callback dispatchers WorkManager PLUGIN This plugin enables persistent background processing that keeps tasks scheduled through app restaurants and system reboots https://pub.dev/packages/workmanager AGUITEZ | ANARETA | ARCEDERA | BALITAAN | EVANGELISTA | MORELOS Page 22 CMSC 23 2ND SEM | 2023 - 2024 11: DATA PERSISTENCE AND NETWORKING DATA PERSISTENCE IN FLUTTER DATA PERSISTENCE 1. Using SQLite The capability to have data that the app Use the sqlite and path plugin uses or relies on to continue to be available This uses SQL statements in insert, delete, regardless of changes to the app’s state as update, and queries compared to other it moves through the app cycle local persistence solutions 2. Read and write files DIFFERENT TYPES OF PERSISTENT DATA IN ANDROID Use the pathprovider App-specific storage Pathprovider is a platform-agnostic way to ○ Store files that are meant for your app’s use access commonly used locations on the only, either in dedicated directories with an device’s file system internal storage volume or different Temporary (cache) and Documents dedicated directories with external storage Directory ○ Internal storage is used to save sensitive 3. Store key-value data on disk information that other apps shouldn’t Use the sharepreferences plugin access Limitations that it can only save primitive ○ No permission needed for internal storage types (in, double, bool, string, and stringList) ○ Files are removed when the app is Not designed for storing large amounts of uninstalled data Shared storage ○ Store files that your app intends to share CATEGORIES OF STORAGE LOCATIONS with other apps such as media, documents, INTERNAL and other files ○ Internal storage is smaller than the ○ Should use the MediaStoreAPI or Storage external storage but it is always Access Framework and must include available on all devices, making it permissions in reading and writing to the more reliable to put data in which external storage your app depends ○ Files are not removed when the app is EXTERNAL uninstalled ○ Could be any removable volume Preferences such as SD cards ○ Store private, primitive data in key-value pairs FLUTTER NETWORKING ○ This uses the SharedPreferences API to save Use the http package values In the Android Manifest must include the ○ This enables you to save and retrieve permission for INTERNET persistent key-value pairs of primitive data ○ This can be any primitive data: booleans, JSON AND SERIALIZATION floats, ints, longs, and strings Serialization refers to the process to ○ Files stored in preferences are moved when converting object to string while uninstalled deserialization is from string to an object Databases MANUAL SERIALIZATION ○ Store structure data in a private database ○ Refers to the use of built-in JSON ○ Files are removed when the app is decoder in dart:convert uninstalled ○ Manual decoding does not perform Network Connection well when your project becomes ○ Store data on the web with your own bigger network server ○ Writing decoding logic by hand can become hard to manage and error-prone AGUITEZ | ANARETA | ARCEDERA | BALITAAN | EVANGELISTA | MORELOS Page 23 CMSC 23 2ND SEM | 2023 - 2024 ○ But if you have fewer models in your project then it is better to use manual serialization Use the built-in library dart:convert Use the jsonDecode() returns a Map Use the.fromJson() to construct a new object with the data from the map structure Use the toJson() converts an object to a map instance CODE GENERATION LIBRARIES ○ Uses external libraries to generate encoding boilerplate for you ○ The difference is a one time setup is required, then a file watcher is run to generate the code from the model classes Use json_serializable or built_value json_serializable allows the user to make regular classes serializable by using annotations built_value provides a higher level way of defining immutable value classes that can also be serialized to JSON FIREBASE Backend-as-a-Service (BaaS) app development platform that provides hosted backend services such as realtime database, cloud storage, authentication, crash reporting, machine learning, remote configuration, and hosting for your static files AGUITEZ | ANARETA | ARCEDERA | BALITAAN | EVANGELISTA | MORELOS Page 24 CMSC 23 2ND SEM | 2023 - 2024 12: TESTING, DISTRIBUTION, AND MONETIZATION FLUTTER TESTING Testing is an important phase in the development cycle. It ensures that the application is of high quality It requires careful planning and execution Make sure things work Systematic + Automated QA Quality Assurance TYPES OF TESTING 1. UNIT TESTING Easiest method to test an application It is based on ensuring the correctness of a piece of code It does not reflect the real environment APP RELEASING 2. WIDGET TESTING Change Icon Ensuring the correctness of widget creation, ○ Go to pubspec.yaml rendering, and interaction with other ○ flutter pub get flutter_launch_icons widgets as expected ○ Then add this lines It goes one step further and provides a real-time environment to find more bugs flutter_icons: android: true ios: true image_path: "assets/booking.png" Change app name ○ Go to Android Manifest ○ Change Application name Sign the app 3. INTEGRATION TESTING ○ You need to create a keystore Involves both unit testing and widget testing ○ Keystore is used to verify the along with external components of the ownership of an application by application like a database or web service providing a digital signature It simulates or mocks the real environment to ○ Use this command to generate your find all bugs early own keystore keytool -genkey -v -keystore TEST-DRIVEN DEVELOPMENT (TDD) %userprofile%\upload-keystore.jks A software development approach where -storetype JKS -keyalg RSA -keysize 2048 tests are written before the actual code -validity 10000 -alias upload ○ You need to configure the reference from the app ○ /android/key.properties ○ Configure the gradle files inside the app AGUITEZ | ANARETA | ARCEDERA | BALITAAN | EVANGELISTA | MORELOS Page 25 CMSC 23 2ND SEM | 2023 - 2024 IN-APP PURCHASES ○ Built in-app revenue with Google Play and App Store support for Flutter PAYMENTS ○ Seamlessly accept payments with multiple providers in your Flutter app Release ○ Type in the terminal: flutter build appbundle ○ If you want an apk: flutter build apk ANDROID APPLICATION PACKAGE (APK) The file that is to be installed on a device Contains all of the app’s files and code inside Signed with app’s certificate ANDROID APPLICATION BUNDLE (AAB) Publishing format that includes all your app’s compiled code and resources and defers APK generation and signing to Google Play Introduced in 2018 Introduced Asset Packs and Dynamic Features Groups of files targeted to a group of devices In this part, the play store selects only the best asset for the user Unlike the APK that it all has the assets and need to download all of it Dynamic Feature ○ the feature are models that may be not needed on the first install of the app ○ Unless the user requests to add the functionality MONETIZATION ADS ○ Easily integrate with Google AdMod and Ad manager ads directly in your Flutter app AGUITEZ | ANARETA | ARCEDERA | BALITAAN | EVANGELISTA | MORELOS Page 26 CMSC 23 2ND SEM | 2023 - 2024 13: MOBILE SECURITY Blackmail the victim with sensitive MOBILE SECURITY information The process of developing, adding, and Harm the victim by destroying or testing security features within the manipulating the victim’s critical application to prevent security vulnerabilities data against threats such as unauthorized access 7. Insufficient Binary Protections and modification There is sensitive information in the app/code itself OWASP Code Obfuscation Open Worldwide Application Security ○ The process of modifying an Project (OWASP) app’s binary to make it A nonprofit foundation that works to harder for humans to improve the security of software understand Community-led open source projects ○ This hides function and class including code, documentation, and names in your compiled Dart standards code Over 250+ local chapters worldwide 8. Security Misconfiguration Tends of thousands of members Example: you did not change the Industry-leading educational and training default password or the system is in conferences development mode 9. Insecure Data Storage OWASP Top 10 Mobile Risks 2024 Storing data in plain text 1. Improper Credential Usage Shared to all Hardcoded credentials 10. Insufficient Cryptography Insecure credential transmission Weak encryption algorithms Insecure credential storage Insufficient key length Weak user authentication Improper key management 2. Inadequate Supply Chain Security Lack of security in third-party FLUTTER SECURITY components Flutter security strategy is based on five key pillars: Malicious insider threats Identify Inadequate testing and validation Detect Lack of security awareness Protect 3. Insecure Authentication/Authorization Respond Presence of insecure direct object Recover reference (IDOR) vulnerabilities Hidden endpoints OBFUSCATING User roles or permission transmissions 1. Android/iOS/macOS supported 4. Insufficient Input/Output Validation 2. Linux/Windows not supported SQL injection 3. Web - minified Inadequate output sanitization 5. Insecure Communication flutter build apk --obfuscate No secure sockets layer/transport --split-debug-info=// 6. Inadequate Privacy Controls Impersonate the victim to commit fraud Misuse the victim’s payment data AGUITEZ | ANARETA | ARCEDERA | BALITAAN | EVANGELISTA | MORELOS Page 27 CMSC 23 2ND SEM | 2023 - 2024 14: GROWTH, ANALYTICS, AND BEYOND APPS AND KEY MOBILE METRICS PHONES Mobile downloads GROWTH OF MOBILE DEVELOPMENT Uninstalls Global mobile app market size amounted to Heatmaps and user session recreations USD 228.98 billion in 2023 Session length and depth Projected to have a Compound Annual Retention rate Growth Rate of 14.3% from 2024 - 2023 (est. Churn rate USD 567.19 billion) Sessions Gaming Application segment of mobile Session intervals applications help the largest revenue share of 34.0% in 2023 FUTURE OF MOBILE APPLICATION DEVELOPMENT Android mobile apps were large but iOS 1. 5G generated 62.0% of the revenue Always striving for better, faster connection Asia Pacific dominated the market and The focus of 5G is speed accounted for over 32.0% of the revenue It’s not just faster than 4G share in 2023 Allows users to connect to different Key players in the mobile market are Apple networks, connect with wearables, devices, Inc., Google LLC, Microsoft Corporation, and machines Amazon Inc., and Gameloft SE Information transfer of milliseconds, and Factors that drive the mobile application reducing latency which provides a better market user experience ○ Smartphone proliferation 2. AR and VR move beyond gaming ○ Increase internet penetration Augmented reality and Virtual reality which ○ Growing use of technologies such as imposes artificial images and objects on Machine Learning and Artificial real-life objects Intelligence However, AR and VR are no longer solely for gamers; these technologies are rapidly MOBILE ANALYTICS expanding to other industries, including Measuring and analysing data generated travel, real estate, and retail by mobile platforms and properties 3. AI Examples Artificial intelligence can stand out in facial ○ Advertising KPIs speech recognition – biometric markers ○ Funnel Analysis AI can improve user safety and data ○ App performance and usage security in fraud detection ○ Heatmaps 4. Blockchain goes beyond cryptocurrency ○ Retention rates Blockchain is essentially a digital ledger that ○ Click-through rates securely records transactions ○ Conversion rates This is not often used in mobile wallets and ○ Response rates to push notification p2p (person to person) payment systems and marketing campaigns This can improve speed and security Types of Mobile Analytics 5. Wearables are more sophisticated ○ Mobile advertising Wearables can be watches, earbuds, and ○ App monetization other smart devices ○ Performance analysis These wearables can fulfill a range of ○ In-app engagement functions from voice activation for phone ○ Mobile analytics for product teams calls, to helping the number of steps ○ Mobile analytics for marketing teams Not only can smart devices be used to do ○ Mobile analytics for UI/UX teams this trivial thing but they can also be helpful ○ Mobile analytics for technical teams in health monitor such as an AGUITEZ | ANARETA | ARCEDERA | BALITAAN | EVANGELISTA | MORELOS Page 28 CMSC 23 2ND SEM | 2023 - 2024 electrocardiogram and can also be used as smart locks in homes 6. Security More information is online so there is a fear of consumer security and privacy AGUITEZ | ANARETA | ARCEDERA | BALITAAN | EVANGELISTA | MORELOS Page 29

Use Quizgecko on...
Browser
Browser