Showing posts with label 【FLUTTER ANDROID STUDIO and IOS】Using Named Routes and Passing Data with Named Routes Meal App. Show all posts
Showing posts with label 【FLUTTER ANDROID STUDIO and IOS】Using Named Routes and Passing Data with Named Routes Meal App. Show all posts

Wednesday, June 16, 2021

【FLUTTER ANDROID STUDIO and IOS】Using Named Routes and Passing Data with Named Routes Meal App

 import 'package:flutter/material.dart';


class CategoryMealsScreen extends StatelessWidget {
static const routeName = '/category-meals';
/*final String categoryId;
final String categoryTitle;

CategoryMealsScreen(this.categoryId, this.categoryTitle);*/

@override
Widget build(BuildContext context) {
final routeArgs =
ModalRoute.of(context).settings.arguments as Map<String, String>;
final categoryTitle = routeArgs['title'];
final categoryId = routeArgs['id'];

return Scaffold(
appBar: AppBar(
title: Text(categoryTitle),
),
body: Center(
child: Text(
'The Recipes For The Category!',
),
),
);
}
}

import 'package:flutter/material.dart';
import './category_meals_screen.dart';
class CategoryItem extends StatelessWidget {
final String id;
final String title;
final Color color;

CategoryItem(this.id, this.title, this.color);

void selectCategory(BuildContext ctx) {
Navigator.of(ctx).pushNamed(
CategoryMealsScreen.routeName,
arguments: {
'id': id,
'title': title,
},
);
}

@override
Widget build(BuildContext context) {
return InkWell(
onTap: () => selectCategory(context),
splashColor: Theme.of(context).primaryColor,
borderRadius: BorderRadius.circular(15),
child: Container(
padding: const EdgeInsets.all(15),
child: Text(
title,
style: Theme.of(context).textTheme.headline6,
),
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
color.withOpacity(0.7),
color,
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
borderRadius: BorderRadius.circular(15),
),
),
);
}
}
import 'package:flutter/material.dart';

class CategoryMealsScreen extends StatelessWidget {
static const routeName = '/category-meals';
/*final String categoryId;
final String categoryTitle;

CategoryMealsScreen(this.categoryId, this.categoryTitle);*/

@override
Widget build(BuildContext context) {
final routeArgs =
ModalRoute.of(context).settings.arguments as Map<String, String>;
final categoryTitle = routeArgs['title'];
final categoryId = routeArgs['id'];

return Scaffold(
appBar: AppBar(
title: Text(categoryTitle),
),
body: Center(
child: Text(
'The Recipes For The Category!',
),
),
);
}
}

End of Summer Sale ☀️😎

20% OFF Inside!🤯 ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏...