-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
282 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,8 @@ | ||
include: package:flutter_lints/flutter.yaml | ||
include: package:very_good_analysis/analysis_options.5.1.0.yaml | ||
analyzer: | ||
exclude: | ||
- lib/l10n/* | ||
- lib/generated/* | ||
linter: | ||
rules: | ||
public_member_api_docs: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
extensions: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// ignore_for_file: avoid_print | ||
|
||
import 'package:flutter/material.dart'; | ||
|
||
class BasicsScreen extends StatelessWidget { | ||
const BasicsScreen({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: const Text('IE Workshop'), | ||
backgroundColor: Colors.red, | ||
actions: [ | ||
IconButton( | ||
onPressed: () {}, | ||
icon: const Icon(Icons.settings), | ||
), | ||
], | ||
), | ||
backgroundColor: Colors.green, | ||
body: SingleChildScrollView( | ||
child: Column( | ||
children: [ | ||
const Text('Hello world!'), | ||
const Text( | ||
'Hello world with style', | ||
style: TextStyle( | ||
fontSize: 34, | ||
color: Colors.blue, | ||
fontWeight: FontWeight.bold, | ||
), | ||
), | ||
const Text( | ||
'Tooooooooooooooo looooooooooooooooong text', | ||
style: TextStyle( | ||
fontSize: 34, | ||
color: Colors.pink, | ||
fontWeight: FontWeight.bold, | ||
), | ||
maxLines: 2, | ||
overflow: TextOverflow.ellipsis, | ||
), | ||
Container( | ||
height: 300, | ||
width: 300, | ||
color: Colors.amber, | ||
child: const Text('Hello in a colored box'), | ||
), | ||
const SizedBox( | ||
height: 15, | ||
), | ||
Container( | ||
height: 300, | ||
width: 300, | ||
color: Colors.amber, | ||
padding: const EdgeInsets.all(30), | ||
child: const Text('Hello in a colored box'), | ||
), | ||
Row( | ||
children: [ | ||
TextButton( | ||
onPressed: () { | ||
print('Button 1 pressed'); | ||
}, | ||
child: const Text('Button 1'), | ||
), | ||
ElevatedButton( | ||
onPressed: () { | ||
print('Button 2 pressed'); | ||
}, | ||
child: const Text('Button 2'), | ||
), | ||
], | ||
), | ||
const SizedBox( | ||
height: 100, | ||
), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:bloc/bloc.dart'; | ||
import 'package:equatable/equatable.dart'; | ||
import 'package:ie_workshop/sample_app/sample_app_screen.dart'; | ||
import 'package:meta/meta.dart'; | ||
|
||
part 'sample_event.dart'; | ||
part 'sample_state.dart'; | ||
|
||
class SampleBloc extends Bloc<SampleEvent, SampleState> { | ||
SampleBloc() : super(SampleInitial()) { | ||
on<FetchData>(_fetchData); | ||
} | ||
|
||
FutureOr<void> _fetchData(FetchData event, Emitter<SampleState> emit) async { | ||
await Future<void>.delayed(const Duration(seconds: 1)); | ||
final list = <MyItem>[]; | ||
for (var i = 0; i < 5; i++) { | ||
list.add( | ||
MyItem( | ||
name: 'Name $i', | ||
description: 'Description $i', | ||
url: 'https://picsum.photos/id/$i/200', | ||
), | ||
); | ||
} | ||
emit(SampleSucces(items: list)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
part of 'sample_bloc.dart'; | ||
|
||
class SampleEvent extends Equatable { | ||
const SampleEvent(); | ||
@override | ||
List<Object> get props => []; | ||
} | ||
|
||
class FetchData extends SampleEvent { | ||
const FetchData(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
part of 'sample_bloc.dart'; | ||
|
||
@immutable | ||
sealed class SampleState {} | ||
|
||
final class SampleInitial extends SampleState {} | ||
|
||
final class SampleLoading extends SampleState {} | ||
|
||
final class SampleSucces extends SampleState { | ||
SampleSucces({required this.items}); | ||
|
||
final List<MyItem> items; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
import 'package:ie_workshop/sample_app/bloc/sample_bloc.dart'; | ||
|
||
class MyItem { | ||
MyItem({ | ||
required this.name, | ||
required this.description, | ||
required this.url, | ||
}); | ||
|
||
final String name; | ||
final String description; | ||
final String url; | ||
} | ||
|
||
class SampleAppScreen extends StatelessWidget { | ||
const SampleAppScreen({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: const Text('My first app'), | ||
), | ||
body: BlocBuilder<SampleBloc, SampleState>( | ||
builder: (context, state) { | ||
if (state is SampleSucces) { | ||
return ListView.builder( | ||
itemBuilder: (context, index) { | ||
final item = state.items[index]; | ||
return ListTile( | ||
title: Text(item.name, style: const TextStyle(fontSize: 30)), | ||
subtitle: Text( | ||
item.description, | ||
style: const TextStyle(fontSize: 24), | ||
), | ||
leading: Image.network(item.url), | ||
trailing: const Icon(Icons.account_tree_sharp), | ||
onTap: () { | ||
Navigator.of(context).push( | ||
MaterialPageRoute<void>( | ||
builder: (context) { | ||
return DetailsScreen(item: item); | ||
}, | ||
), | ||
); | ||
}, | ||
); | ||
}, | ||
itemCount: state.items.length, | ||
); | ||
} | ||
return const Center(child: CircularProgressIndicator()); | ||
}, | ||
), | ||
); | ||
} | ||
} | ||
|
||
class DetailsScreen extends StatelessWidget { | ||
const DetailsScreen({required this.item, super.key}); | ||
|
||
final MyItem item; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: Text(item.name), | ||
), | ||
body: Text(item.description, style: const TextStyle(fontSize: 30)), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters