mirror of
https://github.com/nisrulz/flutter-examples.git
synced 2026-08-25 01:05:36 +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:
committed by
GitHub
parent
80fe9bed92
commit
8745f7cf5a
@@ -10,7 +10,10 @@ class MyApp extends StatelessWidget {
|
||||
title: 'Covid-19',
|
||||
theme: ThemeData(
|
||||
primarySwatch: Colors.blue,
|
||||
accentColor: Color(0xfff4796b),
|
||||
colorScheme: ColorScheme.fromSwatch(
|
||||
primarySwatch: Colors.blue,
|
||||
brightness: Brightness.dark,
|
||||
).copyWith(secondary: Color(0xfff4796b)),
|
||||
brightness: Brightness.dark,
|
||||
),
|
||||
home: Home(),
|
||||
|
||||
@@ -6,10 +6,10 @@ import 'package:http/http.dart' as http;
|
||||
Future getAllData() async {
|
||||
try {
|
||||
var allCountriesUrl = 'https://corona.lmao.ninja/v2/all';
|
||||
var allCountriesResponse = await http.get(allCountriesUrl);
|
||||
var allCountriesResponse = await http.get(Uri.parse(allCountriesUrl));
|
||||
|
||||
var particularCountryUrl = 'https://corona.lmao.ninja/v2/historical/India';
|
||||
var particularCountryResponse = await http.get(particularCountryUrl);
|
||||
var particularCountryResponse = await http.get(Uri.parse(particularCountryUrl));
|
||||
|
||||
// a list to store the data points
|
||||
List<Map<String, dynamic>> dataPoints = [];
|
||||
@@ -48,7 +48,7 @@ Future getAllData() async {
|
||||
Future getAllCountriesData() async {
|
||||
try {
|
||||
var url = 'https://corona.lmao.ninja/v2/countries?sort=country';
|
||||
var response = await http.get(url);
|
||||
var response = await http.get(Uri.parse(url));
|
||||
return response.body;
|
||||
} catch (e) {
|
||||
print(e);
|
||||
|
||||
@@ -10,7 +10,7 @@ import 'package:folding_cell/folding_cell.dart';
|
||||
class CountryList extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<dynamic> results;
|
||||
List<dynamic> results = [];
|
||||
return Scaffold(
|
||||
drawer: DrawerWidget(),
|
||||
appBar: AppBar(
|
||||
@@ -48,14 +48,15 @@ class CountryList extends StatelessWidget {
|
||||
return Container(
|
||||
color: Color(0xFF2e282a),
|
||||
alignment: Alignment.topCenter,
|
||||
child: SimpleFoldingCell(
|
||||
child: SimpleFoldingCell.create(
|
||||
key: _foldingCellKey,
|
||||
frontWidget: Builder(
|
||||
builder: (BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
SimpleFoldingCellState foldingCellState =
|
||||
context.findAncestorStateOfType();
|
||||
SimpleFoldingCellState? foldingCellState =
|
||||
context.findAncestorStateOfType<
|
||||
SimpleFoldingCellState>();
|
||||
foldingCellState?.toggleFold();
|
||||
},
|
||||
child: Container(
|
||||
@@ -68,17 +69,21 @@ class CountryList extends StatelessWidget {
|
||||
);
|
||||
},
|
||||
),
|
||||
innerTopWidget: buildInnerTopWidget(
|
||||
results[index]['country'],
|
||||
results[index]['todayCases'].toString(),
|
||||
results[index]['deaths'].toString(),
|
||||
results[index]['todayDeaths'].toString(),
|
||||
results[index]['recovered'].toString(),
|
||||
results[index]['critical'].toString(),
|
||||
results[index]['casesPerOneMillion'].toString(),
|
||||
innerWidget: Column(
|
||||
children: [
|
||||
buildInnerTopWidget(
|
||||
results[index]['country'],
|
||||
results[index]['todayCases'].toString(),
|
||||
results[index]['deaths'].toString(),
|
||||
results[index]['todayDeaths'].toString(),
|
||||
results[index]['recovered'].toString(),
|
||||
results[index]['critical'].toString(),
|
||||
results[index]['casesPerOneMillion'].toString(),
|
||||
),
|
||||
buildInnerBottomWidget(
|
||||
results[index]['cases'].toString()),
|
||||
],
|
||||
),
|
||||
innerBottomWidget: buildInnerBottomWidget(
|
||||
results[index]['cases'].toString()),
|
||||
cellSize: Size(MediaQuery.of(context).size.width, 125),
|
||||
padding: EdgeInsets.all(15),
|
||||
animationDuration: Duration(milliseconds: 300),
|
||||
|
||||
@@ -50,14 +50,14 @@ class CountrySearchDelegate extends SearchDelegate {
|
||||
return Container(
|
||||
color: Color(0xFF2e282a),
|
||||
alignment: Alignment.topCenter,
|
||||
child: SimpleFoldingCell(
|
||||
child: SimpleFoldingCell.create(
|
||||
key: _foldingCellKey,
|
||||
frontWidget: Builder(
|
||||
builder: (BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
SimpleFoldingCellState foldingCellState =
|
||||
context.findAncestorStateOfType();
|
||||
SimpleFoldingCellState? foldingCellState =
|
||||
context.findAncestorStateOfType<SimpleFoldingCellState>();
|
||||
foldingCellState?.toggleFold();
|
||||
},
|
||||
child: Container(
|
||||
@@ -70,17 +70,21 @@ class CountrySearchDelegate extends SearchDelegate {
|
||||
);
|
||||
},
|
||||
),
|
||||
innerTopWidget: buildInnerTopWidget(
|
||||
suggestionsList[index]['country'],
|
||||
suggestionsList[index]['todayCases'].toString(),
|
||||
suggestionsList[index]['deaths'].toString(),
|
||||
suggestionsList[index]['todayDeaths'].toString(),
|
||||
suggestionsList[index]['recovered'].toString(),
|
||||
suggestionsList[index]['critical'].toString(),
|
||||
suggestionsList[index]['casesPerOneMillion'].toString(),
|
||||
innerWidget: Column(
|
||||
children: [
|
||||
buildInnerTopWidget(
|
||||
suggestionsList[index]['country'],
|
||||
suggestionsList[index]['todayCases'].toString(),
|
||||
suggestionsList[index]['deaths'].toString(),
|
||||
suggestionsList[index]['todayDeaths'].toString(),
|
||||
suggestionsList[index]['recovered'].toString(),
|
||||
suggestionsList[index]['critical'].toString(),
|
||||
suggestionsList[index]['casesPerOneMillion'].toString(),
|
||||
),
|
||||
buildInnerBottomWidget(
|
||||
suggestionsList[index]['cases'].toString()),
|
||||
],
|
||||
),
|
||||
innerBottomWidget: buildInnerBottomWidget(
|
||||
suggestionsList[index]['cases'].toString()),
|
||||
cellSize: Size(MediaQuery.of(context).size.width, 125),
|
||||
padding: EdgeInsets.all(15),
|
||||
animationDuration: Duration(milliseconds: 300),
|
||||
@@ -122,14 +126,14 @@ class CountrySearchDelegate extends SearchDelegate {
|
||||
return Container(
|
||||
color: Color(0xFF2e282a),
|
||||
alignment: Alignment.topCenter,
|
||||
child: SimpleFoldingCell(
|
||||
child: SimpleFoldingCell.create(
|
||||
key: _foldingCellKey,
|
||||
frontWidget: Builder(
|
||||
builder: (BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
SimpleFoldingCellState foldingCellState =
|
||||
context.findAncestorStateOfType();
|
||||
SimpleFoldingCellState? foldingCellState =
|
||||
context.findAncestorStateOfType<SimpleFoldingCellState>();
|
||||
foldingCellState?.toggleFold();
|
||||
},
|
||||
child: Container(
|
||||
@@ -142,17 +146,21 @@ class CountrySearchDelegate extends SearchDelegate {
|
||||
);
|
||||
},
|
||||
),
|
||||
innerTopWidget: buildInnerTopWidget(
|
||||
suggestionsList[index]['country'],
|
||||
suggestionsList[index]['todayCases'].toString(),
|
||||
suggestionsList[index]['deaths'].toString(),
|
||||
suggestionsList[index]['todayDeaths'].toString(),
|
||||
suggestionsList[index]['recovered'].toString(),
|
||||
suggestionsList[index]['critical'].toString(),
|
||||
suggestionsList[index]['casesPerOneMillion'].toString(),
|
||||
),
|
||||
innerBottomWidget: buildInnerBottomWidget(
|
||||
suggestionsList[index]['cases'].toString()),
|
||||
innerWidget: Column(
|
||||
children: [
|
||||
buildInnerTopWidget(
|
||||
suggestionsList[index]['country'],
|
||||
suggestionsList[index]['todayCases'].toString(),
|
||||
suggestionsList[index]['deaths'].toString(),
|
||||
suggestionsList[index]['todayDeaths'].toString(),
|
||||
suggestionsList[index]['recovered'].toString(),
|
||||
suggestionsList[index]['critical'].toString(),
|
||||
suggestionsList[index]['casesPerOneMillion'].toString(),
|
||||
),
|
||||
buildInnerBottomWidget(
|
||||
suggestionsList[index]['cases'].toString()),
|
||||
],
|
||||
),
|
||||
cellSize: Size(MediaQuery.of(context).size.width, 125),
|
||||
padding: EdgeInsets.all(15),
|
||||
animationDuration: Duration(milliseconds: 300),
|
||||
|
||||
@@ -123,18 +123,20 @@ Widget buildInnerBottomWidget(String cases) {
|
||||
fontSize: 20.0,
|
||||
),
|
||||
)),
|
||||
FlatButton(
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
SimpleFoldingCellState foldingCellState =
|
||||
context.findAncestorStateOfType();
|
||||
SimpleFoldingCellState? foldingCellState =
|
||||
context.findAncestorStateOfType<SimpleFoldingCellState>();
|
||||
foldingCellState?.toggleFold();
|
||||
},
|
||||
child: Text(
|
||||
"Close",
|
||||
),
|
||||
color: Colors.black,
|
||||
shape: StadiumBorder(),
|
||||
splashColor: Colors.white.withOpacity(0.5),
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: Colors.black,
|
||||
shape: StadiumBorder(),
|
||||
overlayColor: Colors.white.withOpacity(0.5),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -1,22 +1,14 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:bezier_chart/bezier_chart.dart';
|
||||
import 'package:fl_chart/fl_chart.dart';
|
||||
|
||||
// Widget that will build the graph
|
||||
Widget buildGraph(
|
||||
BuildContext context, List<Map<String, dynamic>> datesAndValues) {
|
||||
// Data is avalaible from a particular date and we are getting that here
|
||||
final fromDate = datesAndValues[0]['date'];
|
||||
|
||||
// Data is avalaible until a particular date and we are getting that here
|
||||
final toDate = datesAndValues.last['date'];
|
||||
|
||||
// Add dates and values corresponding to those dates
|
||||
// in a list
|
||||
List<DataPoint<DateTime>> dataPoints = [];
|
||||
for (final dateAndValue in datesAndValues) {
|
||||
dataPoints.add(DataPoint<DateTime>(
|
||||
value: double.parse(dateAndValue['value'].toString()),
|
||||
xAxis: dateAndValue['date']));
|
||||
// Convert the dates and values into chart points.
|
||||
final spots = <FlSpot>[];
|
||||
for (var i = 0; i < datesAndValues.length; i++) {
|
||||
final value = double.parse(datesAndValues[i]['value'].toString());
|
||||
spots.add(FlSpot(i.toDouble(), value));
|
||||
}
|
||||
|
||||
return Center(
|
||||
@@ -26,24 +18,22 @@ Widget buildGraph(
|
||||
),
|
||||
height: MediaQuery.of(context).size.height / 2,
|
||||
width: MediaQuery.of(context).size.width,
|
||||
child: BezierChart(
|
||||
fromDate: fromDate,
|
||||
bezierChartScale: BezierChartScale.WEEKLY,
|
||||
toDate: toDate,
|
||||
selectedDate: toDate,
|
||||
series: [
|
||||
BezierLine(
|
||||
data: dataPoints,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: LineChart(
|
||||
LineChartData(
|
||||
gridData: FlGridData(show: true),
|
||||
titlesData: FlTitlesData(show: true),
|
||||
borderData: FlBorderData(show: true),
|
||||
lineBarsData: [
|
||||
LineChartBarData(
|
||||
spots: spots,
|
||||
isCurved: true,
|
||||
color: Colors.white,
|
||||
belowBarData: BarAreaData(show: false),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
config: BezierChartConfig(
|
||||
physics: BouncingScrollPhysics(),
|
||||
verticalIndicatorStrokeWidth: 3.0,
|
||||
verticalIndicatorColor: Colors.black26,
|
||||
showVerticalIndicator: true,
|
||||
verticalIndicatorFixedPosition: false,
|
||||
backgroundColor: Colors.transparent,
|
||||
footerHeight: 30.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user