1
0
mirror of https://github.com/nisrulz/flutter-examples.git synced 2026-09-01 12:40:43 +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

@@ -1,40 +1,40 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:meta/meta.dart';
class Home extends StatelessWidget {
Home(
{Key key,
@required this.onSignin,
@required this.onLogout,
@required this.showLoading})
: super(key: key);
const Home({
super.key,
required this.onSignin,
required this.onLogout,
required this.showLoading,
});
final VoidCallback onSignin;
final VoidCallback? onSignin;
final VoidCallback onLogout;
bool showLoading = false;
final bool showLoading;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("Sign In")),
appBar: AppBar(title: const Text("Sign In")),
body: Container(
padding: const EdgeInsets.all(20.0),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
showLoading
? CircularProgressIndicator()
: RaisedButton(
onPressed: this.onSignin,
child: Text("Sign In"),
color: Colors.lightBlueAccent,
padding: const EdgeInsets.all(20.0),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
showLoading
? const CircularProgressIndicator()
: ElevatedButton(
onPressed: onSignin,
style: ElevatedButton.styleFrom(
backgroundColor: Colors.lightBlueAccent,
),
//RaisedButton(onPressed: this.onLogout, child: Text("Logout"), color: Colors.amberAccent),
],
),
)),
child: const Text("Sign In"),
),
],
),
),
),
);
}
}

View File

@@ -8,71 +8,62 @@ import 'home.dart';
import 'user.dart';
void main() {
runApp(App());
runApp(const App());
}
class App extends StatefulWidget {
const App({super.key});
@override
AppState createState() => AppState();
}
class AppState extends State<App> {
String _username = "";
Widget currentPage;
GoogleSignIn googleSignIn;
Widget userPage;
final GoogleSignIn googleSignIn = GoogleSignIn.instance;
late Widget userPage;
@override
void initState() {
super.initState();
userPage = Home(
onSignin: () {
_signin();
print("Sign");
},
onSignin: _signin,
onLogout: _logout,
showLoading: false,
);
}
Future<FirebaseUser> _signin() async {
Future<User?> _signin() async {
setState(() {
userPage = Home(onSignin: null, onLogout: _logout, showLoading: true);
});
FirebaseAuth _auth = FirebaseAuth.instance;
try {
googleSignIn = GoogleSignIn();
GoogleSignInAccount googleSignInAccount = await googleSignIn.signIn();
final GoogleSignInAuthentication gauth = await googleSignInAccount.authentication;
final AuthCredential credential = GoogleAuthProvider.getCredential(
accessToken: gauth.accessToken,
idToken: gauth.idToken,
await googleSignIn.initialize();
final GoogleSignInAccount account = await googleSignIn.authenticate();
final GoogleSignInAuthentication auth = account.authentication;
final AuthCredential credential = GoogleAuthProvider.credential(
idToken: auth.idToken,
);
final AuthResult authRes = await _auth.signInWithCredential(credential);
final FirebaseUser user = authRes.user;
final UserCredential authRes =
await FirebaseAuth.instance.signInWithCredential(credential);
final User? user = authRes.user;
if (user == null) return null;
setState(() {
_username = user.displayName;
userPage = User(
onLogout: _logout,
user: user,
);
userPage = UserProfile(onLogout: _logout, user: user);
});
return user;
} catch (e) {
print(e.toString());
return null;
}
return null;
}
void _logout() async {
Future<void> _logout() async {
await googleSignIn.signOut();
setState(() {
userPage = Home(
onSignin: () {
_signin();
print("Sign");
},
onSignin: _signin,
onLogout: _logout,
showLoading: false,
);

View File

@@ -1,39 +1,43 @@
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:meta/meta.dart';
class User extends StatelessWidget {
User({Key key, @required this.onLogout, @required this.user})
: super(key: key);
class UserProfile extends StatelessWidget {
const UserProfile({
super.key,
required this.onLogout,
required this.user,
});
VoidCallback onLogout;
String username;
FirebaseUser user;
final VoidCallback onLogout;
final User user;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Welcome"),
title: const Text("Welcome"),
actions: <Widget>[
IconButton(
icon: Icon(Icons.exit_to_app), onPressed: this.onLogout)
icon: const Icon(Icons.exit_to_app),
onPressed: onLogout,
),
],
),
body: Container(
padding: const EdgeInsets.all(20.0),
child: Center(
child: Column(
padding: const EdgeInsets.all(20.0),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Image.network(user.photoUrl),
Image.network(user.photoURL ?? ''),
Text(
user.displayName,
textScaleFactor: 1.5,
user.displayName ?? '',
textScaler: const TextScaler.linear(1.5),
),
],
))),
),
),
),
);
}
}