From 1d2246bb0cc6d6a19161d834eb501014ff89b867 Mon Sep 17 00:00:00 2001 From: Moutia Benachour Date: Sun, 11 Sep 2022 15:37:01 +0100 Subject: [PATCH 1/9] update packages to flutter 2 --- pubspec.lock | 165 +++++++++++++++++++++++++++++---------------------- pubspec.yaml | 20 +++---- 2 files changed, 103 insertions(+), 82 deletions(-) diff --git a/pubspec.lock b/pubspec.lock index 2378cd9..922b73e 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,98 +7,91 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0-nullsafety.1" + version: "2.8.2" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.2.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.3.1" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0-nullsafety.3" - convert: - dependency: transitive - description: - name: convert - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.1" + version: "1.15.0" crypto: dependency: transitive description: name: crypto url: "https://pub.dartlang.org" source: hosted - version: "2.1.5" + version: "3.0.2" cupertino_icons: dependency: "direct main" description: name: cupertino_icons url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.0.5" equatable: dependency: transitive description: name: equatable url: "https://pub.dartlang.org" source: hosted - version: "1.2.5" + version: "2.0.5" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" ffi: dependency: transitive description: name: ffi url: "https://pub.dartlang.org" source: hosted - version: "0.1.3" + version: "1.2.1" file: dependency: transitive description: name: file url: "https://pub.dartlang.org" source: hosted - version: "5.2.1" + version: "6.1.4" fl_chart: dependency: "direct main" description: name: fl_chart url: "https://pub.dartlang.org" source: hosted - version: "0.12.0" + version: "0.55.1" flutter: dependency: "direct main" description: flutter @@ -110,21 +103,21 @@ packages: name: flutter_custom_dialog url: "https://pub.dartlang.org" source: hosted - version: "1.0.20" + version: "1.3.0" flutter_spinkit: dependency: "direct main" description: name: flutter_spinkit url: "https://pub.dartlang.org" source: hosted - version: "4.1.2+1" + version: "5.1.0" flutter_svg: dependency: "direct main" description: name: flutter_svg url: "https://pub.dartlang.org" source: hosted - version: "0.19.1" + version: "1.0.3" flutter_test: dependency: "direct dev" description: flutter @@ -141,196 +134,224 @@ packages: name: google_fonts url: "https://pub.dartlang.org" source: hosted - version: "1.1.1" + version: "3.0.1" http: dependency: "direct main" description: name: http url: "https://pub.dartlang.org" source: hosted - version: "0.12.2" + version: "0.13.5" http_parser: dependency: transitive description: name: http_parser url: "https://pub.dartlang.org" source: hosted - version: "3.1.4" - intl: + version: "4.0.1" + js: dependency: transitive description: - name: intl + name: js url: "https://pub.dartlang.org" source: hosted - version: "0.16.1" + version: "0.6.3" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10-nullsafety.1" + version: "0.12.11" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.3" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.7.0" nested: dependency: transitive description: name: nested url: "https://pub.dartlang.org" source: hosted - version: "0.0.4" + version: "1.0.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.1" + version: "1.8.0" path_drawing: dependency: transitive description: name: path_drawing url: "https://pub.dartlang.org" source: hosted - version: "0.4.1+1" + version: "1.0.1" path_parsing: dependency: transitive description: name: path_parsing url: "https://pub.dartlang.org" source: hosted - version: "0.1.4" + version: "1.0.1" path_provider: dependency: transitive description: name: path_provider url: "https://pub.dartlang.org" source: hosted - version: "1.6.24" + version: "2.0.11" + path_provider_android: + dependency: transitive + description: + name: path_provider_android + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.20" + path_provider_ios: + dependency: transitive + description: + name: path_provider_ios + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.11" path_provider_linux: dependency: transitive description: name: path_provider_linux url: "https://pub.dartlang.org" source: hosted - version: "0.0.1+2" + version: "2.1.7" path_provider_macos: dependency: transitive description: name: path_provider_macos url: "https://pub.dartlang.org" source: hosted - version: "0.0.4+6" + version: "2.0.6" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "2.0.4" path_provider_windows: dependency: transitive description: name: path_provider_windows url: "https://pub.dartlang.org" source: hosted - version: "0.0.4+3" - pedantic: - dependency: transitive - description: - name: pedantic - url: "https://pub.dartlang.org" - source: hosted - version: "1.9.2" + version: "2.0.7" petitparser: dependency: transitive description: name: petitparser url: "https://pub.dartlang.org" source: hosted - version: "3.1.0" + version: "4.4.0" pin_code_fields: dependency: "direct main" description: name: pin_code_fields url: "https://pub.dartlang.org" source: hosted - version: "6.0.1" + version: "7.4.0" platform: dependency: transitive description: name: platform url: "https://pub.dartlang.org" source: hosted - version: "2.2.1" + version: "3.1.0" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.3" + version: "2.1.2" process: dependency: transitive description: name: process url: "https://pub.dartlang.org" source: hosted - version: "3.0.13" + version: "4.2.4" provider: dependency: "direct main" description: name: provider url: "https://pub.dartlang.org" source: hosted - version: "4.3.2+2" + version: "6.0.3" shared_preferences: dependency: "direct main" description: name: shared_preferences url: "https://pub.dartlang.org" source: hosted - version: "0.5.12+4" + version: "2.0.15" + shared_preferences_android: + dependency: transitive + description: + name: shared_preferences_android + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.13" + shared_preferences_ios: + dependency: transitive + description: + name: shared_preferences_ios + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.1" shared_preferences_linux: dependency: transitive description: name: shared_preferences_linux url: "https://pub.dartlang.org" source: hosted - version: "0.0.2+4" + version: "2.1.1" shared_preferences_macos: dependency: transitive description: name: shared_preferences_macos url: "https://pub.dartlang.org" source: hosted - version: "0.0.1+11" + version: "2.0.4" shared_preferences_platform_interface: dependency: transitive description: name: shared_preferences_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "2.1.0" shared_preferences_web: dependency: transitive description: name: shared_preferences_web url: "https://pub.dartlang.org" source: hosted - version: "0.1.2+7" + version: "2.0.4" shared_preferences_windows: dependency: transitive description: name: shared_preferences_windows url: "https://pub.dartlang.org" source: hosted - version: "0.0.1+3" + version: "2.1.1" sky_engine: dependency: transitive description: flutter @@ -342,77 +363,77 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.2" + version: "1.8.1" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.1" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19-nullsafety.2" + version: "0.4.8" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.1" win32: dependency: transitive description: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "1.7.4" + version: "2.5.2" xdg_directories: dependency: transitive description: name: xdg_directories url: "https://pub.dartlang.org" source: hosted - version: "0.1.2" + version: "0.2.0+2" xml: dependency: transitive description: name: xml url: "https://pub.dartlang.org" source: hosted - version: "4.5.1" + version: "5.3.1" sdks: - dart: ">=2.10.0-110 <2.11.0" - flutter: ">=1.22.0 <2.0.0" + dart: ">=2.16.2 <3.0.0" + flutter: ">=2.10.0" diff --git a/pubspec.yaml b/pubspec.yaml index 898019a..d931dec 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: ">=2.7.0 <3.0.0" + sdk: ">=2.16.2 <3.0.0" dependencies: flutter: @@ -28,15 +28,15 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.0 - provider: ^4.3.2+2 - http: ^0.12.2 - shared_preferences: ^0.5.12+4 - flutter_spinkit: ^4.1.2+1 - pin_code_fields: ^6.0.1 - flutter_svg: ^0.19.1 - google_fonts: ^1.1.1 - fl_chart: ^0.12.0 - flutter_custom_dialog: ^1.0.20 + provider: ^6.0.3 + http: ^0.13.5 + shared_preferences: ^2.0.15 + flutter_spinkit: ^5.1.0 + pin_code_fields: ^7.4.0 + flutter_svg: ^1.0.3 + google_fonts: ^3.0.1 + fl_chart: ^0.55.1 + flutter_custom_dialog: ^1.3.0 dev_dependencies: flutter_test: sdk: flutter -- 2.43.5 From febec8a45533764d9519305ab5d4f98aadc3b049 Mon Sep 17 00:00:00 2001 From: Moutia Benachour Date: Sun, 11 Sep 2022 15:36:52 +0100 Subject: [PATCH 2/9] update android build config --- android/app/build.gradle | 8 ++------ android/app/src/main/AndroidManifest.xml | 3 ++- android/build.gradle | 8 ++++---- android/gradle/wrapper/gradle-wrapper.properties | 2 +- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 7cb2de9..eee4366 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -26,20 +26,16 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 29 + compileSdkVersion 31 sourceSets { main.java.srcDirs += 'src/main/kotlin' } - lintOptions { - disable 'InvalidPackage' - } - defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.example.robo_advisory" - minSdkVersion 16 + minSdkVersion 20 targetSdkVersion 29 versionCode flutterVersionCode.toInteger() versionName flutterVersionName diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 4f6dda2..bc1e8ab 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -6,11 +6,12 @@ additional functionality it is fine to subclass or reimplement FlutterApplication and put your custom class here. --> Date: Sun, 11 Sep 2022 15:37:28 +0100 Subject: [PATCH 3/9] update dart code --- lib/injection/dependency_injection.dart | 2 +- lib/models/expenses.dart | 6 +- lib/models/healthSteam.dart | 10 +- lib/models/transaction.dart | 9 +- lib/models/user.dart | 8 +- lib/models/wallet.dart | 28 ++++-- lib/providers/auth_provider.dart | 2 +- lib/providers/transaction_provider.dart | 24 ++--- lib/providers/user_provider.dart | 2 +- lib/providers/wallet_provider.dart | 2 +- lib/screens/dashboard/dashboard.dart | 2 +- .../local_widgets/bottom_navigation.dart | 4 +- lib/screens/history/history.dart | 27 +++--- .../local_widgets/transaction_list_tile.dart | 4 +- lib/screens/home/home.dart | 8 +- .../home/local_widgets/expenses_chart.dart | 95 +++++++------------ .../financial_health_stream.dart | 2 +- lib/screens/login.dart | 1 + lib/screens/register/register_step_1.dart | 2 + lib/utils/constants.dart | 2 +- lib/utils/size_config.dart | 60 ++++++------ lib/widgets/drawer.dart | 3 +- 22 files changed, 151 insertions(+), 152 deletions(-) diff --git a/lib/injection/dependency_injection.dart b/lib/injection/dependency_injection.dart index 344cd4b..ab29544 100644 --- a/lib/injection/dependency_injection.dart +++ b/lib/injection/dependency_injection.dart @@ -1,7 +1,7 @@ enum Flavor { MOCK, PRO } class Injector { - static Flavor _flavor; + static late Flavor _flavor; static void configure(Flavor flavor) { _flavor = flavor; diff --git a/lib/models/expenses.dart b/lib/models/expenses.dart index b30f3c3..dab2d01 100644 --- a/lib/models/expenses.dart +++ b/lib/models/expenses.dart @@ -3,8 +3,8 @@ class Expenses { String amount; String percentage; Expenses({ - this.type, - this.amount, - this.percentage, + required this.type, + required this.amount, + required this.percentage, }); } diff --git a/lib/models/healthSteam.dart b/lib/models/healthSteam.dart index 373d02a..e660931 100644 --- a/lib/models/healthSteam.dart +++ b/lib/models/healthSteam.dart @@ -6,11 +6,11 @@ class HealthSteam { String oneGramGoldPriceInLira; HealthSteam({ - this.type, - this.valueInPercentage, - this.goldInGram, - this.goldPriceInTurkishLira, - this.oneGramGoldPriceInLira, + required this.type, + required this.valueInPercentage, + required this.goldInGram, + required this.goldPriceInTurkishLira, + required this.oneGramGoldPriceInLira, }); HealthSteam.fromJson(Map map) diff --git a/lib/models/transaction.dart b/lib/models/transaction.dart index 1cef5d3..7afa0d1 100644 --- a/lib/models/transaction.dart +++ b/lib/models/transaction.dart @@ -1,7 +1,8 @@ class Category { String name; String color; - Category({this.name, this.color}); + + Category({required this.name, required this.color}); Category.formJson(Map map) : name = map["name"], @@ -16,7 +17,11 @@ class Transaction { Category category; Transaction( - {this.amount, this.description, this.date, this.name, this.category}); + {required this.amount, + required this.description, + required this.date, + required this.name, + required this.category}); Transaction.fromJson(Map map) : category = Category.formJson(map["category"]), diff --git a/lib/models/user.dart b/lib/models/user.dart index 525ac73..2806bd7 100644 --- a/lib/models/user.dart +++ b/lib/models/user.dart @@ -4,5 +4,11 @@ class User { String email; String token; - User({this.userId, this.name, this.email, this.token}); + static final User noUser = User(userId: 0, name: '', email: '', token: ''); + + User( + {required this.userId, + required this.name, + required this.email, + required this.token}); } diff --git a/lib/models/wallet.dart b/lib/models/wallet.dart index 51eed9f..9a0c69a 100644 --- a/lib/models/wallet.dart +++ b/lib/models/wallet.dart @@ -11,14 +11,16 @@ class Wallet { List healthStreams; List expensesChart; + static final Wallet emptyWallet = Wallet._empty(); + Wallet({ - this.totalAssets, - this.totalTurkishLiraPool, - this.totalGoldInGram, - this.totalGoldInTurkishLira, - this.healthSteamDay, - this.healthStreams, - this.expensesChart, + required this.totalAssets, + required this.totalTurkishLiraPool, + required this.totalGoldInGram, + required this.totalGoldInTurkishLira, + required this.healthSteamDay, + required this.healthStreams, + required this.expensesChart, }); Wallet.fromMap(Map map) @@ -29,5 +31,15 @@ class Wallet { healthSteamDay = map["health_stream_day"], healthStreams = (map["health_stream"] as List) .map((i) => HealthSteam.fromJson(i)) - .toList(); + .toList(), + expensesChart = []; + + Wallet._empty(): + totalAssets = '', + totalTurkishLiraPool = '', + totalGoldInGram = '', + totalGoldInTurkishLira = '', + healthSteamDay = '', + healthStreams = [], + expensesChart = []; } diff --git a/lib/providers/auth_provider.dart b/lib/providers/auth_provider.dart index e54906d..f7d2ccd 100644 --- a/lib/providers/auth_provider.dart +++ b/lib/providers/auth_provider.dart @@ -18,7 +18,7 @@ class AuthProvider with ChangeNotifier { Status get loggedInStatus => _loggedInStatus; Status get registeredInStatus => _registeredInStatus; - Future> login(String email, int pinCode) async { + Future login(String email, int pinCode) async { var result; final Map loginData = { diff --git a/lib/providers/transaction_provider.dart b/lib/providers/transaction_provider.dart index cdc9e94..9349877 100644 --- a/lib/providers/transaction_provider.dart +++ b/lib/providers/transaction_provider.dart @@ -3,32 +3,28 @@ import 'package:robo_advisory/models/transaction.dart'; import 'package:robo_advisory/repository/transaction.repository.dart'; class TransactionProvider with ChangeNotifier { - String _selectedCategory = "All"; - List _transactionsData; - List _transactionsList; + String? _selectedCategory; + List _transactionsData = []; List get transactionList { - if (_selectedCategory != 'All') { - return _transactionsList = _transactionsData - .where((transaction) => - transaction.category.name == _selectedCategory.toLowerCase()) - .toList(); - } else { - return _transactionsList = _transactionsData; + if (_selectedCategory == null) { + return _transactionsData; } + return _transactionsData + .where((transaction) => + transaction.category.name == _selectedCategory?.toLowerCase()) + .toList(); } void setTransactionsList(List transactions) { _transactionsData = transactions; - _transactionsList = transactions; notifyListeners(); } - String get selectedCategory => _selectedCategory; + String? get selectedCategory => _selectedCategory; - void setSelectedCategory(String category) { + void setSelectedCategory(String? category) { _selectedCategory = category; - print(_selectedCategory); notifyListeners(); } diff --git a/lib/providers/user_provider.dart b/lib/providers/user_provider.dart index dff068a..45d8daf 100644 --- a/lib/providers/user_provider.dart +++ b/lib/providers/user_provider.dart @@ -2,7 +2,7 @@ import 'package:flutter/foundation.dart'; import 'package:robo_advisory/models/user.dart'; class UserProvider with ChangeNotifier { - User _user = new User(); + User _user = User.noUser; int _selectedTabIndex = 0; List _categories = ["All", "Workplace", "Equipment", "Home", "Other"]; diff --git a/lib/providers/wallet_provider.dart b/lib/providers/wallet_provider.dart index 8320eab..4eea9d4 100644 --- a/lib/providers/wallet_provider.dart +++ b/lib/providers/wallet_provider.dart @@ -3,7 +3,7 @@ import 'package:robo_advisory/models/wallet.dart'; import 'package:robo_advisory/repository/wallet.repository.dart'; class WalletProvider with ChangeNotifier { - Wallet _wallet = new Wallet(); + Wallet _wallet = Wallet.emptyWallet; Wallet get wallet => _wallet; diff --git a/lib/screens/dashboard/dashboard.dart b/lib/screens/dashboard/dashboard.dart index 404955a..7cbde88 100644 --- a/lib/screens/dashboard/dashboard.dart +++ b/lib/screens/dashboard/dashboard.dart @@ -17,7 +17,7 @@ class _DashboardScreenState extends State { final GlobalKey _scaffoldKey = GlobalKey(); void _openEndDrawer() { - _scaffoldKey.currentState.openEndDrawer(); + _scaffoldKey.currentState?.openEndDrawer(); } @override diff --git a/lib/screens/dashboard/local_widgets/bottom_navigation.dart b/lib/screens/dashboard/local_widgets/bottom_navigation.dart index c2b60c1..99f2fba 100644 --- a/lib/screens/dashboard/local_widgets/bottom_navigation.dart +++ b/lib/screens/dashboard/local_widgets/bottom_navigation.dart @@ -3,7 +3,7 @@ import 'package:robo_advisory/theme/icons.dart'; import 'package:flutter_svg/flutter_svg.dart'; class BottomNavigation extends StatelessWidget { - BottomNavigation({@required this.selectedIndex, @required this.onItemTapped}); + BottomNavigation({required this.selectedIndex, required this.onItemTapped}); final int selectedIndex; final Function onItemTapped; @override @@ -48,7 +48,7 @@ class BottomNavigation extends StatelessWidget { showSelectedLabels: false, showUnselectedLabels: false, currentIndex: selectedIndex, - onTap: onItemTapped, + onTap: (v) => onItemTapped(v), ); } } diff --git a/lib/screens/history/history.dart b/lib/screens/history/history.dart index e62ba63..b09ebcb 100644 --- a/lib/screens/history/history.dart +++ b/lib/screens/history/history.dart @@ -17,24 +17,20 @@ class HistoryScreen extends StatefulWidget { class _HistoryScreenState extends State { bool loadingData = true; - List transactionData; + List transactionData = []; void initState() { TransactionProvider transactionProvider = Provider.of(context, listen: false); transactionProvider.loadTransactions().then((value) { - if (value != null) { - Timer(Duration(seconds: 3), () { - setState(() { - loadingData = false; - transactionData = value; - Provider.of(context, listen: false) - .setTransactionsList(transactionData); - }); + Timer(Duration(seconds: 3), () { + setState(() { + loadingData = false; + transactionData = value; + Provider.of(context, listen: false) + .setTransactionsList(transactionData); }); - } - - print(value); + }); }); super.initState(); } @@ -71,9 +67,10 @@ class _HistoryScreenState extends State { }).toList(), hint: new Text("Select Category"), value: Provider.of(context, - listen: true) - .selectedCategory, - onChanged: (String newValue) { + listen: true) + .selectedCategory ?? + 'All', + onChanged: (String? newValue) { Provider.of(context, listen: false) .setSelectedCategory(newValue); diff --git a/lib/screens/history/local_widgets/transaction_list_tile.dart b/lib/screens/history/local_widgets/transaction_list_tile.dart index 882189f..f58eb5d 100644 --- a/lib/screens/history/local_widgets/transaction_list_tile.dart +++ b/lib/screens/history/local_widgets/transaction_list_tile.dart @@ -4,7 +4,9 @@ import 'package:robo_advisory/utils/helpers.dart'; class TransactionListTile extends StatelessWidget { final Transaction transactionObject; - TransactionListTile({this.transactionObject}); + + TransactionListTile({required this.transactionObject}); + @override Widget build(BuildContext context) { return Column( diff --git a/lib/screens/home/home.dart b/lib/screens/home/home.dart index 14170fd..2721591 100644 --- a/lib/screens/home/home.dart +++ b/lib/screens/home/home.dart @@ -12,7 +12,7 @@ import 'package:robo_advisory/screens/home/local_widgets/expenses_chart.dart'; import 'dart:async'; class HomeScreen extends StatefulWidget { - HomeScreen({@required this.toggleDrawer}); + HomeScreen({required this.toggleDrawer}); final Function toggleDrawer; @override _HomeScreenState createState() => _HomeScreenState(); @@ -20,13 +20,13 @@ class HomeScreen extends StatefulWidget { class _HomeScreenState extends State { bool loadingData = true; - Wallet walletData; + Wallet walletData = Wallet.emptyWallet; void initState() { WalletProvider walletProvider = Provider.of(context, listen: false); walletProvider.loadWallet().then((value) { - if (value.totalAssets != null) { + if (value.totalAssets.isNotEmpty) { Timer(Duration(seconds: 3), () { setState(() { loadingData = false; @@ -70,7 +70,7 @@ class _HomeScreenState extends State { ), ), GestureDetector( - onTap: widget.toggleDrawer, + onTap: () => widget.toggleDrawer(), child: Icon(Icons.more_vert), ), ], diff --git a/lib/screens/home/local_widgets/expenses_chart.dart b/lib/screens/home/local_widgets/expenses_chart.dart index 2db1054..4cef78e 100644 --- a/lib/screens/home/local_widgets/expenses_chart.dart +++ b/lib/screens/home/local_widgets/expenses_chart.dart @@ -10,7 +10,7 @@ class ExpensesChart extends StatefulWidget { } class ExpensesChartState extends State { - int touchedIndex; + int? touchedIndex; @override Widget build(BuildContext context) { @@ -21,18 +21,22 @@ class ExpensesChartState extends State { Expanded( child: PieChart( PieChartData( - pieTouchData: PieTouchData(touchCallback: (pieTouchResponse) { + pieTouchData: + PieTouchData(touchCallback: (event, pieTouchResponse) { + if (pieTouchResponse == null) return; + setState(() { - if (pieTouchResponse.touchInput is FlLongPressEnd || - pieTouchResponse.touchInput is FlPanEnd) { + if (event is FlLongPressEnd || event is FlPanEndEvent) { touchedIndex = -1; } else { - touchedIndex = pieTouchResponse.touchedSectionIndex; + touchedIndex = + pieTouchResponse.touchedSection?.touchedSectionIndex; + if (touchedIndex != null) { Provider.of(context, listen: false) .setSelectedTabIndex(3); Provider.of(context, listen: false) - .setSelectedCategory(categories[touchedIndex + 1]); + .setSelectedCategory(categories[touchedIndex! + 1]); } } }); @@ -50,58 +54,31 @@ class ExpensesChartState extends State { } List showingSections() { - return List.generate(4, (i) { - final isTouched = i == touchedIndex; - final double fontSize = isTouched ? 25 : 16; - final double radius = isTouched ? 60 : 50; - switch (i) { - case 0: - return PieChartSectionData( - color: const Color(0xff0293ee), - value: 50, - title: '50%', - radius: radius, - titleStyle: TextStyle( - fontSize: fontSize, - fontWeight: FontWeight.bold, - color: const Color(0xffffffff)), - ); - case 1: - return PieChartSectionData( - color: const Color(0xfff8b250), - value: 12, - title: '12%', - radius: radius, - titleStyle: TextStyle( - fontSize: fontSize, - fontWeight: FontWeight.bold, - color: const Color(0xffffffff)), - ); - case 2: - return PieChartSectionData( - color: const Color(0xff13d38e), - value: 13, - title: '13%', - radius: radius, - titleStyle: TextStyle( - fontSize: fontSize, - fontWeight: FontWeight.bold, - color: const Color(0xffffffff)), - ); - case 3: - return PieChartSectionData( - color: const Color(0xff845bef), - value: 25, - title: '25%', - radius: radius, - titleStyle: TextStyle( - fontSize: fontSize, - fontWeight: FontWeight.bold, - color: const Color(0xffffffff)), - ); - default: - return null; - } - }); + final colorsDict = [0xff0293ee, 0xfff8b250, 0xff13d38e, 0xff845bef]; + final values = [50.0, 12.0, 13.0, 25.0]; + + return values + .asMap() + .entries + .map((entry) => _pieChartSectionData( + colorsDict[entry.key], entry.value, touchedIndex == entry.key)) + .toList(); + } + + PieChartSectionData _pieChartSectionData( + int color, double value, bool isTouched) { + final double fontSize = isTouched ? 25 : 16; + final double radius = isTouched ? 60 : 50; + + return PieChartSectionData( + color: Color(color), + value: value, + title: value.toString() + '%', + radius: radius, + titleStyle: TextStyle( + fontSize: fontSize, + fontWeight: FontWeight.bold, + color: const Color(0xffffffff)), + ); } } diff --git a/lib/screens/home/local_widgets/financial_health_stream.dart b/lib/screens/home/local_widgets/financial_health_stream.dart index a9343b0..996772d 100644 --- a/lib/screens/home/local_widgets/financial_health_stream.dart +++ b/lib/screens/home/local_widgets/financial_health_stream.dart @@ -4,7 +4,7 @@ import 'package:google_fonts/google_fonts.dart'; import 'package:flutter_custom_dialog/flutter_custom_dialog.dart'; class FinancialHealthStream extends StatelessWidget { - FinancialHealthStream({@required this.healthSteams}); + FinancialHealthStream({required this.healthSteams}); final List healthSteams; double calculatePercentage(double fullWidth, int percentValue) { diff --git a/lib/screens/login.dart b/lib/screens/login.dart index 68d3110..7a6dfc7 100644 --- a/lib/screens/login.dart +++ b/lib/screens/login.dart @@ -76,6 +76,7 @@ class LoginScreen extends StatelessWidget { Padding( padding: EdgeInsets.only(left: 10.0, right: 10.0), child: PinCodeTextField( + appContext: context, length: 5, cursorColor: Colors.black, animationType: AnimationType.fade, diff --git a/lib/screens/register/register_step_1.dart b/lib/screens/register/register_step_1.dart index 44ce38e..037f417 100644 --- a/lib/screens/register/register_step_1.dart +++ b/lib/screens/register/register_step_1.dart @@ -44,6 +44,7 @@ class RegisterFirstScreen extends StatelessWidget { Padding( padding: EdgeInsets.only(left: 10.0, right: 10.0), child: PinCodeTextField( + appContext: context, length: 5, cursorColor: Colors.black, backgroundColor: Colors.white, @@ -75,6 +76,7 @@ class RegisterFirstScreen extends StatelessWidget { scale: 0.8, child: Switch( value: false, + onChanged: (_) {}, ), ), Text('Remember me') diff --git a/lib/utils/constants.dart b/lib/utils/constants.dart index 1ea2c38..05aed2f 100644 --- a/lib/utils/constants.dart +++ b/lib/utils/constants.dart @@ -14,7 +14,7 @@ final otpPinTheme = PinTheme( fieldWidth: 50, ); -InputDecoration roboInputDecoration({String placeholderHint}) { +InputDecoration roboInputDecoration({String? placeholderHint}) { return InputDecoration( filled: true, fillColor: Colors.white, diff --git a/lib/utils/size_config.dart b/lib/utils/size_config.dart index f0adefb..add18de 100644 --- a/lib/utils/size_config.dart +++ b/lib/utils/size_config.dart @@ -1,30 +1,30 @@ -import 'package:flutter/material.dart'; - -class SizeConfig { - static MediaQueryData _mediaQueryData; - static double screenWidth; - static double screenHeight; - static double defaultSize; - static Orientation orientation; - - void init(BuildContext context) { - _mediaQueryData = MediaQuery.of(context); - screenWidth = _mediaQueryData.size.width; - screenHeight = _mediaQueryData.size.height; - orientation = _mediaQueryData.orientation; - } -} - -// Get the proportionate height as per screen size -double getProportionateScreenHeight(double inputHeight) { - double screenHeight = SizeConfig.screenHeight; - // 812 is the layout height that designer use - return (inputHeight / 812.0) * screenHeight; -} - -// Get the proportionate height as per screen size -double getProportionateScreenWidth(double inputWidth) { - double screenWidth = SizeConfig.screenWidth; - // 375 is the layout width that designer use - return (inputWidth / 375.0) * screenWidth; -} +// import 'package:flutter/material.dart'; +// +// class SizeConfig { +// static MediaQueryData _mediaQueryData; +// static double screenWidth; +// static double screenHeight; +// static double defaultSize; +// static Orientation orientation; +// +// void init(BuildContext context) { +// _mediaQueryData = MediaQuery.of(context); +// screenWidth = _mediaQueryData.size.width; +// screenHeight = _mediaQueryData.size.height; +// orientation = _mediaQueryData.orientation; +// } +// } +// +// // Get the proportionate height as per screen size +// double getProportionateScreenHeight(double inputHeight) { +// double screenHeight = SizeConfig.screenHeight; +// // 812 is the layout height that designer use +// return (inputHeight / 812.0) * screenHeight; +// } +// +// // Get the proportionate height as per screen size +// double getProportionateScreenWidth(double inputWidth) { +// double screenWidth = SizeConfig.screenWidth; +// // 375 is the layout width that designer use +// return (inputWidth / 375.0) * screenWidth; +// } diff --git a/lib/widgets/drawer.dart b/lib/widgets/drawer.dart index cd16fa4..61e8708 100644 --- a/lib/widgets/drawer.dart +++ b/lib/widgets/drawer.dart @@ -46,6 +46,7 @@ class AppDrawer extends StatelessWidget { _createDrawerItem( icon: accountIcon, text: 'Account', + onTap: () {}, ), _createDrawerItem( icon: logoutIcon, @@ -125,7 +126,7 @@ class AppDrawer extends StatelessWidget { } Widget _createDrawerItem( - {String icon, String text, GestureTapCallback onTap}) { + {required String icon, required String text, required GestureTapCallback onTap}) { return ListTile( title: Row( children: [ -- 2.43.5 From 355b3cb4efe4ed5757b271bd0ee4745b647afb3a Mon Sep 17 00:00:00 2001 From: Moutia Benachour Date: Sun, 11 Sep 2022 16:20:00 +0100 Subject: [PATCH 4/9] fix pie chart limits --- lib/screens/home/home.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/screens/home/home.dart b/lib/screens/home/home.dart index 2721591..0328079 100644 --- a/lib/screens/home/home.dart +++ b/lib/screens/home/home.dart @@ -247,7 +247,7 @@ class _HomeScreenState extends State { SizedBox( height: 20.0, ), - ExpensesChart() + Container(height: 200, width: 200, child: ExpensesChart()) ], ) ], -- 2.43.5 From 35a2d8ccdb04a0bb297579eb240fb3e9c92938e7 Mon Sep 17 00:00:00 2001 From: Moutia Benachour Date: Sun, 11 Sep 2022 16:21:04 +0100 Subject: [PATCH 5/9] fix setState after disposed item --- lib/screens/home/local_widgets/expenses_chart.dart | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/screens/home/local_widgets/expenses_chart.dart b/lib/screens/home/local_widgets/expenses_chart.dart index 4cef78e..4b89f69 100644 --- a/lib/screens/home/local_widgets/expenses_chart.dart +++ b/lib/screens/home/local_widgets/expenses_chart.dart @@ -12,6 +12,14 @@ class ExpensesChart extends StatefulWidget { class ExpensesChartState extends State { int? touchedIndex; + bool disposed = false; + + @override + void dispose() { + disposed = true; + super.dispose(); + } + @override Widget build(BuildContext context) { List categories = @@ -24,6 +32,7 @@ class ExpensesChartState extends State { pieTouchData: PieTouchData(touchCallback: (event, pieTouchResponse) { if (pieTouchResponse == null) return; + if (disposed) return; setState(() { if (event is FlLongPressEnd || event is FlPanEndEvent) { -- 2.43.5 From 4fab441eeda3d5374b3dbe0536bbd5a23b407c5e Mon Sep 17 00:00:00 2001 From: Moutia Benachour Date: Sun, 11 Sep 2022 16:41:08 +0100 Subject: [PATCH 6/9] upgrade packages for flutter 3 --- pubspec.lock | 47 ++++++++++++++++++++--------------------------- pubspec.yaml | 2 +- 2 files changed, 21 insertions(+), 28 deletions(-) diff --git a/pubspec.lock b/pubspec.lock index 922b73e..4805836 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.8.2" + version: "2.9.0" boolean_selector: dependency: transitive description: @@ -21,28 +21,21 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.1" + version: "1.2.1" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" + version: "1.16.0" crypto: dependency: transitive description: @@ -70,7 +63,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.1" ffi: dependency: transitive description: @@ -117,7 +110,7 @@ packages: name: flutter_svg url: "https://pub.dartlang.org" source: hosted - version: "1.0.3" + version: "1.1.5" flutter_test: dependency: "direct dev" description: flutter @@ -155,28 +148,28 @@ packages: name: js url: "https://pub.dartlang.org" source: hosted - version: "0.6.3" + version: "0.6.4" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.11" + version: "0.12.12" material_color_utilities: dependency: transitive description: name: material_color_utilities url: "https://pub.dartlang.org" source: hosted - version: "0.1.3" + version: "0.1.5" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0" nested: dependency: transitive description: @@ -190,7 +183,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.2" path_drawing: dependency: transitive description: @@ -260,7 +253,7 @@ packages: name: petitparser url: "https://pub.dartlang.org" source: hosted - version: "4.4.0" + version: "5.0.0" pin_code_fields: dependency: "direct main" description: @@ -363,7 +356,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.9.0" stack_trace: dependency: transitive description: @@ -384,21 +377,21 @@ packages: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.8" + version: "0.4.12" typed_data: dependency: transitive description: @@ -412,7 +405,7 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.2" win32: dependency: transitive description: @@ -433,7 +426,7 @@ packages: name: xml url: "https://pub.dartlang.org" source: hosted - version: "5.3.1" + version: "6.1.0" sdks: - dart: ">=2.16.2 <3.0.0" - flutter: ">=2.10.0" + dart: ">=2.17.0 <3.0.0" + flutter: ">=2.11.0-0.1.pre" diff --git a/pubspec.yaml b/pubspec.yaml index d931dec..bf2b159 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -33,7 +33,7 @@ dependencies: shared_preferences: ^2.0.15 flutter_spinkit: ^5.1.0 pin_code_fields: ^7.4.0 - flutter_svg: ^1.0.3 + flutter_svg: ^1.1.5 google_fonts: ^3.0.1 fl_chart: ^0.55.1 flutter_custom_dialog: ^1.3.0 -- 2.43.5 From a6a5660fc4bd14342be250813e44449a71912143 Mon Sep 17 00:00:00 2001 From: Moutia Benachour Date: Sun, 11 Sep 2022 17:10:24 +0100 Subject: [PATCH 7/9] upgrade to flutter 3 --- lib/screens/login.dart | 24 +++++++++++------------ lib/screens/register/register_step_1.dart | 17 +++++++++------- lib/screens/register/register_step_2.dart | 16 ++++++++------- 3 files changed, 30 insertions(+), 27 deletions(-) diff --git a/lib/screens/login.dart b/lib/screens/login.dart index 7a6dfc7..480b49b 100644 --- a/lib/screens/login.dart +++ b/lib/screens/login.dart @@ -21,9 +21,7 @@ class LoginScreen extends StatelessWidget { Expanded( child: Container( child: Center( - child: FlatButton( - splashColor: Colors.transparent, - highlightColor: Colors.transparent, + child: TextButton( onPressed: () { Navigator.pushNamed(context, Routes.register); }, @@ -110,9 +108,7 @@ class LoginScreen extends StatelessWidget { // activeTrackColor: Colors.white, // activeColor: Colors.white, ), - FlatButton( - splashColor: Colors.transparent, - highlightColor: Colors.transparent, + TextButton( onPressed: () { Navigator.pushNamed( context, Routes.splashScreen); @@ -126,17 +122,19 @@ class LoginScreen extends StatelessWidget { ), SizedBox( width: double.infinity, - child: RaisedButton( - color: Color(0xFF495057), - textColor: Colors.white, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + padding: EdgeInsets.all(18.0), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(18.0), + ), + backgroundColor:Color(0xFF495057), + foregroundColor: Colors.white, + ), onPressed: () { Navigator.pushNamed(context, Routes.dashboard); }, child: Text('Log In'), - padding: EdgeInsets.all(18.0), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(18.0), - ), ), ) ], diff --git a/lib/screens/register/register_step_1.dart b/lib/screens/register/register_step_1.dart index 037f417..a882fb4 100644 --- a/lib/screens/register/register_step_1.dart +++ b/lib/screens/register/register_step_1.dart @@ -89,9 +89,16 @@ class RegisterFirstScreen extends StatelessWidget { ), SizedBox( width: double.infinity, - child: RaisedButton( - color: Color(0xFF495057), - textColor: Colors.white, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Color(0xFF495057), + foregroundColor: Colors.white, + padding: EdgeInsets.all(18.0), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(18.0), + ), + ), + onPressed: () { Navigator.push( context, @@ -103,10 +110,6 @@ class RegisterFirstScreen extends StatelessWidget { ); }, child: Text('Continue'), - padding: EdgeInsets.all(18.0), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(18.0), - ), ), ) ], diff --git a/lib/screens/register/register_step_2.dart b/lib/screens/register/register_step_2.dart index 97a4b53..034c99c 100644 --- a/lib/screens/register/register_step_2.dart +++ b/lib/screens/register/register_step_2.dart @@ -56,18 +56,20 @@ class RegisterSecondScreen extends StatelessWidget { ), SizedBox( width: double.infinity, - child: RaisedButton( - color: Color(0xFF495057), - textColor: Colors.white, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Color(0xFF495057), + foregroundColor: Colors.white, + padding: EdgeInsets.all(18.0), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(18.0), + ), + ), onPressed: () { Navigator.pushNamed(context, Routes.dashboard); print('Next Step'); }, child: Text('Register'), - padding: EdgeInsets.all(18.0), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(18.0), - ), ), ) ], -- 2.43.5 From 3baa33a838b2124296d1467539432646724f0c85 Mon Sep 17 00:00:00 2001 From: Moutia Benachour Date: Sun, 11 Sep 2022 17:10:44 +0100 Subject: [PATCH 8/9] fix transaction filter --- lib/providers/user_provider.dart | 2 +- lib/screens/history/history.dart | 25 +++++++++++++++---------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/lib/providers/user_provider.dart b/lib/providers/user_provider.dart index 45d8daf..b24cbde 100644 --- a/lib/providers/user_provider.dart +++ b/lib/providers/user_provider.dart @@ -5,7 +5,7 @@ class UserProvider with ChangeNotifier { User _user = User.noUser; int _selectedTabIndex = 0; - List _categories = ["All", "Workplace", "Equipment", "Home", "Other"]; + List _categories = ["Workplace", "Equipment", "Home", "Other"]; List get categories => _categories; diff --git a/lib/screens/history/history.dart b/lib/screens/history/history.dart index b09ebcb..a187b28 100644 --- a/lib/screens/history/history.dart +++ b/lib/screens/history/history.dart @@ -57,19 +57,24 @@ class _HistoryScreenState extends State { children: [ DropdownButton( isExpanded: true, - items: Provider.of(context, listen: true) - .categories - .map((String value) { - return DropdownMenuItem( - value: value, - child: Text(value), - ); - }).toList(), + items: [ + DropdownMenuItem( + value: null, + child: Text('All'), + ), + ...Provider.of(context, listen: true) + .categories + .map((String value) { + return DropdownMenuItem( + value: value, + child: Text(value), + ); + }) + ], hint: new Text("Select Category"), value: Provider.of(context, listen: true) - .selectedCategory ?? - 'All', + .selectedCategory, onChanged: (String? newValue) { Provider.of(context, listen: false) -- 2.43.5 From 0637bd0d4ddf2d31c0ae3adcb9323a4fe57bdd19 Mon Sep 17 00:00:00 2001 From: Moutia Benachour Date: Sun, 11 Sep 2022 17:18:42 +0100 Subject: [PATCH 9/9] extract button styles --- lib/screens/login.dart | 12 +++--------- lib/screens/register/register_step_1.dart | 11 ++--------- lib/screens/register/register_step_2.dart | 10 ++-------- lib/widgets/buttons.dart | 11 +++++++++++ 4 files changed, 18 insertions(+), 26 deletions(-) create mode 100644 lib/widgets/buttons.dart diff --git a/lib/screens/login.dart b/lib/screens/login.dart index 480b49b..b1fd39d 100644 --- a/lib/screens/login.dart +++ b/lib/screens/login.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:pin_code_fields/pin_code_fields.dart'; import 'package:robo_advisory/utils/constants.dart'; import 'package:robo_advisory/config/Routes.dart'; +import 'package:robo_advisory/widgets/buttons.dart'; class LoginScreen extends StatelessWidget { bool rememberSwitch = false; @@ -21,7 +22,7 @@ class LoginScreen extends StatelessWidget { Expanded( child: Container( child: Center( - child: TextButton( + child: ElevatedButton( onPressed: () { Navigator.pushNamed(context, Routes.register); }, @@ -123,14 +124,7 @@ class LoginScreen extends StatelessWidget { SizedBox( width: double.infinity, child: ElevatedButton( - style: ElevatedButton.styleFrom( - padding: EdgeInsets.all(18.0), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(18.0), - ), - backgroundColor:Color(0xFF495057), - foregroundColor: Colors.white, - ), + style: mainButtonStyle(), onPressed: () { Navigator.pushNamed(context, Routes.dashboard); }, diff --git a/lib/screens/register/register_step_1.dart b/lib/screens/register/register_step_1.dart index a882fb4..9f10120 100644 --- a/lib/screens/register/register_step_1.dart +++ b/lib/screens/register/register_step_1.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:pin_code_fields/pin_code_fields.dart'; import 'package:robo_advisory/utils/constants.dart'; import 'package:robo_advisory/screens/register/register_step_2.dart'; +import 'package:robo_advisory/widgets/buttons.dart'; class RegisterFirstScreen extends StatelessWidget { @override @@ -90,15 +91,7 @@ class RegisterFirstScreen extends StatelessWidget { SizedBox( width: double.infinity, child: ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: Color(0xFF495057), - foregroundColor: Colors.white, - padding: EdgeInsets.all(18.0), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(18.0), - ), - ), - + style: mainButtonStyle(), onPressed: () { Navigator.push( context, diff --git a/lib/screens/register/register_step_2.dart b/lib/screens/register/register_step_2.dart index 034c99c..c2af72c 100644 --- a/lib/screens/register/register_step_2.dart +++ b/lib/screens/register/register_step_2.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:robo_advisory/utils/constants.dart'; import 'package:robo_advisory/config/Routes.dart'; +import 'package:robo_advisory/widgets/buttons.dart'; class RegisterSecondScreen extends StatelessWidget { @override @@ -57,14 +58,7 @@ class RegisterSecondScreen extends StatelessWidget { SizedBox( width: double.infinity, child: ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: Color(0xFF495057), - foregroundColor: Colors.white, - padding: EdgeInsets.all(18.0), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(18.0), - ), - ), + style: mainButtonStyle(), onPressed: () { Navigator.pushNamed(context, Routes.dashboard); print('Next Step'); diff --git a/lib/widgets/buttons.dart b/lib/widgets/buttons.dart new file mode 100644 index 0000000..0bf95de --- /dev/null +++ b/lib/widgets/buttons.dart @@ -0,0 +1,11 @@ +import 'package:flutter/material.dart'; + +mainButtonStyle() { + return ElevatedButton.styleFrom( + backgroundColor: Color(0xFF495057), + foregroundColor: Colors.white, + padding: EdgeInsets.all(18.0), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(18.0), + )); +} -- 2.43.5