From 340236f8c572c8ad34bcf49c6bf3476f6e37f28b Mon Sep 17 00:00:00 2001 From: Thibault Deckers Date: Thu, 23 Mar 2023 23:21:52 +0100 Subject: [PATCH] minor --- .gitignore | 3 - .metadata | 26 +++- android/.gitignore | 2 + .../thibault/aves/utils/FlutterUtils.kt | 7 +- android/build.gradle | 1 - .../gradle/wrapper/gradle-wrapper.properties | 1 - lib/widgets/counter_main.dart | 131 ++++++++++++++++++ 7 files changed, 162 insertions(+), 9 deletions(-) create mode 100644 lib/widgets/counter_main.dart diff --git a/.gitignore b/.gitignore index 60b39d58b..695e072ff 100644 --- a/.gitignore +++ b/.gitignore @@ -32,9 +32,6 @@ migrate_working_dir/ .pub/ /build/ -# Web related -lib/generated_plugin_registrant.dart - # Symbolication related app.*.symbols diff --git a/.metadata b/.metadata index fdef59c1a..0bc5b71a0 100644 --- a/.metadata +++ b/.metadata @@ -1,10 +1,30 @@ # This file tracks properties of this Flutter project. # Used by Flutter tool to assess capabilities and perform upgrades etc. # -# This file should be version controlled and should not be manually edited. +# This file should be version controlled. version: - revision: bc7bc940836f1f834699625426795fd6f07c18ec - channel: beta + revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 + channel: stable project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 + base_revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 + - platform: android + create_revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 + base_revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/android/.gitignore b/android/.gitignore index 0a741cb43..6f568019d 100644 --- a/android/.gitignore +++ b/android/.gitignore @@ -9,3 +9,5 @@ GeneratedPluginRegistrant.java # Remember to never publicly share your keystore. # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app key.properties +**/*.keystore +**/*.jks diff --git a/android/app/src/main/kotlin/deckers/thibault/aves/utils/FlutterUtils.kt b/android/app/src/main/kotlin/deckers/thibault/aves/utils/FlutterUtils.kt index dc1377cf0..5275e0ed3 100644 --- a/android/app/src/main/kotlin/deckers/thibault/aves/utils/FlutterUtils.kt +++ b/android/app/src/main/kotlin/deckers/thibault/aves/utils/FlutterUtils.kt @@ -17,7 +17,12 @@ import kotlin.coroutines.suspendCoroutine object FlutterUtils { private val LOG_TAG = LogUtils.createTag() - suspend fun initFlutterEngine(context: Context, sharedPreferencesKey: String, callbackHandleKey: String, engineSetter: (engine: FlutterEngine) -> Unit) { + suspend fun initFlutterEngine( + context: Context, + sharedPreferencesKey: String, + callbackHandleKey: String, + engineSetter: (engine: FlutterEngine) -> Unit, + ) { val callbackHandle = context.getSharedPreferences(sharedPreferencesKey, Context.MODE_PRIVATE).getLong(callbackHandleKey, 0) if (callbackHandle == 0L) { Log.e(LOG_TAG, "failed to retrieve registered callback handle for sharedPreferencesKey=$sharedPreferencesKey callbackHandleKey=$callbackHandleKey") diff --git a/android/build.gradle b/android/build.gradle index f15f63e03..6ed8027a9 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,4 +1,3 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext { kotlin_version = '1.7.20' diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index 3a528264c..3c472b99c 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -1,4 +1,3 @@ -#Thu Oct 22 10:54:33 KST 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/lib/widgets/counter_main.dart b/lib/widgets/counter_main.dart new file mode 100644 index 000000000..71e435fea --- /dev/null +++ b/lib/widgets/counter_main.dart @@ -0,0 +1,131 @@ +import 'package:flutter/material.dart'; + +void main() { + runApp(const MyApp()); +} + +class MyApp extends StatelessWidget { + const MyApp({super.key}); + + // This widget is the root of your application. + @override + Widget build(BuildContext context) { + return MaterialApp( + title: 'Flutter Demo', + theme: ThemeData( + // This is the theme of your application. + // + // Try running your application with "flutter run". You'll see the + // application has a blue toolbar. Then, without quitting the app, try + // changing the primarySwatch below to Colors.green and then invoke + // "hot reload" (press "r" in the console where you ran "flutter run", + // or simply save your changes to "hot reload" in a Flutter IDE). + // Notice that the counter didn't reset back to zero; the application + // is not restarted. + primarySwatch: Colors.blue, + ), + home: const MyHomePage(title: 'Flutter Demo Home Page'), + restorationScopeId: 'app', + ); + } +} + +class MyHomePage extends StatefulWidget { + const MyHomePage({super.key, required this.title}); + + // This widget is the home page of your application. It is stateful, meaning + // that it has a State object (defined below) that contains fields that affect + // how it looks. + + // This class is the configuration for the state. It holds the values (in this + // case the title) provided by the parent (in this case the App widget) and + // used by the build method of the State. Fields in a Widget subclass are + // always marked "final". + + final String title; + + @override + State createState() => _MyHomePageState(); +} + +class _MyHomePageState extends State with RestorationMixin { + @override + String? get restorationId => 'home_page'; + + @override + void restoreState(RestorationBucket? oldBucket, bool initialRestore) { + registerForRestoration(_restorableCounter, 'counter'); + debugPrint('TLAD $runtimeType restoreState _restorableCounter=${_restorableCounter.value}'); + } + + final RestorableInt _restorableCounter = RestorableInt(0); + + @override + void dispose() { + _restorableCounter.dispose(); + super.dispose(); + } + + void _incrementCounter() { + setState(() { + // This call to setState tells the Flutter framework that something has + // changed in this State, which causes it to rerun the build method below + // so that the display can reflect the updated values. If we changed + // _counter without calling setState(), then the build method would not be + // called again, and so nothing would appear to happen. + _restorableCounter.value++; + }); + } + + @override + Widget build(BuildContext context) { + // This method is rerun every time setState is called, for instance as done + // by the _incrementCounter method above. + // + // The Flutter framework has been optimized to make rerunning build methods + // fast, so that you can just rebuild anything that needs updating rather + // than having to individually change instances of widgets. + return Scaffold( + appBar: AppBar( + // Here we take the value from the MyHomePage object that was created by + // the App.build method, and use it to set our appbar title. + title: Text(widget.title), + ), + body: Center( + // Center is a layout widget. It takes a single child and positions it + // in the middle of the parent. + child: Column( + // Column is also a layout widget. It takes a list of children and + // arranges them vertically. By default, it sizes itself to fit its + // children horizontally, and tries to be as tall as its parent. + // + // Invoke "debug painting" (press "p" in the console, choose the + // "Toggle Debug Paint" action from the Flutter Inspector in Android + // Studio, or the "Toggle Debug Paint" command in Visual Studio Code) + // to see the wireframe for each widget. + // + // Column has various properties to control how it sizes itself and + // how it positions its children. Here we use mainAxisAlignment to + // center the children vertically; the main axis here is the vertical + // axis because Columns are vertical (the cross axis would be + // horizontal). + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text( + 'You have pushed the button this many times:', + ), + Text( + '${_restorableCounter.value}', + style: Theme.of(context).textTheme.headlineMedium, + ), + ], + ), + ), + floatingActionButton: FloatingActionButton( + onPressed: _incrementCounter, + tooltip: 'Increment', + child: const Icon(Icons.add), + ), // This trailing comma makes auto-formatting nicer for build methods. + ); + } +}