From 0f58cae0c9344e2184963135d4d2f1ce7b375d85 Mon Sep 17 00:00:00 2001 From: Baris Kaya Date: Wed, 29 Jun 2022 23:22:23 +0300 Subject: [PATCH 1/7] update to work with flutter 3.0 --- example/android/.gitignore | 6 + example/android/app/build.gradle | 26 +- .../android/app/src/debug/AndroidManifest.xml | 3 +- .../android/app/src/main/AndroidManifest.xml | 24 +- .../com/example/example/MainActivity.kt | 6 - .../res/drawable-v21/launch_background.xml | 12 + .../app/src/main/res/values-night/styles.xml | 18 ++ .../app/src/main/res/values/styles.xml | 14 +- .../app/src/profile/AndroidManifest.xml | 3 +- example/android/build.gradle | 8 +- example/android/gradle.properties | 1 - .../gradle/wrapper/gradle-wrapper.properties | 3 +- example/android/settings.gradle | 18 +- .../neumorphic_accessibility.dart | 107 ++++---- example/lib/lib/Code.dart | 8 +- example/lib/lib/ThemeColorSelector.dart | 9 +- example/lib/lib/ThemeConfigurator.dart | 11 +- example/lib/lib/back_button.dart | 2 - example/lib/lib/color_selector.dart | 7 +- example/lib/lib/top_bar.dart | 6 +- example/lib/main.dart | 26 +- example/lib/main_home.dart | 5 +- .../lib/playground/neumorphic_playground.dart | 247 ++++++++++-------- example/lib/playground/text_playground.dart | 93 ++++--- example/lib/sample_neumorphic_playground.dart | 44 ++-- example/lib/samples/audio_player_sample.dart | 9 +- example/lib/samples/calculator_sample.dart | 13 +- example/lib/samples/clock/clock_sample.dart | 16 +- .../samples/clock/clock_second_sample.dart | 11 +- example/lib/samples/credit_card_sample.dart | 10 +- example/lib/samples/form_sample.dart | 19 +- example/lib/samples/galaxy_sample.dart | 1 - example/lib/samples/sample_home.dart | 6 +- example/lib/samples/testla_sample.dart | 3 - example/lib/samples/widgets_sample.dart | 10 +- example/lib/tips/border/tips_border.dart | 9 +- .../border/tips_emboss_inside_emboss.dart | 9 +- example/lib/tips/tips_home.dart | 13 +- .../lib/widgets/appbar/widget_app_bar.dart | 6 +- .../widgets/background/widget_background.dart | 3 +- example/lib/widgets/button/button.dart | 13 +- example/lib/widgets/button/widget_button.dart | 3 +- .../lib/widgets/checkbox/widget_checkbox.dart | 3 +- .../widgets/container/widget_container.dart | 3 +- example/lib/widgets/icon/widget_icon.dart | 5 +- .../widget_indeterminate_progress.dart | 3 +- .../widgets/indicator/widget_indicator.dart | 9 +- .../lib/widgets/progress/widget_progress.dart | 9 +- .../radiobutton/widget_radio_button.dart | 25 +- .../range_slider/widget_range_slider.dart | 3 +- example/lib/widgets/slider/widget_slider.dart | 3 +- example/lib/widgets/switch/widget_switch.dart | 5 +- example/lib/widgets/toggle/widget_toggle.dart | 5 +- example/lib/widgets/widgets_home.dart | 10 +- .../Flutter/GeneratedPluginRegistrant.swift | 2 - example/pubspec.yaml | 4 +- 56 files changed, 509 insertions(+), 441 deletions(-) create mode 100644 example/android/app/src/main/res/drawable-v21/launch_background.xml create mode 100644 example/android/app/src/main/res/values-night/styles.xml diff --git a/example/android/.gitignore b/example/android/.gitignore index bc2100d8..6f568019 100644 --- a/example/android/.gitignore +++ b/example/android/.gitignore @@ -5,3 +5,9 @@ gradle-wrapper.jar /gradlew.bat /local.properties 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/example/android/app/build.gradle b/example/android/app/build.gradle index 0f6a5e54..0833ecfc 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -26,24 +26,31 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 28 + compileSdkVersion flutter.compileSdkVersion + ndkVersion flutter.ndkVersion - sourceSets { - main.java.srcDirs += 'src/main/kotlin' + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' } - lintOptions { - disable 'InvalidPackage' + sourceSets { + main.java.srcDirs += 'src/main/kotlin' } defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.example.example" - minSdkVersion 16 - targetSdkVersion 28 + // You can update the following values to match your application needs. + // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. + minSdkVersion flutter.minSdkVersion + targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() versionName flutterVersionName - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { @@ -61,7 +68,4 @@ flutter { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - testImplementation 'junit:junit:4.12' - androidTestImplementation 'androidx.test:runner:1.1.1' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' } diff --git a/example/android/app/src/debug/AndroidManifest.xml b/example/android/app/src/debug/AndroidManifest.xml index c208884f..45d523a2 100644 --- a/example/android/app/src/debug/AndroidManifest.xml +++ b/example/android/app/src/debug/AndroidManifest.xml @@ -1,6 +1,7 @@ - diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index ca1d66b5..3f41384d 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -1,25 +1,25 @@ - - - - - - + + diff --git a/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt b/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt index 1656503f..e793a000 100644 --- a/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt +++ b/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt @@ -1,12 +1,6 @@ package com.example.example -import androidx.annotation.NonNull; import io.flutter.embedding.android.FlutterActivity -import io.flutter.embedding.engine.FlutterEngine -import io.flutter.plugins.GeneratedPluginRegistrant class MainActivity: FlutterActivity() { - override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) { - GeneratedPluginRegistrant.registerWith(flutterEngine); - } } diff --git a/example/android/app/src/main/res/drawable-v21/launch_background.xml b/example/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 00000000..f74085f3 --- /dev/null +++ b/example/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/example/android/app/src/main/res/values-night/styles.xml b/example/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 00000000..06952be7 --- /dev/null +++ b/example/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/example/android/app/src/main/res/values/styles.xml b/example/android/app/src/main/res/values/styles.xml index 00fa4417..cb1ef880 100644 --- a/example/android/app/src/main/res/values/styles.xml +++ b/example/android/app/src/main/res/values/styles.xml @@ -1,8 +1,18 @@ - + + diff --git a/example/android/app/src/profile/AndroidManifest.xml b/example/android/app/src/profile/AndroidManifest.xml index c208884f..45d523a2 100644 --- a/example/android/app/src/profile/AndroidManifest.xml +++ b/example/android/app/src/profile/AndroidManifest.xml @@ -1,6 +1,7 @@ - diff --git a/example/android/build.gradle b/example/android/build.gradle index 3100ad2d..83ae2200 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -1,12 +1,12 @@ buildscript { - ext.kotlin_version = '1.3.50' + ext.kotlin_version = '1.6.10' repositories { google() - jcenter() + mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:3.5.0' + classpath 'com.android.tools.build:gradle:7.1.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -14,7 +14,7 @@ buildscript { allprojects { repositories { google() - jcenter() + mavenCentral() } } diff --git a/example/android/gradle.properties b/example/android/gradle.properties index 38c8d454..94adc3a3 100644 --- a/example/android/gradle.properties +++ b/example/android/gradle.properties @@ -1,4 +1,3 @@ org.gradle.jvmargs=-Xmx1536M -android.enableR8=true android.useAndroidX=true android.enableJetifier=true diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index 296b146b..cb24abda 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Fri Jun 23 08:50:38 CEST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip diff --git a/example/android/settings.gradle b/example/android/settings.gradle index 5a2f14fb..44e62bcf 100644 --- a/example/android/settings.gradle +++ b/example/android/settings.gradle @@ -1,15 +1,11 @@ include ':app' -def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() +def localPropertiesFile = new File(rootProject.projectDir, "local.properties") +def properties = new Properties() -def plugins = new Properties() -def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') -if (pluginsFile.exists()) { - pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } -} +assert localPropertiesFile.exists() +localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } -plugins.each { name, path -> - def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() - include ":$name" - project(":$name").projectDir = pluginDirectory -} +def flutterSdkPath = properties.getProperty("flutter.sdk") +assert flutterSdkPath != null, "flutter.sdk not set in local.properties" +apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" diff --git a/example/lib/accessibility/neumorphic_accessibility.dart b/example/lib/accessibility/neumorphic_accessibility.dart index 15f6223a..346e19f6 100644 --- a/example/lib/accessibility/neumorphic_accessibility.dart +++ b/example/lib/accessibility/neumorphic_accessibility.dart @@ -1,5 +1,4 @@ import 'package:example/lib/color_selector.dart'; -import 'package:flutter/material.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; class NeumorphicAccessibility extends StatefulWidget { @@ -40,8 +39,8 @@ class __PageState extends State<_Page> { double height = 150.0; double width = 150.0; - Color borderColor; - double borderWidth; + late Color borderColor; + late double borderWidth; static final minWidth = 50.0; static final maxWidth = 200.0; @@ -68,10 +67,12 @@ class __PageState extends State<_Page> { Padding( padding: const EdgeInsets.only(left: 8.0, right: 8.0, top: 8.0), - child: RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12)), - color: Theme.of(context).accentColor, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12)), + backgroundColor: Theme.of(context).colorScheme.secondary, + ), child: Text( "back", style: TextStyle(color: Colors.white), @@ -104,7 +105,7 @@ class __PageState extends State<_Page> { int selectedConfiguratorIndex = 0; Widget _configurators() { - final Color buttonActiveColor = Theme.of(context).accentColor; + final Color buttonActiveColor = Theme.of(context).colorScheme.secondary; final Color buttonInnactiveColor = Colors.white; final Color textActiveColor = Colors.white; @@ -124,12 +125,13 @@ class __PageState extends State<_Page> { flex: 1, child: Padding( padding: const EdgeInsets.all(8.0), - child: RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12)), - color: selectedConfiguratorIndex == 0 - ? buttonActiveColor - : buttonInnactiveColor, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12)), + backgroundColor: selectedConfiguratorIndex == 0 + ? buttonActiveColor + : buttonInnactiveColor), child: Text( "Style", style: TextStyle( @@ -150,9 +152,13 @@ class __PageState extends State<_Page> { flex: 1, child: Padding( padding: const EdgeInsets.all(8.0), - child: RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12)), + child: ElevatedButton( + style: ElevatedButton.styleFrom( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12)), + backgroundColor: selectedConfiguratorIndex == 1 + ? buttonActiveColor + : buttonInnactiveColor), child: Text( "Element", style: TextStyle( @@ -161,9 +167,6 @@ class __PageState extends State<_Page> { : textInactiveColor, ), ), - color: selectedConfiguratorIndex == 1 - ? buttonActiveColor - : buttonInnactiveColor, onPressed: () { setState(() { selectedConfiguratorIndex = 1; @@ -176,9 +179,14 @@ class __PageState extends State<_Page> { flex: 1, child: Padding( padding: const EdgeInsets.all(8.0), - child: RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12)), + child: ElevatedButton( + style: ElevatedButton.styleFrom( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12)), + backgroundColor: selectedConfiguratorIndex == 2 + ? buttonActiveColor + : buttonInnactiveColor, + ), child: Text( "Border", style: TextStyle( @@ -187,9 +195,6 @@ class __PageState extends State<_Page> { : textInactiveColor, ), ), - color: selectedConfiguratorIndex == 2 - ? buttonActiveColor - : buttonInnactiveColor, onPressed: () { setState(() { selectedConfiguratorIndex = 2; @@ -200,13 +205,13 @@ class __PageState extends State<_Page> { ), ], ), - _configuratorsChild(), + _configuratorsChild()!, ], ), ); } - Widget _configuratorsChild() { + Widget? _configuratorsChild() { switch (selectedConfiguratorIndex) { case 0: return styleCustomizer(); @@ -267,7 +272,7 @@ class __PageState extends State<_Page> { ColorSelector( onColorChanged: (color) { setState(() { - NeumorphicTheme.of(context) + NeumorphicTheme.of(context)! .updateCurrentTheme(NeumorphicThemeData(baseColor: color)); }); }, @@ -513,7 +518,7 @@ class __PageState extends State<_Page> { } Widget shapeWidget() { - final Color buttonActiveColor = Theme.of(context).accentColor; + final Color buttonActiveColor = Theme.of(context).colorScheme.secondary; final Color buttonInnactiveColor = Colors.white; final Color iconActiveColor = Colors.white; @@ -525,17 +530,19 @@ class __PageState extends State<_Page> { Expanded( child: Padding( padding: const EdgeInsets.all(8.0), - child: RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12)), + child: ElevatedButton( + style: ElevatedButton.styleFrom( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12)), + backgroundColor: shape == NeumorphicShape.concave + ? buttonActiveColor + : buttonInnactiveColor, + ), onPressed: () { setState(() { shape = NeumorphicShape.concave; }); }, - color: shape == NeumorphicShape.concave - ? buttonActiveColor - : buttonInnactiveColor, child: Image.asset("assets/images/concave.png", color: shape == NeumorphicShape.concave ? iconActiveColor @@ -546,17 +553,19 @@ class __PageState extends State<_Page> { Expanded( child: Padding( padding: const EdgeInsets.all(8.0), - child: RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12)), + child: ElevatedButton( + style: ElevatedButton.styleFrom( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12)), + backgroundColor: shape == NeumorphicShape.convex + ? buttonActiveColor + : buttonInnactiveColor, + ), onPressed: () { setState(() { shape = NeumorphicShape.convex; }); }, - color: shape == NeumorphicShape.convex - ? buttonActiveColor - : buttonInnactiveColor, child: Image.asset("assets/images/convex.png", color: shape == NeumorphicShape.convex ? iconActiveColor @@ -567,17 +576,19 @@ class __PageState extends State<_Page> { Expanded( child: Padding( padding: const EdgeInsets.all(8.0), - child: RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12)), + child: ElevatedButton( + style: ElevatedButton.styleFrom( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12)), + backgroundColor: shape == NeumorphicShape.flat + ? buttonActiveColor + : buttonInnactiveColor, + ), onPressed: () { setState(() { shape = NeumorphicShape.flat; }); }, - color: shape == NeumorphicShape.flat - ? buttonActiveColor - : buttonInnactiveColor, child: Image.asset("assets/images/flat.png", color: shape == NeumorphicShape.flat ? iconActiveColor diff --git a/example/lib/lib/Code.dart b/example/lib/lib/Code.dart index 7e02ee7e..8ccb1ebf 100644 --- a/example/lib/lib/Code.dart +++ b/example/lib/lib/Code.dart @@ -22,7 +22,7 @@ class Code extends StatelessWidget { class MyIntWidget extends StatefulWidget { final int value; - MyIntWidget({this.value}); + MyIntWidget({required this.value}); @override _MyIntWidgetState createState() => _MyIntWidgetState(); @@ -30,9 +30,9 @@ class MyIntWidget extends StatefulWidget { class _MyIntWidgetState extends State with TickerProviderStateMixin { - int _value; - AnimationController _controller; - Animation _valueAnimation; + late int _value; + late AnimationController _controller; + late Animation _valueAnimation; @override void initState() { diff --git a/example/lib/lib/ThemeColorSelector.dart b/example/lib/lib/ThemeColorSelector.dart index b9f3fcf4..884b6fcc 100644 --- a/example/lib/lib/ThemeColorSelector.dart +++ b/example/lib/lib/ThemeColorSelector.dart @@ -1,4 +1,3 @@ -import 'package:flutter/material.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; import 'color_selector.dart'; @@ -6,7 +5,7 @@ import 'color_selector.dart'; class ThemeColorSelector extends StatefulWidget { final BuildContext customContext; - ThemeColorSelector({this.customContext}); + ThemeColorSelector({required this.customContext}); @override _ThemeColorSelectorState createState() => _ThemeColorSelectorState(); @@ -19,11 +18,11 @@ class _ThemeColorSelectorState extends State { padding: EdgeInsets.all(4), color: Colors.black, child: ColorSelector( - color: NeumorphicTheme.baseColor(widget.customContext ?? context), + color: NeumorphicTheme.baseColor(widget.customContext), onColorChanged: (color) { setState(() { - NeumorphicTheme.update(widget.customContext ?? context, - (current) => current.copyWith(baseColor: color)); + NeumorphicTheme.update(widget.customContext, + (current) => current!.copyWith(baseColor: color)); }); }, ), diff --git a/example/lib/lib/ThemeConfigurator.dart b/example/lib/lib/ThemeConfigurator.dart index d6f6000e..60fea2dd 100644 --- a/example/lib/lib/ThemeConfigurator.dart +++ b/example/lib/lib/ThemeConfigurator.dart @@ -1,4 +1,3 @@ -import 'package:flutter/material.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; import 'ThemeColorSelector.dart'; @@ -50,7 +49,7 @@ class ThemeConfigurator extends StatelessWidget { class _ThemeConfiguratorDialog extends StatefulWidget { final BuildContext contextContainingTheme; - _ThemeConfiguratorDialog({this.contextContainingTheme}); + _ThemeConfiguratorDialog({required this.contextContainingTheme}); @override _ThemeConfiguratorState createState() => _ThemeConfiguratorState(); @@ -82,12 +81,12 @@ class _ThemeConfiguratorState extends State<_ThemeConfiguratorDialog> { child: Slider( min: Neumorphic.MIN_INTENSITY, //in case of != 0 max: Neumorphic.MAX_INTENSITY, - value: intensity, + value: intensity!, onChanged: (value) { setState(() { NeumorphicTheme.update( widget.contextContainingTheme, - (current) => current.copyWith( + (current) => current!.copyWith( intensity: value, ), ); @@ -119,12 +118,12 @@ class _ThemeConfiguratorState extends State<_ThemeConfiguratorDialog> { child: Slider( min: Neumorphic.MIN_DEPTH, max: Neumorphic.MAX_DEPTH, - value: depth, + value: depth!, onChanged: (value) { setState(() { NeumorphicTheme.update( widget.contextContainingTheme, - (current) => current.copyWith(depth: value), + (current) => current!.copyWith(depth: value), ); }); }, diff --git a/example/lib/lib/back_button.dart b/example/lib/lib/back_button.dart index 6f0b876a..79453357 100644 --- a/example/lib/lib/back_button.dart +++ b/example/lib/lib/back_button.dart @@ -1,5 +1,3 @@ -import 'package:flutter/material.dart'; -import 'package:flutter/widgets.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; class NeumorphicBack extends StatelessWidget { diff --git a/example/lib/lib/color_selector.dart b/example/lib/lib/color_selector.dart index 44133300..6438d6c6 100644 --- a/example/lib/lib/color_selector.dart +++ b/example/lib/lib/color_selector.dart @@ -12,7 +12,10 @@ class ColorSelector extends StatelessWidget { final double width; const ColorSelector( - {this.height = 40, this.width = 40, this.color, this.onColorChanged}); + {this.height = 40, + this.width = 40, + required this.color, + required this.onColorChanged}); @override Widget build(BuildContext context) { @@ -49,7 +52,7 @@ class ColorSelector extends StatelessWidget { ), ), actions: [ - FlatButton( + TextButton( child: const Text('Close'), onPressed: () { Navigator.of(context).pop(); diff --git a/example/lib/lib/top_bar.dart b/example/lib/lib/top_bar.dart index a96d23c2..cfeebe12 100644 --- a/example/lib/lib/top_bar.dart +++ b/example/lib/lib/top_bar.dart @@ -1,5 +1,3 @@ -import 'package:flutter/material.dart'; -import 'package:flutter/widgets.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; import 'back_button.dart'; @@ -10,7 +8,7 @@ class TopBar extends StatelessWidget implements PreferredSizeWidget { static const double kToolbarHeight = 110.0; - const TopBar({this.title = "", this.actions}); + const TopBar({this.title = "", required this.actions}); @override Widget build(BuildContext context) { @@ -36,7 +34,7 @@ class TopBar extends StatelessWidget implements PreferredSizeWidget { alignment: Alignment.centerRight, child: Row( mainAxisSize: MainAxisSize.min, - children: actions ?? [], + children: actions, )), ], ), diff --git a/example/lib/main.dart b/example/lib/main.dart index 0ae45ac6..bcd8e943 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,14 +1,15 @@ import 'package:flutter_neumorphic/flutter_neumorphic.dart'; - import 'main_home.dart'; -void main() => runApp(MyApp()); +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 NeumorphicApp( + return const NeumorphicApp( debugShowCheckedModeBanner: false, title: 'Flutter Demo', themeMode: ThemeMode.light, @@ -28,12 +29,13 @@ class MyApp extends StatelessWidget { } class MyHomePage extends StatelessWidget { - MyHomePage({Key key}) : super(key: key); + const MyHomePage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Scaffold( floatingActionButton: NeumorphicFloatingActionButton( - child: Icon(Icons.add, size: 30), + child: const Icon(Icons.add, size: 30), onPressed: () {}, ), backgroundColor: NeumorphicTheme.baseColor(context), @@ -45,7 +47,7 @@ class MyHomePage extends StatelessWidget { onPressed: () { print("onClick"); }, - style: NeumorphicStyle( + style: const NeumorphicStyle( shape: NeumorphicShape.flat, boxShape: NeumorphicBoxShape.circle(), ), @@ -56,9 +58,9 @@ class MyHomePage extends StatelessWidget { ), ), NeumorphicButton( - margin: EdgeInsets.only(top: 12), + margin: const EdgeInsets.only(top: 12), onPressed: () { - NeumorphicTheme.of(context).themeMode = + NeumorphicTheme.of(context)!.themeMode = NeumorphicTheme.isUsingDark(context) ? ThemeMode.light : ThemeMode.dark; @@ -74,7 +76,7 @@ class MyHomePage extends StatelessWidget { style: TextStyle(color: _textColor(context)), )), NeumorphicButton( - margin: EdgeInsets.only(top: 12), + margin: const EdgeInsets.only(top: 12), onPressed: () { Navigator.of(context) .pushReplacement(MaterialPageRoute(builder: (context) { @@ -98,10 +100,10 @@ class MyHomePage extends StatelessWidget { ); } - Color _iconsColor(BuildContext context) { + Color? _iconsColor(BuildContext context) { final theme = NeumorphicTheme.of(context); - if (theme.isUsingDark) { - return theme.current.accentColor; + if (theme!.isUsingDark) { + return theme.current!.accentColor; } else { return null; } diff --git a/example/lib/main_home.dart b/example/lib/main_home.dart index b6d42dfb..9e20b816 100644 --- a/example/lib/main_home.dart +++ b/example/lib/main_home.dart @@ -1,6 +1,5 @@ import 'package:example/tips/tips_home.dart'; import 'package:example/widgets/widgets_home.dart'; -import 'package:flutter/material.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; import 'accessibility/neumorphic_accessibility.dart'; @@ -24,7 +23,7 @@ class MyApp extends StatelessWidget { } class FullSampleHomePage extends StatelessWidget { - Widget _buildButton({String text, VoidCallback onClick}) { + Widget _buildButton({String? text, VoidCallback? onClick}) { return NeumorphicButton( margin: EdgeInsets.only(bottom: 12), padding: EdgeInsets.symmetric( @@ -41,7 +40,7 @@ class FullSampleHomePage extends StatelessWidget { //), shape: NeumorphicShape.flat, ), - child: Center(child: Text(text)), + child: Center(child: Text(text!)), onPressed: onClick, ); } diff --git a/example/lib/playground/neumorphic_playground.dart b/example/lib/playground/neumorphic_playground.dart index eb52041c..a2501262 100644 --- a/example/lib/playground/neumorphic_playground.dart +++ b/example/lib/playground/neumorphic_playground.dart @@ -2,6 +2,8 @@ import 'package:example/lib/color_selector.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; class NeumorphicPlayground extends StatefulWidget { + const NeumorphicPlayground({super.key}); + @override _NeumorphicPlaygroundState createState() => _NeumorphicPlaygroundState(); } @@ -11,7 +13,7 @@ class _NeumorphicPlaygroundState extends State { Widget build(BuildContext context) { return NeumorphicTheme( themeMode: ThemeMode.light, - theme: NeumorphicThemeData( + theme: const NeumorphicThemeData( baseColor: Color(0xffDDDDDD), lightSource: LightSource.topLeft, depth: 6, @@ -30,7 +32,7 @@ class _Page extends StatefulWidget { class __PageState extends State<_Page> { LightSource lightSource = LightSource.topLeft; NeumorphicShape shape = NeumorphicShape.flat; - NeumorphicBoxShape boxShape; + late NeumorphicBoxShape boxShape; double depth = 5; double intensity = 0.5; double surfaceIntensity = 0.5; @@ -38,10 +40,10 @@ class __PageState extends State<_Page> { double height = 150.0; double width = 150.0; - static final minWidth = 50.0; - static final maxWidth = 200.0; - static final minHeight = 50.0; - static final maxHeight = 200.0; + static const minWidth = 50.0; + static const maxWidth = 200.0; + static const minHeight = 50.0; + static const maxHeight = 200.0; bool haveNeumorphicChild = false; bool childOppositeLightsourceChild = false; @@ -68,11 +70,12 @@ class __PageState extends State<_Page> { children: [ Padding( padding: const EdgeInsets.only(left: 8.0, right: 8.0, top: 8.0), - child: RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12)), - color: Theme.of(context).accentColor, - child: Text( + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Theme.of(context).accentColor, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12))), + child: const Text( "back", style: TextStyle(color: Colors.white), ), @@ -103,13 +106,13 @@ class __PageState extends State<_Page> { Widget _configurators() { final Color buttonActiveColor = Theme.of(context).accentColor; - final Color buttonInnactiveColor = Colors.white; + const Color buttonInnactiveColor = Colors.white; - final Color textActiveColor = Colors.white; + const Color textActiveColor = Colors.white; final Color textInactiveColor = Colors.black.withOpacity(0.3); return Card( - margin: EdgeInsets.all(8), + margin: const EdgeInsets.all(8), elevation: 12, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), color: Colors.grey[300], @@ -122,12 +125,13 @@ class __PageState extends State<_Page> { flex: 1, child: Padding( padding: const EdgeInsets.all(8.0), - child: RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12)), - color: selectedConfiguratorIndex == 0 - ? buttonActiveColor - : buttonInnactiveColor, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: selectedConfiguratorIndex == 0 + ? buttonActiveColor + : buttonInnactiveColor, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12))), child: Text( "Style", style: TextStyle( @@ -148,9 +152,13 @@ class __PageState extends State<_Page> { flex: 1, child: Padding( padding: const EdgeInsets.all(8.0), - child: RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12)), + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: selectedConfiguratorIndex == 1 + ? buttonActiveColor + : buttonInnactiveColor, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12))), child: Text( "Element", style: TextStyle( @@ -159,9 +167,6 @@ class __PageState extends State<_Page> { : textInactiveColor, ), ), - color: selectedConfiguratorIndex == 1 - ? buttonActiveColor - : buttonInnactiveColor, onPressed: () { setState(() { selectedConfiguratorIndex = 1; @@ -174,9 +179,13 @@ class __PageState extends State<_Page> { flex: 1, child: Padding( padding: const EdgeInsets.all(8.0), - child: RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12)), + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: selectedConfiguratorIndex == 2 + ? buttonActiveColor + : buttonInnactiveColor, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12))), child: Text( "Child", style: TextStyle( @@ -185,9 +194,6 @@ class __PageState extends State<_Page> { : textInactiveColor, ), ), - color: selectedConfiguratorIndex == 2 - ? buttonActiveColor - : buttonInnactiveColor, onPressed: () { setState(() { selectedConfiguratorIndex = 2; @@ -198,13 +204,13 @@ class __PageState extends State<_Page> { ) ], ), - _configuratorsChild(), + _configuratorsChild()!, ], ), ); } - Widget _configuratorsChild() { + Widget? _configuratorsChild() { switch (selectedConfiguratorIndex) { case 0: return styleCustomizer(); @@ -259,17 +265,17 @@ class __PageState extends State<_Page> { Widget colorPicker() { return Row( children: [ - SizedBox( + const SizedBox( width: 12, ), - Text("Color "), - SizedBox( + const Text("Color "), + const SizedBox( width: 4, ), ColorSelector( onColorChanged: (color) { setState(() { - NeumorphicTheme.of(context) + NeumorphicTheme.of(context)! .updateCurrentTheme(NeumorphicThemeData(baseColor: color)); }); }, @@ -282,7 +288,7 @@ class __PageState extends State<_Page> { Widget neumorphic() { return NeumorphicButton( padding: EdgeInsets.zero, - duration: Duration(milliseconds: 300), + duration: const Duration(milliseconds: 300), onPressed: () { setState(() {}); }, @@ -309,7 +315,7 @@ class __PageState extends State<_Page> { ? neumorphicChild() : Container( //color: Colors.blue, - child: Center(child: Text("")), + child: const Center(child: Text("")), ), ), ); @@ -318,7 +324,7 @@ class __PageState extends State<_Page> { Widget neumorphicChild() { return Neumorphic( padding: EdgeInsets.zero, - duration: Duration(milliseconds: 300), + duration: const Duration(milliseconds: 300), margin: EdgeInsets.all(this.childMargin), drawSurfaceAboveChild: true, style: NeumorphicStyle( @@ -329,14 +335,14 @@ class __PageState extends State<_Page> { depth: childDepth, lightSource: this.lightSource, oppositeShadowLightSource: this.childOppositeLightsourceChild), - child: SizedBox.expand(), + child: const SizedBox.expand(), ); } Widget depthSelector() { return Row( children: [ - Padding( + const Padding( padding: EdgeInsets.only(left: 12), child: Text("Depth"), ), @@ -353,7 +359,7 @@ class __PageState extends State<_Page> { ), ), Padding( - padding: EdgeInsets.only(right: 12), + padding: const EdgeInsets.only(right: 12), child: Text(depth.floor().toString()), ), ], @@ -363,7 +369,7 @@ class __PageState extends State<_Page> { Widget childDepthSelector() { return Row( children: [ - Padding( + const Padding( padding: EdgeInsets.only(left: 12), child: Text("Child Depth"), ), @@ -380,7 +386,7 @@ class __PageState extends State<_Page> { ), ), Padding( - padding: EdgeInsets.only(right: 12), + padding: const EdgeInsets.only(right: 12), child: Text(childDepth.floor().toString()), ), ], @@ -390,7 +396,7 @@ class __PageState extends State<_Page> { Widget childMarginSelector() { return Row( children: [ - Padding( + const Padding( padding: EdgeInsets.only(left: 12), child: Text("Child Margin"), ), @@ -407,7 +413,7 @@ class __PageState extends State<_Page> { ), ), Padding( - padding: EdgeInsets.only(right: 12), + padding: const EdgeInsets.only(right: 12), child: Text(childMargin.floor().toString()), ), ], @@ -418,7 +424,7 @@ class __PageState extends State<_Page> { return Stack( alignment: Alignment.center, children: [ - Align( + const Align( alignment: Alignment.centerLeft, child: Padding( padding: EdgeInsets.only(left: 12), @@ -431,7 +437,7 @@ class __PageState extends State<_Page> { value: this.haveNeumorphicChild, onChanged: (value) { setState(() { - haveNeumorphicChild = value; + haveNeumorphicChild = value!; }); }, ), @@ -444,7 +450,7 @@ class __PageState extends State<_Page> { return Stack( alignment: Alignment.center, children: [ - Align( + const Align( alignment: Alignment.centerLeft, child: Padding( padding: EdgeInsets.only(left: 12), @@ -457,7 +463,7 @@ class __PageState extends State<_Page> { value: this.drawAboveChild, onChanged: (value) { setState(() { - drawAboveChild = value; + drawAboveChild = value!; }); }, ), @@ -470,7 +476,7 @@ class __PageState extends State<_Page> { return Stack( alignment: Alignment.center, children: [ - Align( + const Align( alignment: Alignment.centerLeft, child: Padding( padding: EdgeInsets.only(left: 12), @@ -483,7 +489,7 @@ class __PageState extends State<_Page> { value: this.childOppositeLightsourceChild, onChanged: (value) { setState(() { - childOppositeLightsourceChild = value; + childOppositeLightsourceChild = value!; }); }, ), @@ -495,10 +501,10 @@ class __PageState extends State<_Page> { Widget sizeSelector() { return Row( children: [ - SizedBox( + const SizedBox( width: 12, ), - Text("W: "), + const Text("W: "), Expanded( child: Slider( min: minWidth, @@ -511,7 +517,7 @@ class __PageState extends State<_Page> { }, ), ), - Text("H: "), + const Text("H: "), Expanded( child: Slider( min: minHeight, @@ -532,7 +538,7 @@ class __PageState extends State<_Page> { if (boxShape.isRoundRect || boxShape.isBeveled) { return Row( children: [ - Padding( + const Padding( padding: EdgeInsets.only(left: 12), child: Text("Corner"), ), @@ -557,20 +563,20 @@ class __PageState extends State<_Page> { ), ), Padding( - padding: EdgeInsets.only(right: 12), + padding: const EdgeInsets.only(right: 12), child: Text(cornerRadius.floor().toString()), ), ], ); } else { - return SizedBox(); + return const SizedBox(); } } Widget intensitySelector() { return Row( children: [ - Padding( + const Padding( padding: EdgeInsets.only(left: 12), child: Text("Intensity"), ), @@ -587,7 +593,7 @@ class __PageState extends State<_Page> { ), ), Padding( - padding: EdgeInsets.only(right: 12), + padding: const EdgeInsets.only(right: 12), child: Text(((intensity * 100).floor() / 100).toString()), ), ], @@ -597,7 +603,7 @@ class __PageState extends State<_Page> { Widget surfaceIntensitySelector() { return Row( children: [ - Padding( + const Padding( padding: EdgeInsets.only(left: 12), child: Text("SurfaceIntensity"), ), @@ -614,7 +620,7 @@ class __PageState extends State<_Page> { ), ), Padding( - padding: EdgeInsets.only(right: 12), + padding: const EdgeInsets.only(right: 12), child: Text(((surfaceIntensity * 100).floor() / 100).toString()), ), ], @@ -623,9 +629,9 @@ class __PageState extends State<_Page> { Widget boxshapeWidget() { final Color buttonActiveColor = Theme.of(context).accentColor; - final Color buttonInnactiveColor = Colors.white; + const Color buttonInnactiveColor = Colors.white; - final Color textActiveColor = Colors.white; + const Color textActiveColor = Colors.white; final Color textInactiveColor = Colors.black.withOpacity(0.3); return Row( @@ -634,18 +640,19 @@ class __PageState extends State<_Page> { Expanded( child: Padding( padding: const EdgeInsets.all(8.0), - child: RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12)), + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: boxShape.isRoundRect + ? buttonActiveColor + : buttonInnactiveColor, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12))), onPressed: () { setState(() { boxShape = NeumorphicBoxShape.roundRect( BorderRadius.circular(this.cornerRadius)); }); }, - color: boxShape.isRoundRect - ? buttonActiveColor - : buttonInnactiveColor, child: Text( "Rect", style: TextStyle( @@ -659,17 +666,19 @@ class __PageState extends State<_Page> { Expanded( child: Padding( padding: const EdgeInsets.all(8.0), - child: RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12)), + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: boxShape.isBeveled + ? buttonActiveColor + : buttonInnactiveColor, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12))), onPressed: () { setState(() { boxShape = NeumorphicBoxShape.beveled( BorderRadius.circular(this.cornerRadius)); }); }, - color: - boxShape.isBeveled ? buttonActiveColor : buttonInnactiveColor, child: Text( "Beveled", style: TextStyle( @@ -683,16 +692,18 @@ class __PageState extends State<_Page> { Expanded( child: Padding( padding: const EdgeInsets.all(8.0), - child: RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12)), + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: boxShape.isCircle + ? buttonActiveColor + : buttonInnactiveColor, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12))), onPressed: () { setState(() { - boxShape = NeumorphicBoxShape.circle(); + boxShape = const NeumorphicBoxShape.circle(); }); }, - color: - boxShape.isCircle ? buttonActiveColor : buttonInnactiveColor, child: Text( "Circle", style: TextStyle( @@ -706,16 +717,18 @@ class __PageState extends State<_Page> { Expanded( child: Padding( padding: const EdgeInsets.all(8.0), - child: RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12)), + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: boxShape.isStadium + ? buttonActiveColor + : buttonInnactiveColor, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12))), onPressed: () { setState(() { - boxShape = NeumorphicBoxShape.stadium(); + boxShape = const NeumorphicBoxShape.stadium(); }); }, - color: - boxShape.isStadium ? buttonActiveColor : buttonInnactiveColor, child: Text( "Stadium", style: TextStyle( @@ -729,18 +742,19 @@ class __PageState extends State<_Page> { Expanded( child: Padding( padding: const EdgeInsets.all(8.0), - child: RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12)), + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: boxShape.isCustomPath + ? buttonActiveColor + : buttonInnactiveColor, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12))), onPressed: () { setState(() { boxShape = NeumorphicBoxShape.path( NeumorphicFlutterLogoPathProvider()); }); }, - color: boxShape.isCustomPath - ? buttonActiveColor - : buttonInnactiveColor, child: Text( "Custom", style: TextStyle( @@ -757,9 +771,9 @@ class __PageState extends State<_Page> { Widget shapeWidget() { final Color buttonActiveColor = Theme.of(context).accentColor; - final Color buttonInnactiveColor = Colors.white; + const Color buttonInnactiveColor = Colors.white; - final Color iconActiveColor = Colors.white; + const Color iconActiveColor = Colors.white; final Color iconInactiveColor = Colors.black.withOpacity(0.3); return Row( @@ -768,17 +782,18 @@ class __PageState extends State<_Page> { Expanded( child: Padding( padding: const EdgeInsets.all(8.0), - child: RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12)), + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: shape == NeumorphicShape.concave + ? buttonActiveColor + : buttonInnactiveColor, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12))), onPressed: () { setState(() { shape = NeumorphicShape.concave; }); }, - color: shape == NeumorphicShape.concave - ? buttonActiveColor - : buttonInnactiveColor, child: Image.asset("assets/images/concave.png", color: shape == NeumorphicShape.concave ? iconActiveColor @@ -789,17 +804,18 @@ class __PageState extends State<_Page> { Expanded( child: Padding( padding: const EdgeInsets.all(8.0), - child: RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12)), + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: shape == NeumorphicShape.convex + ? buttonActiveColor + : buttonInnactiveColor, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12))), onPressed: () { setState(() { shape = NeumorphicShape.convex; }); }, - color: shape == NeumorphicShape.convex - ? buttonActiveColor - : buttonInnactiveColor, child: Image.asset("assets/images/convex.png", color: shape == NeumorphicShape.convex ? iconActiveColor @@ -810,17 +826,18 @@ class __PageState extends State<_Page> { Expanded( child: Padding( padding: const EdgeInsets.all(8.0), - child: RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12)), + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: shape == NeumorphicShape.flat + ? buttonActiveColor + : buttonInnactiveColor, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12))), onPressed: () { setState(() { shape = NeumorphicShape.flat; }); }, - color: shape == NeumorphicShape.flat - ? buttonActiveColor - : buttonInnactiveColor, child: Image.asset("assets/images/flat.png", color: shape == NeumorphicShape.flat ? iconActiveColor diff --git a/example/lib/playground/text_playground.dart b/example/lib/playground/text_playground.dart index f1a547cd..04cbb962 100644 --- a/example/lib/playground/text_playground.dart +++ b/example/lib/playground/text_playground.dart @@ -1,5 +1,4 @@ import 'package:example/lib/color_selector.dart'; -import 'package:flutter/material.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; class NeumorphicTextPlayground extends StatefulWidget { @@ -89,10 +88,12 @@ class __PageState extends State<_Page> { Padding( padding: const EdgeInsets.only(left: 8.0, right: 8.0, top: 8.0), - child: RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12)), - color: Theme.of(context).accentColor, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12)), + backgroundColor: Theme.of(context).colorScheme.secondary, + ), child: Text( "back", style: TextStyle(color: Colors.white), @@ -125,7 +126,7 @@ class __PageState extends State<_Page> { int selectedConfiguratorIndex = 0; Widget _configurators() { - final Color buttonActiveColor = Theme.of(context).accentColor; + final Color buttonActiveColor = Theme.of(context).colorScheme.secondary; final Color buttonInnactiveColor = Colors.white; final Color textActiveColor = Colors.white; @@ -145,12 +146,14 @@ class __PageState extends State<_Page> { flex: 1, child: Padding( padding: const EdgeInsets.all(8.0), - child: RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12)), - color: selectedConfiguratorIndex == 0 - ? buttonActiveColor - : buttonInnactiveColor, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12)), + backgroundColor: selectedConfiguratorIndex == 0 + ? buttonActiveColor + : buttonInnactiveColor, + ), child: Text( "Style", style: TextStyle( @@ -171,9 +174,14 @@ class __PageState extends State<_Page> { flex: 1, child: Padding( padding: const EdgeInsets.all(8.0), - child: RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12)), + child: ElevatedButton( + style: ElevatedButton.styleFrom( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12)), + backgroundColor: selectedConfiguratorIndex == 1 + ? buttonActiveColor + : buttonInnactiveColor, + ), child: Text( "Element", style: TextStyle( @@ -182,9 +190,6 @@ class __PageState extends State<_Page> { : textInactiveColor, ), ), - color: selectedConfiguratorIndex == 1 - ? buttonActiveColor - : buttonInnactiveColor, onPressed: () { setState(() { selectedConfiguratorIndex = 1; @@ -195,13 +200,13 @@ class __PageState extends State<_Page> { ), ], ), - _configuratorsChild(), + _configuratorsChild()!, ], ), ); } - Widget _configuratorsChild() { + Widget? _configuratorsChild() { switch (selectedConfiguratorIndex) { case 0: return styleCustomizer(); @@ -238,7 +243,7 @@ class __PageState extends State<_Page> { } Widget shapeWidget() { - final Color buttonActiveColor = Theme.of(context).accentColor; + final Color buttonActiveColor = Theme.of(context).colorScheme.secondary; final Color buttonInnactiveColor = Colors.white; final Color iconActiveColor = Colors.white; @@ -250,17 +255,19 @@ class __PageState extends State<_Page> { Expanded( child: Padding( padding: const EdgeInsets.all(8.0), - child: RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12)), + child: ElevatedButton( + style: ElevatedButton.styleFrom( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12)), + backgroundColor: shape == NeumorphicShape.concave + ? buttonActiveColor + : buttonInnactiveColor, + ), onPressed: () { setState(() { shape = NeumorphicShape.concave; }); }, - color: shape == NeumorphicShape.concave - ? buttonActiveColor - : buttonInnactiveColor, child: Image.asset("assets/images/concave.png", color: shape == NeumorphicShape.concave ? iconActiveColor @@ -271,17 +278,19 @@ class __PageState extends State<_Page> { Expanded( child: Padding( padding: const EdgeInsets.all(8.0), - child: RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12)), + child: ElevatedButton( + style: ElevatedButton.styleFrom( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12)), + backgroundColor: shape == NeumorphicShape.convex + ? buttonActiveColor + : buttonInnactiveColor, + ), onPressed: () { setState(() { shape = NeumorphicShape.convex; }); }, - color: shape == NeumorphicShape.convex - ? buttonActiveColor - : buttonInnactiveColor, child: Image.asset("assets/images/convex.png", color: shape == NeumorphicShape.convex ? iconActiveColor @@ -292,17 +301,19 @@ class __PageState extends State<_Page> { Expanded( child: Padding( padding: const EdgeInsets.all(8.0), - child: RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12)), + child: ElevatedButton( + style: ElevatedButton.styleFrom( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12)), + backgroundColor: shape == NeumorphicShape.flat + ? buttonActiveColor + : buttonInnactiveColor, + ), onPressed: () { setState(() { shape = NeumorphicShape.flat; }); }, - color: shape == NeumorphicShape.flat - ? buttonActiveColor - : buttonInnactiveColor, child: Image.asset("assets/images/flat.png", color: shape == NeumorphicShape.flat ? iconActiveColor @@ -327,7 +338,7 @@ class __PageState extends State<_Page> { ColorSelector( onColorChanged: (color) { setState(() { - NeumorphicTheme.of(context) + NeumorphicTheme.of(context)! .updateCurrentTheme(NeumorphicThemeData(baseColor: color)); }); }, @@ -444,7 +455,7 @@ class __PageState extends State<_Page> { } FontWeight _fontWeight() { - switch ((this.fontWeight / 100).toInt()) { + switch (this.fontWeight ~/ 100) { case 1: return FontWeight.w100; case 2: diff --git a/example/lib/sample_neumorphic_playground.dart b/example/lib/sample_neumorphic_playground.dart index afb309e7..382bc266 100644 --- a/example/lib/sample_neumorphic_playground.dart +++ b/example/lib/sample_neumorphic_playground.dart @@ -1,5 +1,3 @@ -import 'package:example/lib/color_selector.dart'; -import 'package:flutter/cupertino.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; void main() => runApp(NeumorphicPlayground()); @@ -258,17 +256,19 @@ class __PageState extends State<_Page> { Expanded( child: Padding( padding: const EdgeInsets.all(8.0), - child: RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12)), + child: ElevatedButton( + style: ElevatedButton.styleFrom( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12)), + backgroundColor: shape == NeumorphicShape.concave + ? buttonActiveColor + : buttonInnactiveColor, + ), onPressed: () { setState(() { shape = NeumorphicShape.concave; }); }, - color: shape == NeumorphicShape.concave - ? buttonActiveColor - : buttonInnactiveColor, child: Image.asset("assets/images/concave.png", color: shape == NeumorphicShape.concave ? iconActiveColor @@ -279,17 +279,19 @@ class __PageState extends State<_Page> { Expanded( child: Padding( padding: const EdgeInsets.all(8.0), - child: RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12)), + child: ElevatedButton( + style: ElevatedButton.styleFrom( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12)), + backgroundColor: shape == NeumorphicShape.convex + ? buttonActiveColor + : buttonInnactiveColor, + ), onPressed: () { setState(() { shape = NeumorphicShape.convex; }); }, - color: shape == NeumorphicShape.convex - ? buttonActiveColor - : buttonInnactiveColor, child: Image.asset("assets/images/convex.png", color: shape == NeumorphicShape.convex ? iconActiveColor @@ -300,17 +302,19 @@ class __PageState extends State<_Page> { Expanded( child: Padding( padding: const EdgeInsets.all(8.0), - child: RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12)), + child: ElevatedButton( + style: ElevatedButton.styleFrom( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12)), + backgroundColor: shape == NeumorphicShape.flat + ? buttonActiveColor + : buttonInnactiveColor, + ), onPressed: () { setState(() { shape = NeumorphicShape.flat; }); }, - color: shape == NeumorphicShape.flat - ? buttonActiveColor - : buttonInnactiveColor, child: Image.asset("assets/images/flat.png", color: shape == NeumorphicShape.flat ? iconActiveColor diff --git a/example/lib/samples/audio_player_sample.dart b/example/lib/samples/audio_player_sample.dart index fee9c066..43181790 100644 --- a/example/lib/samples/audio_player_sample.dart +++ b/example/lib/samples/audio_player_sample.dart @@ -1,4 +1,3 @@ -import 'package:flutter/material.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; class AudioPlayerSample extends StatefulWidget { @@ -94,7 +93,7 @@ class __PageState extends State<_Page> { onPressed: () { setState(() { _useDark = !_useDark; - NeumorphicTheme.of(context).themeMode = + NeumorphicTheme.of(context)!.themeMode = _useDark ? ThemeMode.dark : ThemeMode.light; }); }, @@ -235,10 +234,10 @@ class __PageState extends State<_Page> { ); } - Color _iconsColor() { + Color? _iconsColor() { final theme = NeumorphicTheme.of(context); - if (theme.isUsingDark) { - return theme.current.accentColor; + if (theme!.isUsingDark) { + return theme.current!.accentColor; } else { return null; } diff --git a/example/lib/samples/calculator_sample.dart b/example/lib/samples/calculator_sample.dart index fabf9d36..33415136 100644 --- a/example/lib/samples/calculator_sample.dart +++ b/example/lib/samples/calculator_sample.dart @@ -1,4 +1,3 @@ -import 'package:flutter/material.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; class CalculatorSample extends StatefulWidget { @@ -64,7 +63,7 @@ class WidgetCalcButton extends StatelessWidget { } } - Color _backgroundColor(BuildContext context) { + Color? _backgroundColor(BuildContext context) { return button.backgroundAccent ? NeumorphicTheme.accentColor(context) : null; @@ -99,7 +98,7 @@ class _TopScreenWidget extends StatelessWidget { return Neumorphic( style: NeumorphicStyle( boxShape: NeumorphicBoxShape.roundRect(BorderRadius.circular(12)), - depth: -1 * NeumorphicTheme.of(context).current.depth, + depth: -1 * NeumorphicTheme.of(context)!.current!.depth, ), child: FractionallySizedBox( widthFactor: 1, @@ -198,10 +197,10 @@ class __PageContentState extends State<_PageContent> { ), Row( children: [ - RaisedButton( + ElevatedButton( onPressed: () { setState(() { - NeumorphicTheme.of(context) + NeumorphicTheme.of(context)! .updateCurrentTheme(NeumorphicThemeData( depth: 1, intensity: 0.5, @@ -213,10 +212,10 @@ class __PageContentState extends State<_PageContent> { "style 1", ), ), - RaisedButton( + ElevatedButton( onPressed: () { setState(() { - NeumorphicTheme.of(context) + NeumorphicTheme.of(context)! .updateCurrentTheme(NeumorphicThemeData( depth: 8, intensity: 0.3, diff --git a/example/lib/samples/clock/clock_sample.dart b/example/lib/samples/clock/clock_sample.dart index 05bc41e9..f33e4322 100644 --- a/example/lib/samples/clock/clock_sample.dart +++ b/example/lib/samples/clock/clock_sample.dart @@ -40,7 +40,9 @@ class _ClockFirstPageState extends State<_ClockFirstPage> { children: [ Padding( padding: const EdgeInsets.only(left: 8.0, right: 8.0, top: 9.0), - child: TopBar(), + child: TopBar( + actions: [], + ), ), Padding( padding: EdgeInsets.symmetric(horizontal: 20.0), @@ -229,16 +231,16 @@ class NeumorphicClock extends StatelessWidget { } Widget _buildLine( - {BuildContext context, - double angle, - double width, + {BuildContext? context, + double? angle, + double? width, double height = 6, - Color color}) { + Color? color}) { return Transform.rotate( - angle: angle, + angle: angle!, child: Center( child: Padding( - padding: EdgeInsets.only(left: width), + padding: EdgeInsets.only(left: width!), child: Neumorphic( style: NeumorphicStyle( depth: 20, diff --git a/example/lib/samples/clock/clock_second_sample.dart b/example/lib/samples/clock/clock_second_sample.dart index 91873349..9180b4df 100644 --- a/example/lib/samples/clock/clock_second_sample.dart +++ b/example/lib/samples/clock/clock_second_sample.dart @@ -1,5 +1,4 @@ import 'package:example/lib/top_bar.dart'; -import 'package:flutter/material.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; class ClockAlarmPage extends StatelessWidget { @@ -61,7 +60,9 @@ class _ClockPageState extends State<_Page> { children: [ Padding( padding: const EdgeInsets.only(left: 8.0, right: 8.0, top: 9.0), - child: TopBar(), + child: TopBar( + actions: [], + ), ), Padding( padding: EdgeInsets.symmetric(horizontal: 20.0), @@ -230,8 +231,8 @@ class Alarm { final String label; const Alarm({ - @required this.enabled, - @required this.time, - @required this.label, + required this.enabled, + required this.time, + required this.label, }); } diff --git a/example/lib/samples/credit_card_sample.dart b/example/lib/samples/credit_card_sample.dart index de640f5b..a2955889 100644 --- a/example/lib/samples/credit_card_sample.dart +++ b/example/lib/samples/credit_card_sample.dart @@ -1,7 +1,5 @@ import 'dart:ui'; -import 'package:flutter/material.dart'; -import 'package:flutter/widgets.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; class CreditCardSample extends StatefulWidget { @@ -235,7 +233,7 @@ class __PageContentState extends State<_PageContent> { setState(() { _useDark = !_useDark; - NeumorphicTheme.of(context).themeMode = + NeumorphicTheme.of(context)!.themeMode = _useDark ? ThemeMode.dark : ThemeMode.light; }); }, @@ -328,7 +326,7 @@ class __PageContentState extends State<_PageContent> { value: 0, onChanged: (value) { setState(() { - _dotIndex = value; + _dotIndex = value!; }); }, style: NeumorphicRadioStyle( @@ -348,7 +346,7 @@ class __PageContentState extends State<_PageContent> { value: 1, onChanged: (value) { setState(() { - _dotIndex = value; + _dotIndex = value!; }); }, style: NeumorphicRadioStyle( @@ -368,7 +366,7 @@ class __PageContentState extends State<_PageContent> { value: 2, onChanged: (value) { setState(() { - _dotIndex = value; + _dotIndex = value!; }); }, style: NeumorphicRadioStyle( diff --git a/example/lib/samples/form_sample.dart b/example/lib/samples/form_sample.dart index 7d6af0cc..a834d4d8 100644 --- a/example/lib/samples/form_sample.dart +++ b/example/lib/samples/form_sample.dart @@ -35,7 +35,7 @@ class __PageState extends State<_Page> { String firstName = ""; String lastName = ""; double age = 12; - Gender gender; + late Gender gender; Set rides = Set(); @override @@ -181,7 +181,7 @@ class _AgeField extends StatelessWidget { final double age; final ValueChanged onChanged; - _AgeField({@required this.age, this.onChanged}); + _AgeField({required this.age, required this.onChanged}); @override Widget build(BuildContext context) { @@ -230,14 +230,15 @@ class _TextField extends StatefulWidget { final ValueChanged onChanged; - _TextField({@required this.label, @required this.hint, this.onChanged}); + _TextField( + {required this.label, required this.hint, required this.onChanged}); @override __TextFieldState createState() => __TextFieldState(); } class __TextFieldState extends State<_TextField> { - TextEditingController _controller; + late TextEditingController _controller; @override void initState() { @@ -283,8 +284,8 @@ class _GenderField extends StatelessWidget { final ValueChanged onChanged; const _GenderField({ - @required this.gender, - @required this.onChanged, + required this.gender, + required this.onChanged, }); @override @@ -313,7 +314,7 @@ class _GenderField extends StatelessWidget { ), value: Gender.MALE, child: Icon(Icons.account_box), - onChanged: (value) => this.onChanged(value), + onChanged: (value) => this.onChanged(value!), ), SizedBox(width: 12), NeumorphicRadio( @@ -324,7 +325,7 @@ class _GenderField extends StatelessWidget { ), value: Gender.FEMALE, child: Icon(Icons.pregnant_woman), - onChanged: (value) => this.onChanged(value), + onChanged: (value) => this.onChanged(value!), ), SizedBox(width: 12), NeumorphicRadio( @@ -335,7 +336,7 @@ class _GenderField extends StatelessWidget { ), value: Gender.NON_BINARY, child: Icon(Icons.supervised_user_circle), - onChanged: (value) => this.onChanged(value), + onChanged: (value) => this.onChanged(value!), ), SizedBox( width: 18, diff --git a/example/lib/samples/galaxy_sample.dart b/example/lib/samples/galaxy_sample.dart index 5bae0f8e..aca638ca 100644 --- a/example/lib/samples/galaxy_sample.dart +++ b/example/lib/samples/galaxy_sample.dart @@ -1,6 +1,5 @@ import 'package:example/lib/ThemeConfigurator.dart'; import 'package:example/lib/top_bar.dart'; -import 'package:flutter/material.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; class GalaxySample extends StatelessWidget { diff --git a/example/lib/samples/sample_home.dart b/example/lib/samples/sample_home.dart index e4e120a0..65a11b4e 100644 --- a/example/lib/samples/sample_home.dart +++ b/example/lib/samples/sample_home.dart @@ -12,7 +12,7 @@ import 'galaxy_sample.dart'; import 'widgets_sample.dart'; class SamplesHome extends StatelessWidget { - Widget _buildButton({String text, VoidCallback onClick}) { + Widget _buildButton({required String text, VoidCallback? onClick}) { return NeumorphicButton( margin: EdgeInsets.only(bottom: 12), padding: EdgeInsets.symmetric( @@ -46,7 +46,9 @@ class SamplesHome extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.max, children: [ - TopBar(), + TopBar( + actions: [], + ), _buildButton( text: "Tesla", onClick: () { diff --git a/example/lib/samples/testla_sample.dart b/example/lib/samples/testla_sample.dart index 400ecf07..27d89940 100644 --- a/example/lib/samples/testla_sample.dart +++ b/example/lib/samples/testla_sample.dart @@ -1,7 +1,4 @@ -import 'dart:ui'; -import 'package:flutter/material.dart'; -import 'package:flutter/widgets.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; class TeslaSample extends StatefulWidget { diff --git a/example/lib/samples/widgets_sample.dart b/example/lib/samples/widgets_sample.dart index a98f67fc..6ec2b3d6 100644 --- a/example/lib/samples/widgets_sample.dart +++ b/example/lib/samples/widgets_sample.dart @@ -2,14 +2,14 @@ import 'package:flutter/material.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; class WidgetsSample extends StatefulWidget { - WidgetsSample({Key key}) : super(key: key); + WidgetsSample({Key? key}) : super(key: key); @override createState() => _ContainersListPageState(); } class _ContainersListPageState extends State { - int _groupValue; + late int _groupValue; bool _switchConcaveEnabled = false; bool _switchConvexEnabled = false; bool _switchFlatEnabled = false; @@ -125,7 +125,7 @@ class _ContainersListPageState extends State { groupValue: _groupValue, onChanged: (value) { setState(() { - _groupValue = value; + _groupValue = value!; }); }, ), @@ -145,7 +145,7 @@ class _ContainersListPageState extends State { groupValue: _groupValue, onChanged: (value) { setState(() { - _groupValue = value; + _groupValue = value!; }); }, ), @@ -165,7 +165,7 @@ class _ContainersListPageState extends State { groupValue: _groupValue, onChanged: (value) { setState(() { - _groupValue = value; + _groupValue = value!; }); }, ), diff --git a/example/lib/tips/border/tips_border.dart b/example/lib/tips/border/tips_border.dart index 69e04ea3..0e88e8ff 100644 --- a/example/lib/tips/border/tips_border.dart +++ b/example/lib/tips/border/tips_border.dart @@ -1,11 +1,10 @@ import 'package:example/lib/Code.dart'; import 'package:example/lib/ThemeConfigurator.dart'; import 'package:example/lib/top_bar.dart'; -import 'package:flutter/material.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; class TipsBorderPage extends StatefulWidget { - TipsBorderPage({Key key}) : super(key: key); + TipsBorderPage({Key? key}) : super(key: key); @override createState() => _WidgetPageState(); @@ -149,9 +148,9 @@ class _CustomWidget extends StatefulWidget { final NeumorphicStyle secondStyle; _CustomWidget( - {@required this.title, - @required this.firstStyle, - @required this.secondStyle}); + {required this.title, + required this.firstStyle, + required this.secondStyle}); @override createState() => _CustomWidgetState(); diff --git a/example/lib/tips/border/tips_emboss_inside_emboss.dart b/example/lib/tips/border/tips_emboss_inside_emboss.dart index c9e03ae8..f106ca18 100644 --- a/example/lib/tips/border/tips_emboss_inside_emboss.dart +++ b/example/lib/tips/border/tips_emboss_inside_emboss.dart @@ -1,11 +1,10 @@ import 'package:example/lib/Code.dart'; import 'package:example/lib/ThemeConfigurator.dart'; import 'package:example/lib/top_bar.dart'; -import 'package:flutter/material.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; class TipsRecursiveeEmbossPage extends StatefulWidget { - TipsRecursiveeEmbossPage({Key key}) : super(key: key); + TipsRecursiveeEmbossPage({Key? key}) : super(key: key); @override createState() => _WidgetPageState(); @@ -88,14 +87,14 @@ class _EmbossmbossWidgetState extends State<_EmbossmbossWidget> { } Widget _generateEmbosss( - {int number, Widget child, bool reverseEachPair = false}) { + {int? number, required Widget child, bool reverseEachPair = false}) { Widget element = child; - for (int i = 0; i < number; ++i) { + for (int i = 0; i < number!; ++i) { element = Neumorphic( padding: EdgeInsets.all(20), style: NeumorphicStyle( boxShape: NeumorphicBoxShape.circle(), - depth: -(NeumorphicTheme.depth(context).abs()), //force negative + depth: -(NeumorphicTheme.depth(context)!.abs()), //force negative oppositeShadowLightSource: (reverseEachPair && i % 2 == 0), ), child: element, diff --git a/example/lib/tips/tips_home.dart b/example/lib/tips/tips_home.dart index 945a5e35..9c815fd7 100644 --- a/example/lib/tips/tips_home.dart +++ b/example/lib/tips/tips_home.dart @@ -6,7 +6,7 @@ import 'border/tips_border.dart'; import 'border/tips_emboss_inside_emboss.dart'; class TipsHome extends StatelessWidget { - Widget _buildButton({String text, VoidCallback onClick}) { + Widget _buildButton({String? text, VoidCallback? onClick}) { return NeumorphicButton( margin: EdgeInsets.only(bottom: 12), padding: EdgeInsets.symmetric( @@ -19,7 +19,7 @@ class TipsHome extends StatelessWidget { BorderRadius.circular(12), ), ), - child: Center(child: Text(text)), + child: Center(child: Text(text!)), onPressed: onClick, ); } @@ -39,7 +39,10 @@ class TipsHome extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.max, children: [ - TopBar(title: "Tips"), + TopBar( + title: "Tips", + actions: [], + ), _buildButton( text: "Border", onClick: () { @@ -53,7 +56,9 @@ class TipsHome extends StatelessWidget { onClick: () { Navigator.of(context) .push(MaterialPageRoute(builder: (context) { - return TipsRecursiveeEmbossPage(); + return TipsRecursiveeEmbossPage( + key: null, + ); })); }), ], diff --git a/example/lib/widgets/appbar/widget_app_bar.dart b/example/lib/widgets/appbar/widget_app_bar.dart index 6e4549e7..de6cf03b 100644 --- a/example/lib/widgets/appbar/widget_app_bar.dart +++ b/example/lib/widgets/appbar/widget_app_bar.dart @@ -1,9 +1,7 @@ -import 'package:flutter/material.dart'; -import 'package:flutter/rendering.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; class AppBarWidgetPage extends StatelessWidget { - AppBarWidgetPage({Key key}) : super(key: key); + AppBarWidgetPage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { @@ -152,7 +150,7 @@ class FirstThemeContent extends StatelessWidget { class _MyDrawer extends StatelessWidget { final bool isLead; - const _MyDrawer({Key key, this.isLead = true}) : super(key: key); + const _MyDrawer({Key? key, this.isLead = true}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/example/lib/widgets/background/widget_background.dart b/example/lib/widgets/background/widget_background.dart index aa35b588..c32edccc 100644 --- a/example/lib/widgets/background/widget_background.dart +++ b/example/lib/widgets/background/widget_background.dart @@ -1,11 +1,10 @@ import 'package:example/lib/Code.dart'; import 'package:example/lib/ThemeConfigurator.dart'; import 'package:example/lib/top_bar.dart'; -import 'package:flutter/material.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; class BackgroundWidgetPage extends StatefulWidget { - BackgroundWidgetPage({Key key}) : super(key: key); + BackgroundWidgetPage({Key? key}) : super(key: key); @override createState() => _WidgetPageState(); diff --git a/example/lib/widgets/button/button.dart b/example/lib/widgets/button/button.dart index cb8e6319..6e25bb34 100644 --- a/example/lib/widgets/button/button.dart +++ b/example/lib/widgets/button/button.dart @@ -1,4 +1,3 @@ -import 'package:flutter/material.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; class ButtonSample extends StatefulWidget { @@ -42,17 +41,17 @@ class __PageState extends State<_Page> { child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - RaisedButton( + ElevatedButton( onPressed: () { Navigator.of(context).pop(); }, child: Text("back"), ), - RaisedButton( + ElevatedButton( onPressed: () { setState(() { _useDark = !_useDark; - NeumorphicTheme.of(context).themeMode = + NeumorphicTheme.of(context)!.themeMode = _useDark ? ThemeMode.dark : ThemeMode.light; }); }, @@ -87,10 +86,10 @@ class __PageState extends State<_Page> { ); } - Color _iconsColor() { + Color? _iconsColor() { final theme = NeumorphicTheme.of(context); - if (theme.isUsingDark) { - return theme.current.accentColor; + if (theme!.isUsingDark) { + return theme.current!.accentColor; } else { return null; } diff --git a/example/lib/widgets/button/widget_button.dart b/example/lib/widgets/button/widget_button.dart index 117225b3..37592421 100644 --- a/example/lib/widgets/button/widget_button.dart +++ b/example/lib/widgets/button/widget_button.dart @@ -2,11 +2,10 @@ import 'package:example/lib/Code.dart'; import 'package:example/lib/ThemeConfigurator.dart'; import 'package:example/lib/color_selector.dart'; import 'package:example/lib/top_bar.dart'; -import 'package:flutter/material.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; class ButtonWidgetPage extends StatefulWidget { - ButtonWidgetPage({Key key}) : super(key: key); + ButtonWidgetPage({Key? key}) : super(key: key); @override createState() => _WidgetPageState(); diff --git a/example/lib/widgets/checkbox/widget_checkbox.dart b/example/lib/widgets/checkbox/widget_checkbox.dart index 1412294c..3627b1bf 100644 --- a/example/lib/widgets/checkbox/widget_checkbox.dart +++ b/example/lib/widgets/checkbox/widget_checkbox.dart @@ -2,11 +2,10 @@ import 'package:example/lib/Code.dart'; import 'package:example/lib/ThemeConfigurator.dart'; import 'package:example/lib/color_selector.dart'; import 'package:example/lib/top_bar.dart'; -import 'package:flutter/material.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; class CheckboxWidgetPage extends StatefulWidget { - CheckboxWidgetPage({Key key}) : super(key: key); + CheckboxWidgetPage({Key? key}) : super(key: key); @override createState() => _WidgetPageState(); diff --git a/example/lib/widgets/container/widget_container.dart b/example/lib/widgets/container/widget_container.dart index 90cafbf4..8e48f79b 100644 --- a/example/lib/widgets/container/widget_container.dart +++ b/example/lib/widgets/container/widget_container.dart @@ -2,11 +2,10 @@ import 'package:example/lib/Code.dart'; import 'package:example/lib/ThemeConfigurator.dart'; import 'package:example/lib/color_selector.dart'; import 'package:example/lib/top_bar.dart'; -import 'package:flutter/material.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; class ContainerWidgetPage extends StatefulWidget { - ContainerWidgetPage({Key key}) : super(key: key); + ContainerWidgetPage({Key? key}) : super(key: key); @override createState() => _WidgetPageState(); diff --git a/example/lib/widgets/icon/widget_icon.dart b/example/lib/widgets/icon/widget_icon.dart index deb111ed..e5067032 100644 --- a/example/lib/widgets/icon/widget_icon.dart +++ b/example/lib/widgets/icon/widget_icon.dart @@ -1,10 +1,9 @@ import 'package:example/lib/ThemeConfigurator.dart'; import 'package:example/lib/top_bar.dart'; -import 'package:flutter/material.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; class IconWidgetPage extends StatefulWidget { - IconWidgetPage({Key key}) : super(key: key); + IconWidgetPage({Key? key}) : super(key: key); @override createState() => _WidgetPageState(); @@ -741,7 +740,7 @@ class _PageState extends State<_Page> { Icons.picture_in_picture, Icons.picture_in_picture_alt, Icons.pie_chart, - Icons.pie_chart_outlined, + Icons.pie_chart_outline, Icons.pin_drop, Icons.place, Icons.play_arrow, diff --git a/example/lib/widgets/indeterminate_progress/widget_indeterminate_progress.dart b/example/lib/widgets/indeterminate_progress/widget_indeterminate_progress.dart index 09f2b289..95ccf5d6 100644 --- a/example/lib/widgets/indeterminate_progress/widget_indeterminate_progress.dart +++ b/example/lib/widgets/indeterminate_progress/widget_indeterminate_progress.dart @@ -2,11 +2,10 @@ import 'package:example/lib/Code.dart'; import 'package:example/lib/ThemeConfigurator.dart'; import 'package:example/lib/color_selector.dart'; import 'package:example/lib/top_bar.dart'; -import 'package:flutter/material.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; class IndeterminateProgressWidgetPage extends StatefulWidget { - IndeterminateProgressWidgetPage({Key key}) : super(key: key); + IndeterminateProgressWidgetPage({Key? key}) : super(key: key); @override createState() => _WidgetPageState(); diff --git a/example/lib/widgets/indicator/widget_indicator.dart b/example/lib/widgets/indicator/widget_indicator.dart index a5c42247..fca02508 100644 --- a/example/lib/widgets/indicator/widget_indicator.dart +++ b/example/lib/widgets/indicator/widget_indicator.dart @@ -2,13 +2,12 @@ import 'package:example/lib/Code.dart'; import 'package:example/lib/ThemeConfigurator.dart'; import 'package:example/lib/color_selector.dart'; import 'package:example/lib/top_bar.dart'; -import 'package:flutter/material.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; import 'dart:math' show Random; class IndicatorWidgetPage extends StatefulWidget { - IndicatorWidgetPage({Key key}) : super(key: key); + IndicatorWidgetPage({Key? key}) : super(key: key); @override createState() => _WidgetPageState(); @@ -102,7 +101,7 @@ NeumorphicIndicator( percent: percent, ), SizedBox(width: 12), - FlatButton( + TextButton( child: Text('Update'), onPressed: () { setState(() { @@ -298,7 +297,7 @@ NeumorphicIndicator( duration: Duration(seconds: 1), ), SizedBox(width: 12), - FlatButton( + TextButton( child: Text('Update'), onPressed: () { setState(() { @@ -356,7 +355,7 @@ NeumorphicIndicator( percent: percent, curve: Curves.bounceOut), SizedBox(width: 12), - FlatButton( + TextButton( child: Text('Update'), onPressed: () { setState(() { diff --git a/example/lib/widgets/progress/widget_progress.dart b/example/lib/widgets/progress/widget_progress.dart index 7867cb06..aec517d0 100644 --- a/example/lib/widgets/progress/widget_progress.dart +++ b/example/lib/widgets/progress/widget_progress.dart @@ -7,7 +7,7 @@ import 'package:flutter_neumorphic/flutter_neumorphic.dart'; import 'dart:math' show Random; class ProgressWidgetPage extends StatefulWidget { - ProgressWidgetPage({Key key}) : super(key: key); + ProgressWidgetPage({Key? key}) : super(key: key); @override createState() => _WidgetPageState(); @@ -42,6 +42,7 @@ class _PageState extends State<_Page> { child: Scaffold( appBar: TopBar( title: "Progress", + actions: [], ), backgroundColor: Colors.transparent, body: SingleChildScrollView( @@ -110,7 +111,7 @@ Expanded( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ _buildWidget(context), - FlatButton( + TextButton( child: Text('Update'), onPressed: () { setState(() { @@ -323,7 +324,7 @@ Expanded( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ _buildWidget(context), - FlatButton( + TextButton( child: Text('Update'), onPressed: () { setState(() { @@ -384,7 +385,7 @@ Expanded( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ _buildWidget(context), - FlatButton( + TextButton( child: Text('Update'), onPressed: () { setState(() { diff --git a/example/lib/widgets/radiobutton/widget_radio_button.dart b/example/lib/widgets/radiobutton/widget_radio_button.dart index f8e1434f..88182d44 100644 --- a/example/lib/widgets/radiobutton/widget_radio_button.dart +++ b/example/lib/widgets/radiobutton/widget_radio_button.dart @@ -1,11 +1,10 @@ import 'package:example/lib/Code.dart'; import 'package:example/lib/ThemeConfigurator.dart'; import 'package:example/lib/top_bar.dart'; -import 'package:flutter/material.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; class RadioButtonWidgetPage extends StatefulWidget { - RadioButtonWidgetPage({Key key}) : super(key: key); + RadioButtonWidgetPage({Key? key}) : super(key: key); @override createState() => _WidgetPageState(); @@ -69,7 +68,7 @@ class _DefaultWidget extends StatefulWidget { } class _DefaultWidgetState extends State<_DefaultWidget> { - int groupValue; + late int groupValue; Widget _buildCode(BuildContext context) { return Code(""" @@ -108,7 +107,7 @@ NeumorphicRadio( value: 1991, onChanged: (value) { setState(() { - groupValue = value; + groupValue = value!; }); }, padding: EdgeInsets.all(8.0), @@ -120,7 +119,7 @@ NeumorphicRadio( groupValue: groupValue, onChanged: (value) { setState(() { - groupValue = value; + groupValue = value!; }); }, padding: EdgeInsets.all(8.0), @@ -132,7 +131,7 @@ NeumorphicRadio( value: 2012, onChanged: (value) { setState(() { - groupValue = value; + groupValue = value!; }); }, padding: EdgeInsets.all(8.0), @@ -160,7 +159,7 @@ class CircleRadios extends StatefulWidget { } class _CircleRadiosState extends State { - String groupValue; + late String groupValue; Widget _buildCode(BuildContext context) { return Code(""" @@ -198,7 +197,7 @@ NeumorphicRadio( value: "A", onChanged: (value) { setState(() { - groupValue = value; + groupValue = value!; }); }, padding: EdgeInsets.all(18.0), @@ -213,7 +212,7 @@ NeumorphicRadio( groupValue: groupValue, onChanged: (value) { setState(() { - groupValue = value; + groupValue = value!; }); }, padding: EdgeInsets.all(18.0), @@ -228,7 +227,7 @@ NeumorphicRadio( value: "C", onChanged: (value) { setState(() { - groupValue = value; + groupValue = value!; }); }, padding: EdgeInsets.all(18.0), @@ -256,7 +255,7 @@ class _EnabledDisabledWidget extends StatefulWidget { } class _EnabledDisabledWidgetState extends State<_EnabledDisabledWidget> { - int groupValue; + late int groupValue; Widget _buildWidget(BuildContext context) { return Padding( @@ -275,7 +274,7 @@ class _EnabledDisabledWidgetState extends State<_EnabledDisabledWidget> { child: Text("First"), onChanged: (value) { setState(() { - groupValue = value; + groupValue = value!; }); }, ), @@ -293,7 +292,7 @@ class _EnabledDisabledWidgetState extends State<_EnabledDisabledWidget> { child: Text("Second"), onChanged: (value) { setState(() { - groupValue = value; + groupValue = value!; }); }, ), diff --git a/example/lib/widgets/range_slider/widget_range_slider.dart b/example/lib/widgets/range_slider/widget_range_slider.dart index c8c312f3..2b04e7f0 100644 --- a/example/lib/widgets/range_slider/widget_range_slider.dart +++ b/example/lib/widgets/range_slider/widget_range_slider.dart @@ -2,11 +2,10 @@ import 'package:example/lib/Code.dart'; import 'package:example/lib/ThemeConfigurator.dart'; import 'package:example/lib/color_selector.dart'; import 'package:example/lib/top_bar.dart'; -import 'package:flutter/material.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; class RangeSliderWidgetPage extends StatefulWidget { - RangeSliderWidgetPage({Key key}) : super(key: key); + RangeSliderWidgetPage({Key? key}) : super(key: key); @override createState() => _RangeWidgetPageState(); diff --git a/example/lib/widgets/slider/widget_slider.dart b/example/lib/widgets/slider/widget_slider.dart index 522c9c30..beb1450a 100644 --- a/example/lib/widgets/slider/widget_slider.dart +++ b/example/lib/widgets/slider/widget_slider.dart @@ -2,11 +2,10 @@ import 'package:example/lib/Code.dart'; import 'package:example/lib/ThemeConfigurator.dart'; import 'package:example/lib/color_selector.dart'; import 'package:example/lib/top_bar.dart'; -import 'package:flutter/material.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; class SliderWidgetPage extends StatefulWidget { - SliderWidgetPage({Key key}) : super(key: key); + SliderWidgetPage({Key? key}) : super(key: key); @override createState() => _WidgetPageState(); diff --git a/example/lib/widgets/switch/widget_switch.dart b/example/lib/widgets/switch/widget_switch.dart index cb26b465..2e639f5f 100644 --- a/example/lib/widgets/switch/widget_switch.dart +++ b/example/lib/widgets/switch/widget_switch.dart @@ -2,11 +2,10 @@ import 'package:example/lib/Code.dart'; import 'package:example/lib/ThemeConfigurator.dart'; import 'package:example/lib/color_selector.dart'; import 'package:example/lib/top_bar.dart'; -import 'package:flutter/material.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; class SwitchWidgetPage extends StatefulWidget { - SwitchWidgetPage({Key key}) : super(key: key); + SwitchWidgetPage({Key? key}) : super(key: key); @override createState() => _WidgetPageState(); @@ -110,7 +109,7 @@ NeumorphicSwitch( }, ), SizedBox(width: 12), - FlatButton( + TextButton( onPressed: () { setState(() { isEnabled = !isEnabled; diff --git a/example/lib/widgets/toggle/widget_toggle.dart b/example/lib/widgets/toggle/widget_toggle.dart index c2ebbf80..19afb18c 100644 --- a/example/lib/widgets/toggle/widget_toggle.dart +++ b/example/lib/widgets/toggle/widget_toggle.dart @@ -1,11 +1,10 @@ import 'package:example/lib/Code.dart'; import 'package:example/lib/ThemeConfigurator.dart'; import 'package:example/lib/top_bar.dart'; -import 'package:flutter/material.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; class ToggleWidgetPage extends StatefulWidget { - ToggleWidgetPage({Key key}) : super(key: key); + ToggleWidgetPage({Key? key}) : super(key: key); @override createState() => _WidgetPageState(); @@ -272,7 +271,7 @@ NeumorphicToggle( ), onAnimationChangedFinished: (value) { if (value == 0) { - Scaffold.of(context) + ScaffoldMessenger.of(context) .showSnackBar(SnackBar(content: Text('on back !'))); print("onAnimationChangedFinished: $_selectedIndex"); } diff --git a/example/lib/widgets/widgets_home.dart b/example/lib/widgets/widgets_home.dart index 4cea506b..1f68f5fc 100644 --- a/example/lib/widgets/widgets_home.dart +++ b/example/lib/widgets/widgets_home.dart @@ -1,7 +1,6 @@ import 'package:example/lib/top_bar.dart'; import 'package:example/widgets/appbar/widget_app_bar.dart'; import 'package:example/widgets/toggle/widget_toggle.dart'; -import 'package:flutter/material.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; import 'background/widget_background.dart'; @@ -18,7 +17,7 @@ import 'slider/widget_slider.dart'; import 'switch/widget_switch.dart'; class WidgetsHome extends StatelessWidget { - Widget _buildButton({String text, VoidCallback onClick}) { + Widget _buildButton({String? text, VoidCallback? onClick}) { return NeumorphicButton( margin: EdgeInsets.only(bottom: 12), padding: EdgeInsets.symmetric( @@ -31,7 +30,7 @@ class WidgetsHome extends StatelessWidget { ), shape: NeumorphicShape.flat, ), - child: Center(child: Text(text)), + child: Center(child: Text(text!)), onPressed: onClick, ); } @@ -51,7 +50,10 @@ class WidgetsHome extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.max, children: [ - TopBar(title: "Widgets"), + TopBar( + title: "Widgets", + actions: [], + ), _buildButton( text: "Container", onClick: () { diff --git a/example/macos/Flutter/GeneratedPluginRegistrant.swift b/example/macos/Flutter/GeneratedPluginRegistrant.swift index cf981460..cccf817a 100644 --- a/example/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/example/macos/Flutter/GeneratedPluginRegistrant.swift @@ -2,8 +2,6 @@ // Generated file. Do not edit. // -// clang-format off - import FlutterMacOS import Foundation diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 5f19d033..5a991ce8 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -14,7 +14,7 @@ description: A new Flutter project. version: 1.0.0+1 environment: - sdk: ">=2.6.0 <3.0.0" + sdk: '>=2.18.0-234.0.dev <3.0.0' dependencies: flutter: @@ -23,7 +23,7 @@ dependencies: flutter_neumorphic: path: ../ - flutter_colorpicker: ^0.4.0 + flutter_colorpicker: ^1.0.3 dev_dependencies: flutter_test: From b960ed4ecf170f19eb647125865f4ac093d55357 Mon Sep 17 00:00:00 2001 From: Baris Kaya Date: Wed, 29 Jun 2022 23:33:56 +0300 Subject: [PATCH 2/7] fix initialization problems --- example/lib/samples/form_sample.dart | 2 +- example/lib/samples/widgets_sample.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/example/lib/samples/form_sample.dart b/example/lib/samples/form_sample.dart index a834d4d8..dbf554bc 100644 --- a/example/lib/samples/form_sample.dart +++ b/example/lib/samples/form_sample.dart @@ -35,7 +35,7 @@ class __PageState extends State<_Page> { String firstName = ""; String lastName = ""; double age = 12; - late Gender gender; + late Gender gender = Gender.NON_BINARY; Set rides = Set(); @override diff --git a/example/lib/samples/widgets_sample.dart b/example/lib/samples/widgets_sample.dart index 6ec2b3d6..444cdf8c 100644 --- a/example/lib/samples/widgets_sample.dart +++ b/example/lib/samples/widgets_sample.dart @@ -9,7 +9,7 @@ class WidgetsSample extends StatefulWidget { } class _ContainersListPageState extends State { - late int _groupValue; + int _groupValue = 1; bool _switchConcaveEnabled = false; bool _switchConvexEnabled = false; bool _switchFlatEnabled = false; From cf517a03444207b0dcfb36ae57a333936afcecc3 Mon Sep 17 00:00:00 2001 From: Baris Kaya Date: Thu, 30 Jun 2022 07:51:49 +0300 Subject: [PATCH 3/7] remove unnecessary containers --- .../com/example/example/MainActivity.kt | 1 + .../neumorphic_accessibility.dart | 8 +- example/lib/lib/Code.dart | 1 - example/lib/lib/color_selector.dart | 4 - .../lib/playground/neumorphic_playground.dart | 16 +- example/lib/playground/text_playground.dart | 2 - example/lib/sample_neumorphic_playground.dart | 16 +- example/lib/samples/clock/clock_sample.dart | 1 - example/lib/samples/credit_card_sample.dart | 240 +++++++++--------- example/lib/samples/form_sample.dart | 1 - example/lib/samples/sample_home.dart | 1 - example/lib/samples/testla_sample.dart | 1 - example/lib/samples/widgets_sample.dart | 1 - example/lib/tips/tips_home.dart | 1 - .../lib/widgets/progress/widget_progress.dart | 1 - 15 files changed, 129 insertions(+), 166 deletions(-) diff --git a/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt b/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt index e793a000..df49ce4e 100644 --- a/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt +++ b/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt @@ -3,4 +3,5 @@ package com.example.example import io.flutter.embedding.android.FlutterActivity class MainActivity: FlutterActivity() { + val myString = "adding this one cuz codefactor does not allow an empty function!" } diff --git a/example/lib/accessibility/neumorphic_accessibility.dart b/example/lib/accessibility/neumorphic_accessibility.dart index 346e19f6..e059d66d 100644 --- a/example/lib/accessibility/neumorphic_accessibility.dart +++ b/example/lib/accessibility/neumorphic_accessibility.dart @@ -215,13 +215,10 @@ class __PageState extends State<_Page> { switch (selectedConfiguratorIndex) { case 0: return styleCustomizer(); - break; case 1: return elementCustomizer(); - break; case 2: return borderCustomizer(); - break; } return null; } @@ -330,10 +327,7 @@ class __PageState extends State<_Page> { child: SizedBox( height: height, width: width, - child: Container( - //color: Colors.blue, - child: Center(child: Text("")), - ), + child: Center(child: Text("")), ), ); } diff --git a/example/lib/lib/Code.dart b/example/lib/lib/Code.dart index 8ccb1ebf..a70994f6 100644 --- a/example/lib/lib/Code.dart +++ b/example/lib/lib/Code.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; class Code extends StatelessWidget { diff --git a/example/lib/lib/color_selector.dart b/example/lib/lib/color_selector.dart index 6438d6c6..9dcfef71 100644 --- a/example/lib/lib/color_selector.dart +++ b/example/lib/lib/color_selector.dart @@ -1,7 +1,4 @@ -import 'dart:ui'; - import 'package:flutter/material.dart'; -import 'package:flutter/widgets.dart'; import 'package:flutter_colorpicker/flutter_colorpicker.dart'; @immutable @@ -47,7 +44,6 @@ class ColorSelector extends StatelessWidget { child: ColorPicker( pickerColor: color, onColorChanged: this.onColorChanged, - showLabel: true, pickerAreaHeightPercent: 0.8, ), ), diff --git a/example/lib/playground/neumorphic_playground.dart b/example/lib/playground/neumorphic_playground.dart index a2501262..53c2de77 100644 --- a/example/lib/playground/neumorphic_playground.dart +++ b/example/lib/playground/neumorphic_playground.dart @@ -72,7 +72,7 @@ class __PageState extends State<_Page> { padding: const EdgeInsets.only(left: 8.0, right: 8.0, top: 8.0), child: ElevatedButton( style: ElevatedButton.styleFrom( - backgroundColor: Theme.of(context).accentColor, + backgroundColor: Theme.of(context).colorScheme.secondary, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12))), child: const Text( @@ -105,7 +105,7 @@ class __PageState extends State<_Page> { int selectedConfiguratorIndex = 0; Widget _configurators() { - final Color buttonActiveColor = Theme.of(context).accentColor; + final Color buttonActiveColor = Theme.of(context).colorScheme.secondary; const Color buttonInnactiveColor = Colors.white; const Color textActiveColor = Colors.white; @@ -214,13 +214,10 @@ class __PageState extends State<_Page> { switch (selectedConfiguratorIndex) { case 0: return styleCustomizer(); - break; case 1: return elementCustomizer(); - break; case 2: return childCustomizer(); - break; } return null; } @@ -313,10 +310,7 @@ class __PageState extends State<_Page> { width: width, child: haveNeumorphicChild ? neumorphicChild() - : Container( - //color: Colors.blue, - child: const Center(child: Text("")), - ), + : const Center(child: Text("")), ), ); } @@ -628,7 +622,7 @@ class __PageState extends State<_Page> { } Widget boxshapeWidget() { - final Color buttonActiveColor = Theme.of(context).accentColor; + final Color buttonActiveColor = Theme.of(context).colorScheme.secondary; const Color buttonInnactiveColor = Colors.white; const Color textActiveColor = Colors.white; @@ -770,7 +764,7 @@ class __PageState extends State<_Page> { } Widget shapeWidget() { - final Color buttonActiveColor = Theme.of(context).accentColor; + final Color buttonActiveColor = Theme.of(context).colorScheme.secondary; const Color buttonInnactiveColor = Colors.white; const Color iconActiveColor = Colors.white; diff --git a/example/lib/playground/text_playground.dart b/example/lib/playground/text_playground.dart index 04cbb962..1dacffd0 100644 --- a/example/lib/playground/text_playground.dart +++ b/example/lib/playground/text_playground.dart @@ -210,10 +210,8 @@ class __PageState extends State<_Page> { switch (selectedConfiguratorIndex) { case 0: return styleCustomizer(); - break; case 1: return elementCustomizer(); - break; } return null; } diff --git a/example/lib/sample_neumorphic_playground.dart b/example/lib/sample_neumorphic_playground.dart index 382bc266..151e8312 100644 --- a/example/lib/sample_neumorphic_playground.dart +++ b/example/lib/sample_neumorphic_playground.dart @@ -83,12 +83,6 @@ class __PageState extends State<_Page> { } Widget _configurators() { - final Color buttonActiveColor = Theme.of(context).accentColor; - final Color buttonInnactiveColor = Colors.white; - - final Color textActiveColor = Colors.white; - final Color textInactiveColor = Colors.black.withOpacity(0.3); - return Column( children: [ styleCustomizer(), @@ -134,12 +128,8 @@ class __PageState extends State<_Page> { child: SizedBox( height: height, width: width, - child: haveNeumorphicChild - ? neumorphicChild() - : Container( - //color: Colors.blue, - child: Center(child: Text("")), - ), + child: + haveNeumorphicChild ? neumorphicChild() : Center(child: Text("")), ), ); } @@ -244,7 +234,7 @@ class __PageState extends State<_Page> { } Widget shapeWidget() { - final Color buttonActiveColor = Theme.of(context).accentColor; + final Color buttonActiveColor = Theme.of(context).colorScheme.secondary; final Color buttonInnactiveColor = Colors.white; final Color iconActiveColor = Colors.white; diff --git a/example/lib/samples/clock/clock_sample.dart b/example/lib/samples/clock/clock_sample.dart index f33e4322..45420a25 100644 --- a/example/lib/samples/clock/clock_sample.dart +++ b/example/lib/samples/clock/clock_sample.dart @@ -1,5 +1,4 @@ import 'package:example/lib/top_bar.dart'; -import 'package:flutter/material.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; import 'clock_second_sample.dart'; diff --git a/example/lib/samples/credit_card_sample.dart b/example/lib/samples/credit_card_sample.dart index a2955889..4421f787 100644 --- a/example/lib/samples/credit_card_sample.dart +++ b/example/lib/samples/credit_card_sample.dart @@ -55,147 +55,145 @@ class __PageContentState extends State<_PageContent> { } Widget _buildCard(BuildContext context) { - return Container( + return Neumorphic( + style: NeumorphicStyle( + depth: 10, + boxShape: NeumorphicBoxShape.roundRect(BorderRadius.circular(20)), + shape: NeumorphicShape.flat, + ), child: Neumorphic( + margin: EdgeInsets.all(8), style: NeumorphicStyle( depth: 10, boxShape: NeumorphicBoxShape.roundRect(BorderRadius.circular(20)), shape: NeumorphicShape.flat, ), - child: Neumorphic( - margin: EdgeInsets.all(8), - style: NeumorphicStyle( - depth: 10, - boxShape: NeumorphicBoxShape.roundRect(BorderRadius.circular(20)), - shape: NeumorphicShape.flat, - ), - child: SizedBox( - height: 200, - child: AspectRatio( - aspectRatio: 9 / 16, - child: Stack( - fit: StackFit.expand, - children: [ - //Image.asset("assets/images/map.jpg", fit: BoxFit.cover), - BackdropFilter( - filter: ImageFilter.blur(sigmaX: 3, sigmaY: 3), - child: Container( - decoration: BoxDecoration( - gradient: LinearGradient( - begin: Alignment.topRight, - end: Alignment.bottomLeft, - colors: [ - Colors.purple.withOpacity(0.5), - Colors.red.withOpacity(0.5) - ])), - ), + child: SizedBox( + height: 200, + child: AspectRatio( + aspectRatio: 9 / 16, + child: Stack( + fit: StackFit.expand, + children: [ + //Image.asset("assets/images/map.jpg", fit: BoxFit.cover), + BackdropFilter( + filter: ImageFilter.blur(sigmaX: 3, sigmaY: 3), + child: Container( + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topRight, + end: Alignment.bottomLeft, + colors: [ + Colors.purple.withOpacity(0.5), + Colors.red.withOpacity(0.5) + ])), ), - Stack( - children: [ - Positioned( - top: 12, - left: 16, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "VISA", - style: TextStyle( - fontSize: 40, - color: Colors.white, - fontWeight: FontWeight.w800), - ), - SizedBox( - height: 30, - ), - Text( - "1234 5678", - style: TextStyle( - fontSize: 30, - color: Colors.black.withOpacity(0.7)), - ), - SizedBox( - height: 3, - ), - Text( - "1234 5678", - style: TextStyle( - fontSize: 30, - color: Colors.black.withOpacity(0.7)), - ), - ], - ), + ), + Stack( + children: [ + Positioned( + top: 12, + left: 16, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "VISA", + style: TextStyle( + fontSize: 40, + color: Colors.white, + fontWeight: FontWeight.w800), + ), + SizedBox( + height: 30, + ), + Text( + "1234 5678", + style: TextStyle( + fontSize: 30, + color: Colors.black.withOpacity(0.7)), + ), + SizedBox( + height: 3, + ), + Text( + "1234 5678", + style: TextStyle( + fontSize: 30, + color: Colors.black.withOpacity(0.7)), + ), + ], ), - Positioned( - top: 12, - right: 16, - child: SizedBox( - height: 60, - child: Neumorphic( - style: NeumorphicStyle( - depth: 5, - intensity: 0.8, - lightSource: LightSource.topLeft, - boxShape: NeumorphicBoxShape.roundRect( - BorderRadius.circular(12), - ), + ), + Positioned( + top: 12, + right: 16, + child: SizedBox( + height: 60, + child: Neumorphic( + style: NeumorphicStyle( + depth: 5, + intensity: 0.8, + lightSource: LightSource.topLeft, + boxShape: NeumorphicBoxShape.roundRect( + BorderRadius.circular(12), ), - child: RotatedBox( - quarterTurns: 1, - child: Image.asset( - "assets/images/credit_card_chip.png")), ), + child: RotatedBox( + quarterTurns: 1, + child: Image.asset( + "assets/images/credit_card_chip.png")), ), ), - Positioned( - bottom: 12, - right: 16, - child: Column( - children: [ - Text( - "09/24", - style: TextStyle( - fontSize: 20, - color: Colors.white.withOpacity(0.7)), - ), - SizedBox( - height: 8, - ), - Stack( - children: [ - Neumorphic( + ), + Positioned( + bottom: 12, + right: 16, + child: Column( + children: [ + Text( + "09/24", + style: TextStyle( + fontSize: 20, + color: Colors.white.withOpacity(0.7)), + ), + SizedBox( + height: 8, + ), + Stack( + children: [ + Neumorphic( + style: NeumorphicStyle( + shape: NeumorphicShape.convex, + depth: -10, + boxShape: NeumorphicBoxShape.circle(), + color: Colors.grey[300]), + child: const SizedBox( + height: 30, + width: 30, + ), + ), + Padding( + padding: EdgeInsets.only(left: 18), + child: Neumorphic( style: NeumorphicStyle( shape: NeumorphicShape.convex, - depth: -10, boxShape: NeumorphicBoxShape.circle(), - color: Colors.grey[300]), + depth: 10), child: const SizedBox( height: 30, width: 30, ), ), - Padding( - padding: EdgeInsets.only(left: 18), - child: Neumorphic( - style: NeumorphicStyle( - shape: NeumorphicShape.convex, - boxShape: NeumorphicBoxShape.circle(), - depth: 10), - child: const SizedBox( - height: 30, - width: 30, - ), - ), - ), - ], - ), - ], - ), - ) - ], - ), - ], - ), + ), + ], + ), + ], + ), + ) + ], + ), + ], ), ), ), diff --git a/example/lib/samples/form_sample.dart b/example/lib/samples/form_sample.dart index dbf554bc..6cbc345c 100644 --- a/example/lib/samples/form_sample.dart +++ b/example/lib/samples/form_sample.dart @@ -1,6 +1,5 @@ import 'package:example/lib/ThemeConfigurator.dart'; import 'package:example/lib/top_bar.dart'; -import 'package:flutter/material.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; class FormSample extends StatelessWidget { diff --git a/example/lib/samples/sample_home.dart b/example/lib/samples/sample_home.dart index 65a11b4e..e2885582 100644 --- a/example/lib/samples/sample_home.dart +++ b/example/lib/samples/sample_home.dart @@ -5,7 +5,6 @@ import 'package:example/samples/clock/clock_sample.dart'; import 'package:example/samples/credit_card_sample.dart'; import 'package:example/samples/form_sample.dart'; import 'package:example/samples/testla_sample.dart'; -import 'package:flutter/material.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; import 'galaxy_sample.dart'; diff --git a/example/lib/samples/testla_sample.dart b/example/lib/samples/testla_sample.dart index 27d89940..a9c69bfd 100644 --- a/example/lib/samples/testla_sample.dart +++ b/example/lib/samples/testla_sample.dart @@ -1,4 +1,3 @@ - import 'package:flutter_neumorphic/flutter_neumorphic.dart'; class TeslaSample extends StatefulWidget { diff --git a/example/lib/samples/widgets_sample.dart b/example/lib/samples/widgets_sample.dart index 444cdf8c..99525311 100644 --- a/example/lib/samples/widgets_sample.dart +++ b/example/lib/samples/widgets_sample.dart @@ -1,4 +1,3 @@ -import 'package:flutter/material.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; class WidgetsSample extends StatefulWidget { diff --git a/example/lib/tips/tips_home.dart b/example/lib/tips/tips_home.dart index 9c815fd7..47e8e96e 100644 --- a/example/lib/tips/tips_home.dart +++ b/example/lib/tips/tips_home.dart @@ -1,5 +1,4 @@ import 'package:example/lib/top_bar.dart'; -import 'package:flutter/material.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; import 'border/tips_border.dart'; diff --git a/example/lib/widgets/progress/widget_progress.dart b/example/lib/widgets/progress/widget_progress.dart index aec517d0..1084d085 100644 --- a/example/lib/widgets/progress/widget_progress.dart +++ b/example/lib/widgets/progress/widget_progress.dart @@ -1,7 +1,6 @@ import 'package:example/lib/Code.dart'; import 'package:example/lib/color_selector.dart'; import 'package:example/lib/top_bar.dart'; -import 'package:flutter/material.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; import 'dart:math' show Random; From 227a1285b8e5bb4e92817b2fe3b7623b8a9a3585 Mon Sep 17 00:00:00 2001 From: Luis Andres Rojas Matey Date: Sun, 7 Aug 2022 11:42:46 -0600 Subject: [PATCH 4/7] Update samples by using stable version of Flutter --- .../neumorphic_accessibility.dart | 48 ++++++------- .../lib/playground/neumorphic_playground.dart | 68 +++++++++---------- example/lib/playground/text_playground.dart | 32 ++++----- example/lib/sample_neumorphic_playground.dart | 18 ++--- example/lib/samples/credit_card_sample.dart | 6 +- example/lib/samples/form_sample.dart | 6 +- example/lib/samples/widgets_sample.dart | 6 +- .../radiobutton/widget_radio_button.dart | 16 ++--- example/pubspec.yaml | 2 +- 9 files changed, 102 insertions(+), 100 deletions(-) diff --git a/example/lib/accessibility/neumorphic_accessibility.dart b/example/lib/accessibility/neumorphic_accessibility.dart index e059d66d..65f282ef 100644 --- a/example/lib/accessibility/neumorphic_accessibility.dart +++ b/example/lib/accessibility/neumorphic_accessibility.dart @@ -71,7 +71,7 @@ class __PageState extends State<_Page> { style: ElevatedButton.styleFrom( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12)), - backgroundColor: Theme.of(context).colorScheme.secondary, + // backgroundColor: Theme.of(context).colorScheme.secondary, ), child: Text( "back", @@ -127,11 +127,12 @@ class __PageState extends State<_Page> { padding: const EdgeInsets.all(8.0), child: ElevatedButton( style: ElevatedButton.styleFrom( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12)), - backgroundColor: selectedConfiguratorIndex == 0 - ? buttonActiveColor - : buttonInnactiveColor), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12)), + // backgroundColor: selectedConfiguratorIndex == 0 + // ? buttonActiveColor + // : buttonInnactiveColor + ), child: Text( "Style", style: TextStyle( @@ -154,11 +155,12 @@ class __PageState extends State<_Page> { padding: const EdgeInsets.all(8.0), child: ElevatedButton( style: ElevatedButton.styleFrom( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12)), - backgroundColor: selectedConfiguratorIndex == 1 - ? buttonActiveColor - : buttonInnactiveColor), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12)), + // backgroundColor: selectedConfiguratorIndex == 1 + // ? buttonActiveColor + // : buttonInnactiveColor + ), child: Text( "Element", style: TextStyle( @@ -183,9 +185,9 @@ class __PageState extends State<_Page> { style: ElevatedButton.styleFrom( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12)), - backgroundColor: selectedConfiguratorIndex == 2 - ? buttonActiveColor - : buttonInnactiveColor, + // backgroundColor: selectedConfiguratorIndex == 2 + // ? buttonActiveColor + // : buttonInnactiveColor, ), child: Text( "Border", @@ -528,9 +530,9 @@ class __PageState extends State<_Page> { style: ElevatedButton.styleFrom( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12)), - backgroundColor: shape == NeumorphicShape.concave - ? buttonActiveColor - : buttonInnactiveColor, + // backgroundColor: shape == NeumorphicShape.concave + // ? buttonActiveColor + // : buttonInnactiveColor, ), onPressed: () { setState(() { @@ -551,9 +553,9 @@ class __PageState extends State<_Page> { style: ElevatedButton.styleFrom( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12)), - backgroundColor: shape == NeumorphicShape.convex - ? buttonActiveColor - : buttonInnactiveColor, + // backgroundColor: shape == NeumorphicShape.convex + // ? buttonActiveColor + // : buttonInnactiveColor, ), onPressed: () { setState(() { @@ -574,9 +576,9 @@ class __PageState extends State<_Page> { style: ElevatedButton.styleFrom( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12)), - backgroundColor: shape == NeumorphicShape.flat - ? buttonActiveColor - : buttonInnactiveColor, + // backgroundColor: shape == NeumorphicShape.flat + // ? buttonActiveColor + // : buttonInnactiveColor, ), onPressed: () { setState(() { diff --git a/example/lib/playground/neumorphic_playground.dart b/example/lib/playground/neumorphic_playground.dart index 53c2de77..947711c7 100644 --- a/example/lib/playground/neumorphic_playground.dart +++ b/example/lib/playground/neumorphic_playground.dart @@ -72,7 +72,7 @@ class __PageState extends State<_Page> { padding: const EdgeInsets.only(left: 8.0, right: 8.0, top: 8.0), child: ElevatedButton( style: ElevatedButton.styleFrom( - backgroundColor: Theme.of(context).colorScheme.secondary, + // backgroundColor: Theme.of(context).colorScheme.secondary, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12))), child: const Text( @@ -127,9 +127,9 @@ class __PageState extends State<_Page> { padding: const EdgeInsets.all(8.0), child: ElevatedButton( style: ElevatedButton.styleFrom( - backgroundColor: selectedConfiguratorIndex == 0 - ? buttonActiveColor - : buttonInnactiveColor, + // backgroundColor: selectedConfiguratorIndex == 0 + // ? buttonActiveColor + // : buttonInnactiveColor, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12))), child: Text( @@ -154,9 +154,9 @@ class __PageState extends State<_Page> { padding: const EdgeInsets.all(8.0), child: ElevatedButton( style: ElevatedButton.styleFrom( - backgroundColor: selectedConfiguratorIndex == 1 - ? buttonActiveColor - : buttonInnactiveColor, + // backgroundColor: selectedConfiguratorIndex == 1 + // ? buttonActiveColor + // : buttonInnactiveColor, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12))), child: Text( @@ -181,9 +181,9 @@ class __PageState extends State<_Page> { padding: const EdgeInsets.all(8.0), child: ElevatedButton( style: ElevatedButton.styleFrom( - backgroundColor: selectedConfiguratorIndex == 2 - ? buttonActiveColor - : buttonInnactiveColor, + // backgroundColor: selectedConfiguratorIndex == 2 + // ? buttonActiveColor + // : buttonInnactiveColor, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12))), child: Text( @@ -636,9 +636,9 @@ class __PageState extends State<_Page> { padding: const EdgeInsets.all(8.0), child: ElevatedButton( style: ElevatedButton.styleFrom( - backgroundColor: boxShape.isRoundRect - ? buttonActiveColor - : buttonInnactiveColor, + // backgroundColor: boxShape.isRoundRect + // ? buttonActiveColor + // : buttonInnactiveColor, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12))), onPressed: () { @@ -662,9 +662,9 @@ class __PageState extends State<_Page> { padding: const EdgeInsets.all(8.0), child: ElevatedButton( style: ElevatedButton.styleFrom( - backgroundColor: boxShape.isBeveled - ? buttonActiveColor - : buttonInnactiveColor, + // backgroundColor: boxShape.isBeveled + // ? buttonActiveColor + // : buttonInnactiveColor, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12))), onPressed: () { @@ -688,9 +688,9 @@ class __PageState extends State<_Page> { padding: const EdgeInsets.all(8.0), child: ElevatedButton( style: ElevatedButton.styleFrom( - backgroundColor: boxShape.isCircle - ? buttonActiveColor - : buttonInnactiveColor, + // backgroundColor: boxShape.isCircle + // ? buttonActiveColor + // : buttonInnactiveColor, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12))), onPressed: () { @@ -713,9 +713,9 @@ class __PageState extends State<_Page> { padding: const EdgeInsets.all(8.0), child: ElevatedButton( style: ElevatedButton.styleFrom( - backgroundColor: boxShape.isStadium - ? buttonActiveColor - : buttonInnactiveColor, + // backgroundColor: boxShape.isStadium + // ? buttonActiveColor + // : buttonInnactiveColor, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12))), onPressed: () { @@ -738,9 +738,9 @@ class __PageState extends State<_Page> { padding: const EdgeInsets.all(8.0), child: ElevatedButton( style: ElevatedButton.styleFrom( - backgroundColor: boxShape.isCustomPath - ? buttonActiveColor - : buttonInnactiveColor, + // backgroundColor: boxShape.isCustomPath + // ? buttonActiveColor + // : buttonInnactiveColor, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12))), onPressed: () { @@ -778,9 +778,9 @@ class __PageState extends State<_Page> { padding: const EdgeInsets.all(8.0), child: ElevatedButton( style: ElevatedButton.styleFrom( - backgroundColor: shape == NeumorphicShape.concave - ? buttonActiveColor - : buttonInnactiveColor, + // backgroundColor: shape == NeumorphicShape.concave + // ? buttonActiveColor + // : buttonInnactiveColor, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12))), onPressed: () { @@ -800,9 +800,9 @@ class __PageState extends State<_Page> { padding: const EdgeInsets.all(8.0), child: ElevatedButton( style: ElevatedButton.styleFrom( - backgroundColor: shape == NeumorphicShape.convex - ? buttonActiveColor - : buttonInnactiveColor, + // backgroundColor: shape == NeumorphicShape.convex + // ? buttonActiveColor + // : buttonInnactiveColor, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12))), onPressed: () { @@ -822,9 +822,9 @@ class __PageState extends State<_Page> { padding: const EdgeInsets.all(8.0), child: ElevatedButton( style: ElevatedButton.styleFrom( - backgroundColor: shape == NeumorphicShape.flat - ? buttonActiveColor - : buttonInnactiveColor, + // backgroundColor: shape == NeumorphicShape.flat + // ? buttonActiveColor + // : buttonInnactiveColor, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12))), onPressed: () { diff --git a/example/lib/playground/text_playground.dart b/example/lib/playground/text_playground.dart index 1dacffd0..80a34fc0 100644 --- a/example/lib/playground/text_playground.dart +++ b/example/lib/playground/text_playground.dart @@ -92,7 +92,7 @@ class __PageState extends State<_Page> { style: ElevatedButton.styleFrom( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12)), - backgroundColor: Theme.of(context).colorScheme.secondary, + // backgroundColor: Theme.of(context).colorScheme.secondary, ), child: Text( "back", @@ -150,9 +150,9 @@ class __PageState extends State<_Page> { style: ElevatedButton.styleFrom( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12)), - backgroundColor: selectedConfiguratorIndex == 0 - ? buttonActiveColor - : buttonInnactiveColor, + // backgroundColor: selectedConfiguratorIndex == 0 + // ? buttonActiveColor + // : buttonInnactiveColor, ), child: Text( "Style", @@ -178,9 +178,9 @@ class __PageState extends State<_Page> { style: ElevatedButton.styleFrom( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12)), - backgroundColor: selectedConfiguratorIndex == 1 - ? buttonActiveColor - : buttonInnactiveColor, + // backgroundColor: selectedConfiguratorIndex == 1 + // ? buttonActiveColor + // : buttonInnactiveColor, ), child: Text( "Element", @@ -257,9 +257,9 @@ class __PageState extends State<_Page> { style: ElevatedButton.styleFrom( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12)), - backgroundColor: shape == NeumorphicShape.concave - ? buttonActiveColor - : buttonInnactiveColor, + // backgroundColor: shape == NeumorphicShape.concave + // ? buttonActiveColor + // : buttonInnactiveColor, ), onPressed: () { setState(() { @@ -280,9 +280,9 @@ class __PageState extends State<_Page> { style: ElevatedButton.styleFrom( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12)), - backgroundColor: shape == NeumorphicShape.convex - ? buttonActiveColor - : buttonInnactiveColor, + // backgroundColor: shape == NeumorphicShape.convex + // ? buttonActiveColor + // : buttonInnactiveColor, ), onPressed: () { setState(() { @@ -303,9 +303,9 @@ class __PageState extends State<_Page> { style: ElevatedButton.styleFrom( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12)), - backgroundColor: shape == NeumorphicShape.flat - ? buttonActiveColor - : buttonInnactiveColor, + // backgroundColor: shape == NeumorphicShape.flat + // ? buttonActiveColor + // : buttonInnactiveColor, ), onPressed: () { setState(() { diff --git a/example/lib/sample_neumorphic_playground.dart b/example/lib/sample_neumorphic_playground.dart index 151e8312..36e44de2 100644 --- a/example/lib/sample_neumorphic_playground.dart +++ b/example/lib/sample_neumorphic_playground.dart @@ -250,9 +250,9 @@ class __PageState extends State<_Page> { style: ElevatedButton.styleFrom( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12)), - backgroundColor: shape == NeumorphicShape.concave - ? buttonActiveColor - : buttonInnactiveColor, + // backgroundColor: shape == NeumorphicShape.concave + // ? buttonActiveColor + // : buttonInnactiveColor, ), onPressed: () { setState(() { @@ -273,9 +273,9 @@ class __PageState extends State<_Page> { style: ElevatedButton.styleFrom( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12)), - backgroundColor: shape == NeumorphicShape.convex - ? buttonActiveColor - : buttonInnactiveColor, + // backgroundColor: shape == NeumorphicShape.convex + // ? buttonActiveColor + // : buttonInnactiveColor, ), onPressed: () { setState(() { @@ -296,9 +296,9 @@ class __PageState extends State<_Page> { style: ElevatedButton.styleFrom( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12)), - backgroundColor: shape == NeumorphicShape.flat - ? buttonActiveColor - : buttonInnactiveColor, + // backgroundColor: shape == NeumorphicShape.flat + // ? buttonActiveColor + // : buttonInnactiveColor, ), onPressed: () { setState(() { diff --git a/example/lib/samples/credit_card_sample.dart b/example/lib/samples/credit_card_sample.dart index 4421f787..ff909bd6 100644 --- a/example/lib/samples/credit_card_sample.dart +++ b/example/lib/samples/credit_card_sample.dart @@ -324,7 +324,7 @@ class __PageContentState extends State<_PageContent> { value: 0, onChanged: (value) { setState(() { - _dotIndex = value!; + _dotIndex = value! as int; }); }, style: NeumorphicRadioStyle( @@ -344,7 +344,7 @@ class __PageContentState extends State<_PageContent> { value: 1, onChanged: (value) { setState(() { - _dotIndex = value!; + _dotIndex = value! as int; }); }, style: NeumorphicRadioStyle( @@ -364,7 +364,7 @@ class __PageContentState extends State<_PageContent> { value: 2, onChanged: (value) { setState(() { - _dotIndex = value!; + _dotIndex = value! as int; }); }, style: NeumorphicRadioStyle( diff --git a/example/lib/samples/form_sample.dart b/example/lib/samples/form_sample.dart index 6cbc345c..df25cb63 100644 --- a/example/lib/samples/form_sample.dart +++ b/example/lib/samples/form_sample.dart @@ -313,7 +313,7 @@ class _GenderField extends StatelessWidget { ), value: Gender.MALE, child: Icon(Icons.account_box), - onChanged: (value) => this.onChanged(value!), + onChanged: (value) => this.onChanged(value! as Gender), ), SizedBox(width: 12), NeumorphicRadio( @@ -324,7 +324,7 @@ class _GenderField extends StatelessWidget { ), value: Gender.FEMALE, child: Icon(Icons.pregnant_woman), - onChanged: (value) => this.onChanged(value!), + onChanged: (value) => this.onChanged(value! as Gender), ), SizedBox(width: 12), NeumorphicRadio( @@ -335,7 +335,7 @@ class _GenderField extends StatelessWidget { ), value: Gender.NON_BINARY, child: Icon(Icons.supervised_user_circle), - onChanged: (value) => this.onChanged(value!), + onChanged: (value) => this.onChanged(value! as Gender), ), SizedBox( width: 18, diff --git a/example/lib/samples/widgets_sample.dart b/example/lib/samples/widgets_sample.dart index 99525311..113e6fc6 100644 --- a/example/lib/samples/widgets_sample.dart +++ b/example/lib/samples/widgets_sample.dart @@ -124,7 +124,7 @@ class _ContainersListPageState extends State { groupValue: _groupValue, onChanged: (value) { setState(() { - _groupValue = value!; + _groupValue = value! as int; }); }, ), @@ -144,7 +144,7 @@ class _ContainersListPageState extends State { groupValue: _groupValue, onChanged: (value) { setState(() { - _groupValue = value!; + _groupValue = value! as int; }); }, ), @@ -164,7 +164,7 @@ class _ContainersListPageState extends State { groupValue: _groupValue, onChanged: (value) { setState(() { - _groupValue = value!; + _groupValue = value! as int; }); }, ), diff --git a/example/lib/widgets/radiobutton/widget_radio_button.dart b/example/lib/widgets/radiobutton/widget_radio_button.dart index 88182d44..8b5123d6 100644 --- a/example/lib/widgets/radiobutton/widget_radio_button.dart +++ b/example/lib/widgets/radiobutton/widget_radio_button.dart @@ -107,7 +107,7 @@ NeumorphicRadio( value: 1991, onChanged: (value) { setState(() { - groupValue = value!; + groupValue = value! as int; }); }, padding: EdgeInsets.all(8.0), @@ -119,7 +119,7 @@ NeumorphicRadio( groupValue: groupValue, onChanged: (value) { setState(() { - groupValue = value!; + groupValue = value! as int; }); }, padding: EdgeInsets.all(8.0), @@ -131,7 +131,7 @@ NeumorphicRadio( value: 2012, onChanged: (value) { setState(() { - groupValue = value!; + groupValue = value! as int; }); }, padding: EdgeInsets.all(8.0), @@ -197,7 +197,7 @@ NeumorphicRadio( value: "A", onChanged: (value) { setState(() { - groupValue = value!; + groupValue = value! as String; }); }, padding: EdgeInsets.all(18.0), @@ -212,7 +212,7 @@ NeumorphicRadio( groupValue: groupValue, onChanged: (value) { setState(() { - groupValue = value!; + groupValue = value! as String; }); }, padding: EdgeInsets.all(18.0), @@ -227,7 +227,7 @@ NeumorphicRadio( value: "C", onChanged: (value) { setState(() { - groupValue = value!; + groupValue = value! as String; }); }, padding: EdgeInsets.all(18.0), @@ -274,7 +274,7 @@ class _EnabledDisabledWidgetState extends State<_EnabledDisabledWidget> { child: Text("First"), onChanged: (value) { setState(() { - groupValue = value!; + groupValue = value! as int; }); }, ), @@ -292,7 +292,7 @@ class _EnabledDisabledWidgetState extends State<_EnabledDisabledWidget> { child: Text("Second"), onChanged: (value) { setState(() { - groupValue = value!; + groupValue = value! as int; }); }, ), diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 5a991ce8..be7c7c6a 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -14,7 +14,7 @@ description: A new Flutter project. version: 1.0.0+1 environment: - sdk: '>=2.18.0-234.0.dev <3.0.0' + sdk: '>=2.17.0<3.0.0' dependencies: flutter: From 8914343e67a5f43c8c5fe8c676a9868d95809e31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8Flisong?= <40148554+Sulisong@users.noreply.github.com> Date: Tue, 16 Aug 2022 23:48:58 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E9=87=8D=E5=A4=8D=E7=9A=84=E6=8E=A7?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 重复的控件,导致自定义 NeumorphicStyle 无效 --- lib/src/widget/toggle.dart | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/lib/src/widget/toggle.dart b/lib/src/widget/toggle.dart index cfb560e0..a6922312 100644 --- a/lib/src/widget/toggle.dart +++ b/lib/src/widget/toggle.dart @@ -193,15 +193,7 @@ class NeumorphicToggle extends StatelessWidget { child: FractionallySizedBox( widthFactor: 1 / this.children.length, heightFactor: 1, - child: Neumorphic( - style: NeumorphicStyle( - boxShape: NeumorphicBoxShape.roundRect( - this.style?.borderRadius ?? - BorderRadius.all(Radius.circular(12))), - ), - margin: this.padding, - child: this.thumb, - ), + child: this.thumb, ), ), Row( From 037825c8bd713de815a04b322d936a2ced0bbef1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8Flisong?= <40148554+Sulisong@users.noreply.github.com> Date: Sun, 4 Sep 2022 22:54:43 +0800 Subject: [PATCH 6/7] Update slider.dart MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 解决内嵌于PageView时拖动无效 --- lib/src/widget/slider.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/widget/slider.dart b/lib/src/widget/slider.dart index 4e5a5eed..5bf0602d 100644 --- a/lib/src/widget/slider.dart +++ b/lib/src/widget/slider.dart @@ -139,7 +139,7 @@ class _NeumorphicSliderState extends State { Widget build(BuildContext context) { return LayoutBuilder(builder: (context, constraints) { return GestureDetector( - onPanUpdate: (DragUpdateDetails details) { + onHorizontalDragUpdate: (DragUpdateDetails details) { final tapPos = details.localPosition; final newPercent = tapPos.dx / constraints.maxWidth; final newValue = From 4aac4b294b759231538c7ab4bd6ee5403b2c2eda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8Flisong?= <40148554+Sulisong@users.noreply.github.com> Date: Sun, 4 Sep 2022 23:09:06 +0800 Subject: [PATCH 7/7] Update slider.dart fixs --- lib/src/widget/slider.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/widget/slider.dart b/lib/src/widget/slider.dart index 5bf0602d..54e79c4c 100644 --- a/lib/src/widget/slider.dart +++ b/lib/src/widget/slider.dart @@ -150,12 +150,12 @@ class _NeumorphicSliderState extends State { widget.onChanged!(newValue); } }, - onPanStart: (DragStartDetails details) { + onHorizontalDragStart: (DragStartDetails details) { if (widget.onChangeStart != null) { widget.onChangeStart!(widget.value); } }, - onPanEnd: (details) { + onHorizontalDragEnd: (details) { if (widget.onChangeEnd != null) { widget.onChangeEnd!(widget.value); }