1
0
mirror of https://github.com/nisrulz/flutter-examples.git synced 2026-08-30 11:40:19 +00:00

chore: modernize Flutter examples — null safety, latest APIs, Kotlin DSL Gradle (#148)

* updates

* Update Gradle wrapper script to fetch latest version online and allow --version override

* chore(analytics_integration): migrate Gradle build scripts to Kotlin DSL

Convert Groovy build files to Kotlin DSL and bump Gradle wrapper.

* chore(animation_example): migrate Gradle build scripts to Kotlin DSL

Convert Groovy build files to Kotlin DSL.

* chore(biometrics): migrate Gradle build scripts to Kotlin DSL

Convert Groovy build files to Kotlin DSL.

* chore(bmi_calculator): test

test body

* chore(bottom_sheet): test

test body

* chore(custom_home_drawer): migrate Gradle build scripts to Kotlin DSL

Convert Groovy build files to Kotlin DSL and bump Gradle wrapper.

* chore(covid19_mobile_app): migrate Gradle build scripts to Kotlin DSL

Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper.

* chore(dropdown_button): migrate Gradle build scripts to Kotlin DSL

Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper.

* chore(enabling_splash_screen): migrate Gradle build scripts to Kotlin DSL

Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper.

* chore(expense_planner): migrate Gradle build scripts to Kotlin DSL

Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper.

* chore(firebase_crash_reporting): migrate Gradle build scripts to Kotlin DSL

Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper.

* chore(firebase_google_authentication): migrate Gradle build scripts to Kotlin DSL

Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper.

* chore(flutter_date_pickers-master): migrate Gradle build scripts to Kotlin DSL

Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper.

* chore(getx_counter_app): migrate Gradle build scripts to Kotlin DSL

Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper.

* chore(google_signin): migrate Gradle build scripts to Kotlin DSL

Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper.

* chore(grid_layout): remove legacy nested android project

Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies.

* chore(handling_routes): migrate Gradle build scripts to Kotlin DSL

Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper.

* chore(image_editor): migrate Gradle build scripts to Kotlin DSL

Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper.

* chore(image_from_network): migrate Gradle build scripts to Kotlin DSL

Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper.

* chore(infinite_list): migrate Gradle build scripts to Kotlin DSL

Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper.

* chore(load_local_image): remove legacy nested android project

Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies.

* chore(load_local_json): remove legacy nested android project

Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies.

* chore(lunch_app): migrate Gradle build scripts to Kotlin DSL

Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper.

* chore(navigation_drawer): remove legacy nested android project

Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies.

* chore(news_memes_app): migrate Gradle build scripts to Kotlin DSL

Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper.

* chore(persist_key_value): remove legacy nested android project

Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies.

* chore(push_notifications): migrate Gradle build scripts to Kotlin DSL

Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper.

* chore(save_data_locally_with_sqlite): migrate Gradle build scripts to Kotlin DSL

Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper.

* chore(scan_qr_code): migrate Gradle build scripts to Kotlin DSL

Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper.

* chore(simple_material_app): remove legacy nested android project

Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies.

* chore(sliver_app_bar_example): migrate Gradle build scripts to Kotlin DSL

Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper.

* chore(stateful_widget): remove legacy nested android project

Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies.

* chore(stateless_widgets): remove legacy nested android project

Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies.

* chore(statless_counter_app): migrate Gradle build scripts to Kotlin DSL

Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper.

* chore(tic_tac_toe): migrate Gradle build scripts to Kotlin DSL

Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper.

* chore(tip_calculator): remove legacy nested android project

Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies.

* chore(todo_list_using_provider): migrate Gradle build scripts to Kotlin DSL

Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper.

* chore(unit_testing): migrate Gradle build scripts to Kotlin DSL

Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper.

* chore(using_alert_dialog): remove legacy nested android project

Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies.

* chore(using_bottom_nav_bar): remove legacy nested android project

Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies.

* chore(using_custom_fonts): remove legacy nested android project

Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies.

* chore(using_edittext): remove legacy nested android project

Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies.

* chore(using_expansionpanel): migrate Gradle build scripts to Kotlin DSL

Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper.

* chore(using_firebase_db): migrate Gradle build scripts to Kotlin DSL

Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper.

* chore(using_gradient): remove legacy nested android project

Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies.

* chore(using_http_get): remove legacy nested android project

Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies.

* chore(using_interactiveviewer): migrate Gradle build scripts to Kotlin DSL

Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper.

* chore(using_listview): remove legacy nested android project

Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies.

* chore(using_listwheelscrollview): migrate Gradle build scripts to Kotlin DSL

Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper.

* chore(using_platform_adaptive): migrate Gradle build scripts to Kotlin DSL

Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper.

* chore(using_snackbar): remove legacy nested android project

Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies.

* chore(using_stepper): remove legacy nested android project

Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies.

* chore(using_tabs): remove legacy nested android project

Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies.

* chore(using_theme): remove legacy nested android project

Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies.

* chore(view_pdf_file): migrate Gradle build scripts to Kotlin DSL

Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper.

* chore: ignore .trash directory

* chore: remove IDE configs and PR template

* chore(infinite_list): remove legacy nested android project

* refactor(infinite_list): migrate theme to ColorScheme API

* refactor(using_theme): migrate to ColorScheme API

* refactor(analytics_integration): migrate Firebase Analytics API

* refactor(firebase_google_authentication): migrate Google Sign-In API

* refactor(covid19_mobile_app): migrate theme and buttons to current API

* refactor(covid19_mobile_app): replace bezier_chart with fl_chart

* refactor(image_editor): migrate image plugins and button styles

* refactor(scan_qr_code): migrate mobile_scanner API

* refactor(lunch_app): migrate to null safety

* refactor(todo_list_using_provider): migrate to null safety

* refactor(unit_testing): migrate to null safety

* refactor(using_firebase_db): migrate Firebase Database API

* fix(update_gradle_wrapper): edit gradle-wrapper.properties directly

* refactor(push_notifications): migrate Firebase Messaging API

* refactor(using_http_get): migrate to null safety

* refactor(using_listview): migrate to null safety

* refactor(using_listwheelscrollview): migrate to null safety

* refactor(view_pdf_file): migrate to null safety

* refactor(bottom_sheet): migrate to null safety

* refactor(stateless_widgets): migrate to null safety

* chore: regenerate Gradle wrapper

* refactor: move maintenance scripts to Makefile

* chore: remove generated and IDE files

* fix: migrate image_editor to current plugins

* fix: migrate news_memes_app share to share_plus

* fix: migrate view_pdf_file to syncfusion pdf viewer

* fix: update deprecated APIs

* style: remove commented-out code
This commit is contained in:
Nishant Srivastava
2026-08-17 13:58:51 +02:00
committed by GitHub
parent 80fe9bed92
commit 8745f7cf5a
2600 changed files with 9278 additions and 58100 deletions

View File

@@ -14,25 +14,23 @@ class MyApp extends StatelessWidget {
title: 'Personal Expenses',
theme: ThemeData(
primarySwatch: Colors.purple,
accentColor: Colors.amber,
// errorColor: Colors.red,
colorScheme: ColorScheme.fromSwatch(primarySwatch: Colors.purple)
.copyWith(secondary: Colors.amber),
fontFamily: 'Quicksand',
textTheme: ThemeData.light().textTheme.copyWith(
title: TextStyle(
titleMedium: TextStyle(
fontFamily: 'OpenSans',
fontWeight: FontWeight.bold,
fontSize: 18,
),
button: TextStyle(color: Colors.white),
labelLarge: TextStyle(color: Colors.white),
),
appBarTheme: AppBarTheme(
textTheme: ThemeData.light().textTheme.copyWith(
title: TextStyle(
fontFamily: 'OpenSans',
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
titleTextStyle: TextStyle(
fontFamily: 'OpenSans',
fontSize: 20,
fontWeight: FontWeight.bold,
),
)),
home: MyHomePage(),
);
@@ -40,27 +38,12 @@ class MyApp extends StatelessWidget {
}
class MyHomePage extends StatefulWidget {
// String titleInput;
// String amountInput;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final List<Transaction> _userTransactions = [
// Transaction(
// id: 't1',
// title: 'New Shoes',
// amount: 69.99,
// date: DateTime.now(),
// ),
// Transaction(
// id: 't2',
// title: 'Weekly Groceries',
// amount: 16.53,
// date: DateTime.now(),
// ),
];
final List<Transaction> _userTransactions = [];
List<Transaction> get _recentTransactions {
return _userTransactions.where((tx) {
@@ -121,7 +104,6 @@ class _MyHomePageState extends State<MyHomePage> {
),
body: SingleChildScrollView(
child: Column(
// mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Chart(_recentTransactions),

View File

@@ -1,5 +1,3 @@
import 'package:flutter/foundation.dart';
class Transaction {
final String id;
final String title;
@@ -7,9 +5,9 @@ class Transaction {
final DateTime date;
Transaction({
@required this.id,
@required this.title,
@required this.amount,
@required this.date,
required this.id,
required this.title,
required this.amount,
required this.date,
});
}

View File

@@ -33,7 +33,7 @@ class Chart extends StatelessWidget {
double get totalSpending {
return groupedTransactionValues.fold(0.0, (sum, item) {
return sum + item['amount'];
return sum + (item['amount'] as double);
});
}
@@ -50,8 +50,8 @@ class Chart extends StatelessWidget {
return Flexible(
fit: FlexFit.tight,
child: ChartBar(
data['day'],
data['amount'],
data['day'] as String,
data['amount'] as double,
totalSpending == 0.0
? 0.0
: (data['amount'] as double) / totalSpending,

View File

@@ -13,7 +13,7 @@ class NewTransaction extends StatefulWidget {
class _NewTransactionState extends State<NewTransaction> {
final _titleController = TextEditingController();
final _amountController = TextEditingController();
DateTime _selectedDate;
DateTime? _selectedDate;
void _submitData() {
if (_amountController.text.isEmpty) {
@@ -29,7 +29,7 @@ class _NewTransactionState extends State<NewTransaction> {
widget.addTx(
enteredTitle,
enteredAmount,
_selectedDate,
_selectedDate!,
);
Navigator.of(context).pop();
@@ -65,9 +65,6 @@ class _NewTransactionState extends State<NewTransaction> {
decoration: InputDecoration(labelText: 'Title'),
controller: _titleController,
onSubmitted: (_) => _submitData(),
// onChanged: (val) {
// titleInput = val;
// },
),
TextField(
decoration: InputDecoration(labelText: 'Amount'),
@@ -83,27 +80,31 @@ class _NewTransactionState extends State<NewTransaction> {
child: Text(
_selectedDate == null
? 'No Date Chosen!'
: 'Picked Date: ${DateFormat.yMd().format(_selectedDate)}',
: 'Picked Date: ${DateFormat.yMd().format(_selectedDate!)}',
),
),
FlatButton(
textColor: Theme.of(context).primaryColor,
TextButton(
onPressed: _presentDatePicker,
style: TextButton.styleFrom(
foregroundColor: Theme.of(context).primaryColor,
),
child: Text(
'Choose Date',
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
onPressed: _presentDatePicker,
),
],
),
),
RaisedButton(
child: Text('Add Transaction'),
color: Theme.of(context).primaryColor,
textColor: Theme.of(context).textTheme.button.color,
ElevatedButton(
onPressed: _submitData,
style: ElevatedButton.styleFrom(
backgroundColor: Theme.of(context).primaryColor,
foregroundColor: Theme.of(context).textTheme.labelLarge?.color,
),
child: Text('Add Transaction'),
),
],
),

View File

@@ -18,7 +18,7 @@ class TransactionList extends StatelessWidget {
children: <Widget>[
Text(
'No transactions added yet!',
style: Theme.of(context).textTheme.title,
style: Theme.of(context).textTheme.titleLarge,
),
SizedBox(
height: 20,
@@ -51,14 +51,14 @@ class TransactionList extends StatelessWidget {
),
title: Text(
transactions[index].title,
style: Theme.of(context).textTheme.title,
style: Theme.of(context).textTheme.titleLarge,
),
subtitle: Text(
DateFormat.yMMMd().format(transactions[index].date),
),
trailing: IconButton(
icon: Icon(Icons.delete),
color: Theme.of(context).errorColor,
color: Theme.of(context).colorScheme.error,
onPressed: () => deleteTx(transactions[index].id),
),
),

View File

@@ -10,7 +10,20 @@ class UserTransactions extends StatefulWidget {
}
class _UserTransactionsState extends State<UserTransactions> {
Function deleteTx;
late final Function deleteTx;
void _deleteTx(String id) {
setState(() {
_userTransactions.removeWhere((tx) => tx.id == id);
});
}
@override
void initState() {
deleteTx = _deleteTx;
super.initState();
}
final List<Transaction> _userTransactions = [
Transaction(
id: 't1',
@@ -44,7 +57,7 @@ class _UserTransactionsState extends State<UserTransactions> {
return Column(
children: <Widget>[
NewTransaction(_addNewTransaction),
TransactionList(_userTransactions, deleteTx()),
TransactionList(_userTransactions, deleteTx),
],
);
}