0% found this document useful (0 votes)
7 views14 pages

Flutter Development Guide: Setup & Widgets

Uploaded by

Vivek Kushwaha
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views14 pages

Flutter Development Guide: Setup & Widgets

Uploaded by

Vivek Kushwaha
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Introduction to Flutter

• What is Flutter?
• Why use Flutter?
• Cross-platform development
• Single codebase for Android, iOS, Web,
Desktop
Flutter Architecture
• Framework, Engine, and Embedder
• Widgets are the building blocks
• Everything is a widget
Setting Up Flutter
• Install Flutter SDK
• Set up an editor (VS Code / Android Studio)
• Create your first Flutter app
Understanding Widgets
• StatelessWidget vs StatefulWidget
• Build method and widget tree
• Hot reload and hot restart
Layouts in Flutter
• Column, Row, Stack, ListView
• Container, Padding, Center
• Flexible and Expanded
Navigation and Routing
• Navigator class
• Named routes
• Push and pop routes
State Management
• Why manage state?
• setState, InheritedWidget, Provider
• Introduction to BLoC
Flutter StatelessWidget Example
• StatelessWidget example
• Used for immutable widgets

class MyWidget extends StatelessWidget {


@override
Widget build(BuildContext context) {
return Text('Hello, Flutter!');
}
}
Flutter StatefulWidget Example
• StatefulWidget example
• Used for dynamic UI updates
class CounterWidget extends StatefulWidget {
@override
_CounterWidgetState createState() => _CounterWidgetState();
}

class _CounterWidgetState extends State<CounterWidget> {


int _counter = 0;

void _increment() {
setState(() {
_counter++;
});
}

@override
Widget build(BuildContext context) {
return Column(
children: [
Text('Counter: \$_counter'),
ElevatedButton(onPressed: _increment, child: Text('Increment')),
],
);
}
Flutter BLoC Pattern
• What is BLoC (Business Logic Component)?
• Separating UI from logic
• Streams and Sinks
• Using flutter_bloc package
Implementing BLoC
• Create Event and State classes
• Create BLoC class
• BlocProvider and BlocBuilder
• Example use case: Counter App
BLoC Pattern - Counter Example
• BLoC separates business logic from UI
• Example using flutter_bloc

// Event
abstract class CounterEvent {}
class Increment extends CounterEvent {}

// State
class CounterState {
final int counter;
CounterState([Link]);
}

// BLoC
class CounterBloc extends Bloc<CounterEvent, CounterState> {
CounterBloc() : super(CounterState(0)) {
on<Increment>((event, emit) => emit(CounterState([Link] + 1)));
}
}
Using BlocBuilder in UI
• Connect BLoC to UI using BlocBuilder

BlocBuilder<CounterBloc, CounterState>(
builder: (context, state) {
return Column(
children: [
Text('Counter: \${[Link]}'),
ElevatedButton(
onPressed: () => [Link]<CounterBloc>().add(Increment()),
child: Text('Increment'),
),
],
);
},
)
Resources and Next Steps
• Flutter documentation: [Link]
• BLoC documentation: [Link]
• Practice building apps
• Explore advanced topics (animations, custom
widgets)

You might also like