mirror of
https://github.com/nisrulz/flutter-examples.git
synced 2026-08-25 01:05:36 +00:00
- Bump all apps to sdk >=3.0.0 <4.0.0 and add flutter_lints + a shared analysis_options.yaml to every app (flutter analyze is now green repo-wide) - Fix real compile errors in firebase_google_authentication and image_editor, plus deprecated APIs (Matrix4, SvgPicture.color, textScaleFactor), missing async 'mounted' guards, and misc lints via dart fix + manual fixes - Align pubspec 'name' with each folder and Android namespace/applicationId with the documented github.nisrulz.* convention - Convert bmi_calculator from a legacy Flutter module to a standard app with a proper android/ scaffold; fix missing android:exported in launcher manifests across 22 apps so all Android builds pass - Untrack generated build files (GeneratedPluginRegistrant, .flutter-plugins-dependencies) and ignore them
102 lines
2.9 KiB
Dart
102 lines
2.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
void main() {
|
|
runApp(MaterialApp(
|
|
// Title
|
|
title: "Simple Material App",
|
|
// Home
|
|
home: MyHome()));
|
|
}
|
|
|
|
class MyHome extends StatefulWidget {
|
|
const MyHome({super.key});
|
|
|
|
@override
|
|
MyHomeState createState() => MyHomeState();
|
|
}
|
|
|
|
class MyHomeState extends State<MyHome> {
|
|
// init the step to 0th position
|
|
int current_step = 0;
|
|
List<Step> my_steps = [
|
|
Step(
|
|
// Title of the Step
|
|
title: Text("Step 1"),
|
|
// Content, it can be any widget here. Using basic Text for this example
|
|
content: Text("Hello!"),
|
|
isActive: true),
|
|
Step(
|
|
title: Text("Step 2"),
|
|
content: Text("World!"),
|
|
// You can change the style of the step icon i.e number, editing, etc.
|
|
state: StepState.editing,
|
|
isActive: true),
|
|
Step(
|
|
title: Text("Step 3"),
|
|
content: Text("Hello World!"),
|
|
isActive: true),
|
|
];
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
// Appbar
|
|
appBar: AppBar(
|
|
// Title
|
|
title: Text("Simple Material App"),
|
|
),
|
|
// Body
|
|
body: Container(
|
|
child: Stepper(
|
|
// Using a variable here for handling the currentStep
|
|
currentStep: current_step,
|
|
// List the steps you would like to have
|
|
steps: my_steps,
|
|
// Define the type of Stepper style
|
|
// StepperType.horizontal : Horizontal Style
|
|
// StepperType.vertical : Vertical Style
|
|
type: StepperType.vertical,
|
|
// Know the step that is tapped
|
|
onStepTapped: (step) {
|
|
// On hitting step itself, change the state and jump to that step
|
|
setState(() {
|
|
// update the variable handling the current step value
|
|
// jump to the tapped step
|
|
current_step = step;
|
|
});
|
|
// Log function call
|
|
print("onStepTapped : $step");
|
|
},
|
|
onStepCancel: () {
|
|
// On hitting cancel button, change the state
|
|
setState(() {
|
|
// update the variable handling the current step value
|
|
// going back one step i.e subtracting 1, until its 0
|
|
if (current_step > 0) {
|
|
current_step = current_step - 1;
|
|
} else {
|
|
current_step = 0;
|
|
}
|
|
});
|
|
// Log function call
|
|
print("onStepCancel : $current_step");
|
|
},
|
|
// On hitting continue button, change the state
|
|
onStepContinue: () {
|
|
setState(() {
|
|
// update the variable handling the current step value
|
|
// going back one step i.e adding 1, until its the length of the step
|
|
if (current_step < my_steps.length - 1) {
|
|
current_step = current_step + 1;
|
|
} else {
|
|
current_step = 0;
|
|
}
|
|
});
|
|
// Log function call
|
|
print("onStepContinue : $current_step");
|
|
},
|
|
)),
|
|
);
|
|
}
|
|
}
|